cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1396015 - in /cxf/trunk: rt/management/src/main/java/org/apache/cxf/management/jmx/ services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/listeners/ tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/pr...
Date Tue, 09 Oct 2012 13:08:03 GMT
Author: coheigea
Date: Tue Oct  9 13:08:03 2012
New Revision: 1396015

URL: http://svn.apache.org/viewvc?rev=1396015&view=rev
Log:
Fixing some lazy initialization problems

Modified:
    cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/jmx/MBServerConnectorFactory.java
    cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/listeners/WSDiscoveryServerListener.java
    cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/FrontendFactory.java

Modified: cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/jmx/MBServerConnectorFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/jmx/MBServerConnectorFactory.java?rev=1396015&r1=1396014&r2=1396015&view=diff
==============================================================================
--- cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/jmx/MBServerConnectorFactory.java
(original)
+++ cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/jmx/MBServerConnectorFactory.java
Tue Oct  9 13:08:03 2012
@@ -45,7 +45,6 @@ public final class MBServerConnectorFact
     
     private static final Logger LOG = LogUtils.getL7dLogger(MBServerConnectorFactory.class);
 
-    private static MBServerConnectorFactory factory;
     private static MBeanServer server;
 
     private static String serviceUrl = DEFAULT_SERVICE_URL;
@@ -57,6 +56,16 @@ public final class MBServerConnectorFact
     private static boolean daemon;
 
     private static JMXConnectorServer connectorServer;
+
+    private static class MBServerConnectorFactoryHolder {
+        private static final MBServerConnectorFactory INSTANCE = 
+            new MBServerConnectorFactory();
+    }
+
+    private static class MBeanServerHolder {
+        private static final MBeanServer INSTANCE = 
+            MBeanServerFactory.createMBeanServer(); 
+    }
     
     private MBServerConnectorFactory() {
         
@@ -87,10 +96,7 @@ public final class MBServerConnectorFact
     }
     
     public static MBServerConnectorFactory getInstance() {
-        if (factory == null) {
-            factory = new MBServerConnectorFactory();
-        } 
-        return factory;        
+        return MBServerConnectorFactoryHolder.INSTANCE;
     }  
     
     public void setMBeanServer(MBeanServer ms) {
@@ -116,9 +122,7 @@ public final class MBServerConnectorFact
 
     public void createConnector() throws IOException {
         
-        if (server == null) {
-            server = MBeanServerFactory.createMBeanServer(); 
-        }
+        server = MBeanServerHolder.INSTANCE;
         
         // Create the JMX service URL.
         JMXServiceURL url = new JMXServiceURL(serviceUrl);       

Modified: cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/listeners/WSDiscoveryServerListener.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/listeners/WSDiscoveryServerListener.java?rev=1396015&r1=1396014&r2=1396015&view=diff
==============================================================================
--- cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/listeners/WSDiscoveryServerListener.java
(original)
+++ cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/listeners/WSDiscoveryServerListener.java
Tue Oct  9 13:08:03 2012
@@ -31,10 +31,16 @@ import org.apache.cxf.ws.discovery.inter
  * 
  */
 public class WSDiscoveryServerListener implements ServerLifeCycleListener {
-    static WSDiscoveryServiceImpl staticService;
-    
     final Bus bus;
     volatile WSDiscoveryServiceImpl service;
+
+    private static final class WSDiscoveryServiceImplHolder {
+        private static final WSDiscoveryServiceImpl INSTANCE;
+        static {
+            Bus bus = BusFactory.newInstance().createBus();
+            INSTANCE = new WSDiscoveryServiceImpl(bus);
+        }
+    }
     
     
     public WSDiscoveryServerListener(Bus bus) {
@@ -53,11 +59,7 @@ public class WSDiscoveryServerListener i
     }
 
     private static WSDiscoveryServiceImpl getStaticService() {
-        if (staticService == null) {
-            Bus bus = BusFactory.newInstance().createBus();
-            staticService = new WSDiscoveryServiceImpl(bus);
-        }
-        return staticService;
+        return WSDiscoveryServiceImplHolder.INSTANCE;
     }
 
     public void startServer(Server server) {

Modified: cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/FrontendFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/FrontendFactory.java?rev=1396015&r1=1396014&r2=1396015&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/FrontendFactory.java
(original)
+++ cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/FrontendFactory.java
Tue Oct  9 13:08:03 2012
@@ -35,7 +35,6 @@ import org.apache.cxf.tools.java2wsdl.pr
 import org.apache.cxf.tools.util.AnnotationUtil;
 
 public final class FrontendFactory {
-    private static FrontendFactory instance;
     private Class<?> serviceClass;
     private List<Method> wsMethods;
     
@@ -45,6 +44,11 @@ public final class FrontendFactory {
                        WebService.class,
                        WebServiceProvider.class};
 
+    private static final class FrontendFactoryHolder {
+        private static final FrontendFactory INSTANCE = 
+            new FrontendFactory();
+    }
+
     public enum Style {
         Jaxws,
         Simple
@@ -54,10 +58,7 @@ public final class FrontendFactory {
     }
 
     public static FrontendFactory getInstance() {
-        if (instance == null) {
-            instance = new FrontendFactory();
-        }
-        return instance;
+        return FrontendFactoryHolder.INSTANCE;
     }
 
     private boolean isJaxws() {



Mime
View raw message