Subversion Repositories SmartDukaan

Rev

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

Rev 4719 Rev 4729
Line 41... Line 41...
41
        initialize();
41
        initialize();
42
    }
42
    }
43
    
43
    
44
    private static void initialize() {
44
    private static void initialize() {
45
        try {
45
        try {
46
            int port = 9013;
-
 
47
            try {
46
            
48
                dbHost = "jdbc:mysql://" + ConfigClient.getClient().get(ConfigClientKeys.warehouse_service_db_hostname.toString()) + "/warehouse";
47
            dbHost = "jdbc:mysql://" + ConfigClient.getClient().get(ConfigClientKeys.warehouse_service_db_hostname.toString()) + "/warehouse";
49
                String portNo = ConfigClient.getClient().get(ConfigClientKeys.warehouse_service_server_port.toString());
48
            String portNo = ConfigClient.getClient().get(ConfigClientKeys.warehouse_service_server_port.toString());
50
                port = Integer.parseInt(portNo);
49
            int port = Integer.parseInt(portNo);
51
            } catch(Exception e) {
50
        
52
                log.warn("Unable to get port number from the Config server because of:", e);
-
 
53
            }
51
        
54
 
-
 
55
            // Setting dbHost env property to make this value accessible in context.xml 
-
 
56
            // while spring context creation.
52
            
57
            System.setProperty("dbHost", dbHost);
-
 
58
 
-
 
59
            handler = new WarehouseServiceHandler();
53
            handler = new WarehouseServiceHandler();
60
            processor = new Processor<Iface>(handler);
54
            processor = new Processor<Iface>(handler);
-
 
55
            
-
 
56
	        log.info("DB Connection String is: " + dbHost);
-
 
57
	        log.info("URL read by data source before setting is: " + handler.getDataSourceUrl());
-
 
58
	        handler.setDataSourceUrl(dbHost);
-
 
59
	        log.info("URL read by data source after setting is: " + handler.getDataSourceUrl());
-
 
60
 
61
            TServerTransport serverTransport = new TServerSocket(port);
61
            TServerTransport serverTransport = new TServerSocket(port);
62
            TTransportFactory tFactory = new TFramedTransport.Factory();
62
            TTransportFactory tFactory = new TFramedTransport.Factory();
63
            TProtocolFactory pFactory = new TBinaryProtocol.Factory();
63
            TProtocolFactory pFactory = new TBinaryProtocol.Factory();
64
            
64
            
65
            Args serverParams = new Args(serverTransport);
65
            Args serverParams = new Args(serverTransport);
Line 75... Line 75...
75
        }
75
        }
76
    }
76
    }
77
    
77
    
78
    public void destroy() {
78
    public void destroy() {
79
        System.out.println("Warehouse Server stopped.");
79
        System.out.println("Warehouse Server stopped.");
80
        // TODO Auto-generated method stub
-
 
81
        
-
 
82
    }
80
    }
83
 
81
 
84
    public void init(DaemonContext dc) throws Exception {
82
    public void init(DaemonContext dc) throws Exception {
85
        System.out.println("Initializing Warehouse Server...");
83
        System.out.println("Initializing Warehouse Server...");
86
        // TODO Auto-generated method stub
-
 
87
        
-
 
88
    }
84
    }
89
 
85
 
90
    public void start() throws Exception {
86
    public void start() throws Exception {
91
        System.out.println("Starting Warehouse Server");
87
    	log.info("Starting Warehouse Server");
92
        initialize();
88
        initialize();
93
        // TODO Auto-generated method stub
-
 
94
        
-
 
95
    }
89
    }
96
 
90
 
97
    public void stop() throws Exception {
91
    public void stop() throws Exception {
98
        System.out.println("Stopping Warehouse Server...");
92
        log.info("Stopping Warehouse Server...");
99
        server.stop();
93
        server.stop();
100
        System.exit(0);
-
 
101
        // TODO Auto-generated method stub
-
 
102
        
-
 
103
    }
94
    }
104
}
95
}