Subversion Repositories SmartDukaan

Rev

Rev 4637 | Rev 4719 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4637 Rev 4718
Line 7... Line 7...
7
import in.shop2020.utils.ConfigClientKeys;
7
import in.shop2020.utils.ConfigClientKeys;
8
import in.shop2020.warehouse.WarehouseService.Iface;
8
import in.shop2020.warehouse.WarehouseService.Iface;
9
import in.shop2020.warehouse.WarehouseService.Processor;
9
import in.shop2020.warehouse.WarehouseService.Processor;
10
import in.shop2020.warehouse.service.handler.WarehouseServiceHandler;
10
import in.shop2020.warehouse.service.handler.WarehouseServiceHandler;
11
 
11
 
-
 
12
import org.apache.commons.daemon.Daemon;
-
 
13
import org.apache.commons.daemon.DaemonContext;
-
 
14
 
12
import org.apache.commons.logging.Log;
15
import org.apache.commons.logging.Log;
13
import org.apache.commons.logging.LogFactory;
16
import org.apache.commons.logging.LogFactory;
14
import org.apache.thrift.protocol.TBinaryProtocol;
17
import org.apache.thrift.protocol.TBinaryProtocol;
15
import org.apache.thrift.protocol.TProtocolFactory;
18
import org.apache.thrift.protocol.TProtocolFactory;
16
import org.apache.thrift.server.TServer;
19
import org.apache.thrift.server.TServer;
Line 30... Line 33...
30
 
33
 
31
    private static WarehouseServiceHandler handler;
34
    private static WarehouseServiceHandler handler;
32
 
35
 
33
    private static Processor<Iface> processor;
36
    private static Processor<Iface> processor;
34
    private static String dbHost;
37
    private static String dbHost;
-
 
38
    private static TServer server;
35
 
39
 
36
    public static void main(String[] args){
40
    public static void main(String[] args){
-
 
41
        initialize();
-
 
42
    }
-
 
43
    
-
 
44
    private static void initialize() {
37
        try {
45
        try {
38
            int port = 9013;
46
            int port = 9013;
39
            try {
47
            try {
40
                dbHost = "jdbc:mysql://" + ConfigClient.getClient().get(ConfigClientKeys.warehouse_service_db_hostname.toString()) + "/warehouse";
48
                dbHost = "jdbc:mysql://" + ConfigClient.getClient().get(ConfigClientKeys.warehouse_service_db_hostname.toString()) + "/warehouse";
41
                String portNo = ConfigClient.getClient().get(ConfigClientKeys.warehouse_service_server_port.toString());
49
                String portNo = ConfigClient.getClient().get(ConfigClientKeys.warehouse_service_server_port.toString());
Line 56... Line 64...
56
            
64
            
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
            TServer server = new TThreadPoolServer(serverParams);
69
            server = new TThreadPoolServer(serverParams);
62
            
70
            
63
            log.info("Warehouse service started on port " + port);
71
            log.info("Warehouse service started on port " + port);
64
            server.serve();
72
            server.serve();
65
        }catch(Exception ex){
73
        }catch(Exception ex){
66
            ex.printStackTrace();
74
            ex.printStackTrace();
67
        }
75
        }
68
    }
76
    }
-
 
77
    
-
 
78
    public void destroy() {
-
 
79
        System.out.println("Warehouse Server stopped.");
-
 
80
        // TODO Auto-generated method stub
-
 
81
        
-
 
82
    }
-
 
83
 
-
 
84
    public void init(DaemonContext dc) throws Exception {
-
 
85
        System.out.println("Initializing Warehouse Server...");
-
 
86
        // TODO Auto-generated method stub
-
 
87
        
-
 
88
    }
-
 
89
 
-
 
90
    public void start() throws Exception {
-
 
91
        System.out.println("Starting Warehouse Server");
-
 
92
        initialize();
-
 
93
        // TODO Auto-generated method stub
-
 
94
        
-
 
95
    }
-
 
96
 
-
 
97
    public void stop() throws Exception {
-
 
98
        System.out.println("Stopping Warehouse Server...");
-
 
99
        server.stop();
-
 
100
        System.exit(0);
-
 
101
        // TODO Auto-generated method stub
-
 
102
        
-
 
103
    }
69
}
104
}