[esb-java-dev] svn commit r704 - esb/java/trunk/modules/core/src/main/java/org/wso2/esb

svn at wso2.com svn at wso2.com
Sun Feb 4 22:37:27 PST 2007


Author: asankha
Date: Sun Feb  4 22:37:22 2007
New Revision: 704

Modified:
   esb/java/trunk/modules/core/src/main/java/org/wso2/esb/ServiceBusManager.java
Log:
fix exception and wait till the DB actually starts.. else throw an exception

Modified: esb/java/trunk/modules/core/src/main/java/org/wso2/esb/ServiceBusManager.java
==============================================================================
--- esb/java/trunk/modules/core/src/main/java/org/wso2/esb/ServiceBusManager.java	(original)
+++ esb/java/trunk/modules/core/src/main/java/org/wso2/esb/ServiceBusManager.java	Sun Feb  4 22:37:22 2007
@@ -89,18 +89,27 @@
         try {
             networkServerControl = new NetworkServerControl();
             networkServerControl.start(null);
-            networkServerControl.ping();
-            log.info("Derby NetworkServer is started");
+            for (int i=0; i<5; i++) {
+                Thread.sleep(1000);
+                try {
+                    networkServerControl.ping();
+                    log.info("Derby SB Network Server started..");
+                    Properties properties = networkServerControl.getCurrentProperties();
+                    String host = properties.getProperty("derby.drda.host");
+                    int port = Integer.parseInt(properties.getProperty("derby.drda.portNumber"));
+                    log.info("DataBase Network Server :: Host :" + host + " Port :" + port);
+                    return;
+                } catch (Exception ignore) {}
+            }
+            log.fatal("Derby DB Network Server failed to start");
+            throw new ServiceBusException("Derby DB Network Server failed to start");
         } catch (UnknownHostException e) {
             throw new ServiceBusException(e);
         } catch (Exception e) {
             throw new ServiceBusException(e);
         }
-        Properties properties = networkServerControl.getCurrentProperties();
-        String host = properties.getProperty("derby.drda.host");
-        int port = Integer.parseInt(properties.getProperty("derby.drda.portNumber"));
-        log.info("DataBase Network Server :: Host :" + host + " Port :" + port);
     }
+    
     public void stopDataBaseServer() throws ServiceBusException {
         if (networkServerControl != null) {
             try {




More information about the Esb-java-dev mailing list