Subversion Repositories SmartDukaan

Rev

Rev 3853 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3853 Rev 4718
Line 7... Line 7...
7
import in.shop2020.crm.CRMService.Processor;
7
import in.shop2020.crm.CRMService.Processor;
8
import in.shop2020.crm.service.handler.CRMServiceHandler;
8
import in.shop2020.crm.service.handler.CRMServiceHandler;
9
import in.shop2020.thrift.clients.config.ConfigClient;
9
import in.shop2020.thrift.clients.config.ConfigClient;
10
import in.shop2020.utils.ConfigClientKeys;
10
import in.shop2020.utils.ConfigClientKeys;
11
 
11
 
-
 
12
import org.apache.commons.daemon.Daemon;
-
 
13
import org.apache.commons.daemon.DaemonContext;
12
import org.apache.thrift.protocol.TBinaryProtocol;
14
import org.apache.thrift.protocol.TBinaryProtocol;
13
import org.apache.thrift.protocol.TProtocolFactory;
15
import org.apache.thrift.protocol.TProtocolFactory;
14
import org.apache.thrift.server.TServer;
16
import org.apache.thrift.server.TServer;
15
import org.apache.thrift.server.TThreadPoolServer;
17
import org.apache.thrift.server.TThreadPoolServer;
16
import org.apache.thrift.server.TThreadPoolServer.Args;
18
import org.apache.thrift.server.TThreadPoolServer.Args;
Line 25... Line 27...
25
 * Service for accessing all necessary data relevant for CRM tool.
27
 * Service for accessing all necessary data relevant for CRM tool.
26
 * Example tickets, activities, agents etc.
28
 * Example tickets, activities, agents etc.
27
 *
29
 *
28
 * @author mandeep
30
 * @author mandeep
29
 */
31
 */
30
public class CRMServer {
32
public class CRMServer implements Daemon {
31
    private static Logger            logger = LoggerFactory.getLogger(CRMServer.class);
33
    private static Logger            logger = LoggerFactory.getLogger(CRMServer.class);
32
 
34
 
33
    private static CRMServiceHandler handler;
35
    private static CRMServiceHandler handler;
34
 
36
 
35
    private static Processor<Iface>       processor;
37
    private static Processor<Iface>       processor;
-
 
38
    
-
 
39
    private static TServer server;
36
 
40
    
37
    public static void main(String[] args) {
41
    public static void main(String[] args) {
-
 
42
        initialize();
-
 
43
    }
-
 
44
 
-
 
45
    private static void initialize() {
38
        try {
46
        try {
39
            handler = new CRMServiceHandler();
47
            handler = new CRMServiceHandler();
40
			processor = new Processor<Iface>(handler);
48
			processor = new Processor<Iface>(handler);
41
            int port = 9014;
49
            int port = 9014;
42
            try {
50
            try {
Line 57... Line 65...
57
        	Args serverParams = new Args(serverTransport);
65
        	Args serverParams = new Args(serverTransport);
58
			serverParams.processor(processor);
66
			serverParams.processor(processor);
59
			serverParams.transportFactory(tFactory);
67
			serverParams.transportFactory(tFactory);
60
			serverParams.protocolFactory(pFactory);
68
			serverParams.protocolFactory(pFactory);
61
			
69
			
62
			TServer server = new TThreadPoolServer(serverParams);
70
			server = new TThreadPoolServer(serverParams);
63
 
71
 
64
            logger.info("CRM service started on port 9014");
72
            logger.info("CRM service started on port 9014");
65
            server.serve();
73
            server.serve();
66
        } catch (Exception ex) {
74
        } catch (Exception ex) {
67
            logger.error("Error starting server", ex);
75
            logger.error("Error starting server", ex);
68
        }
76
        }
69
    }
77
    }
-
 
78
 
-
 
79
    public void destroy() {
-
 
80
        System.out.println("CRMServer stopped.");
-
 
81
        // TODO Auto-generated method stub
-
 
82
        
-
 
83
    }
-
 
84
 
-
 
85
    public void init(DaemonContext dc) throws Exception {
-
 
86
        System.out.println("Initializing CRMServer...");
-
 
87
        // TODO Auto-generated method stub
-
 
88
        
-
 
89
    }
-
 
90
 
-
 
91
    public void start() throws Exception {
-
 
92
        System.out.println("Starting CRM");
-
 
93
        initialize();
-
 
94
        // TODO Auto-generated method stub
-
 
95
        
-
 
96
    }
-
 
97
 
-
 
98
    public void stop() throws Exception {
-
 
99
        System.out.println("Stopping CRMServer...");
-
 
100
        server.stop();
-
 
101
        System.exit(0);
-
 
102
        // TODO Auto-generated method stub
-
 
103
        
-
 
104
    }
70
}
105
}
71
106