Author: indika
Date: Fri Jan 11 04:45:48 2008
New Revision: 12152

Log:

some minor improvement


Modified:
   
branches/esb/java/1.6/esb/java/modules/core/src/main/java/org/wso2/esb/ServiceBusManager.java

Modified: 
branches/esb/java/1.6/esb/java/modules/core/src/main/java/org/wso2/esb/ServiceBusManager.java
==============================================================================
--- 
branches/esb/java/1.6/esb/java/modules/core/src/main/java/org/wso2/esb/ServiceBusManager.java
       (original)
+++ 
branches/esb/java/1.6/esb/java/modules/core/src/main/java/org/wso2/esb/ServiceBusManager.java
       Fri Jan 11 04:45:48 2008
@@ -59,6 +59,7 @@
 import java.lang.management.ManagementFactory;
 import java.net.UnknownHostException;
 import java.rmi.NoSuchObjectException;
+import java.rmi.RemoteException;
 import java.rmi.registry.LocateRegistry;
 import java.rmi.server.UnicastRemoteObject;
 import java.util.*;
@@ -518,24 +519,35 @@
     }
 
     private void startJMXService() {
+
         String jmxPort = 
ServiceBusConfiguration.getInstance().getFirstProperty("Ports.JMX");
         if (jmxPort != null) {
+            // only jmx support is available for jdk 1.5 
             String javaVersion = System.getProperty("java.version");
             if (javaVersion.indexOf("1.4") != -1) { // In ESB, JMX is not 
supported on JDK 1.4
                 log.warn("JMX is not supported on JDK 1.4. " +
                     "Please use JDK 1.5 or newer version if you requre JMX 
functionality.");
                 return;
             }
-            log.info("Starting JMX Connector");
+
+            log.info("Starting the JMX Connector");
+            
             int jmxPortInt = Integer.parseInt(jmxPort);
             MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+
+            //creating local registry
             try {
                 rmiRegistry = LocateRegistry.createRegistry(jmxPortInt);
-                // Create an RMI connector and start it
+            } catch (RemoteException e) {
+                String msg = "Couldn't create a localregistry(RMI)";
+                handleException(msg, e);
+            }
+
+            // Create an RMI connector and start it
+            try {
                 String jmxURL = "service:jmx:rmi:///jndi/rmi://" +
                     NetworkUtils.getLocalHostname() + ":" + jmxPortInt + 
"/esb";
                 JMXServiceURL url = new JMXServiceURL(jmxURL);
-
                 // Security credentials are included in the env Map
                 HashMap env = new HashMap();
                 env.put(JMXConnectorServer.AUTHENTICATOR, new 
ESBJMXAuthenticator());
@@ -544,9 +556,8 @@
                 jmxConnectorServer.start();
                 log.info("JMX Service URL      : " + jmxURL);
             } catch (Exception e) {
-                String msg = "Could not initialize MBean server";
-                log.error(msg, e);
-                throw new ServiceBusException(msg, e);
+                String msg = "Couldn't initialize the JMX Connector on the 
port ' " + jmxPort + " '";
+                handleException(msg, e);
             }
         }
     }
@@ -558,16 +569,14 @@
                 jmxConnectorServer.stop();
             } catch (IOException e) {
                 String msg = "Error when Shutting down the JMX Connector ";
-                log.error(msg, e);
-                throw new ServiceBusException(msg, e);
+                handleException(msg, e);
             }
         }
         try {
             UnicastRemoteObject.unexportObject(rmiRegistry, true);
         } catch (NoSuchObjectException e) {
             String msg = "Error when stoping localregistry(RMI)";
-            log.error(msg, e);
-            throw new ServiceBusException(msg, e);
+            handleException(msg, e);
         }
     }
 
@@ -577,7 +586,7 @@
         if (jmxAgentName == null || "".equals(jmxAgentName)) {
             jmxAgentName = "org.wso2.esb";
         }
-        
+
         registerMBean(mbs, new ServerView(),
             jmxAgentName + ":Type=Admin,ConnectorName=ServerAdmin");
         registerMBean(mbs, new ServerStatusView(),

_______________________________________________
Esb-java-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/esb-java-dev

Reply via email to