[hornetq-commits] JBoss hornetq SVN: r8511 - trunk/src/main/org/hornetq/core/client/impl.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Dec 2 18:51:36 EST 2009


Author: clebert.suconic at jboss.com
Date: 2009-12-02 18:51:36 -0500 (Wed, 02 Dec 2009)
New Revision: 8511

Modified:
   trunk/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java
Log:
just a tweak

Modified: trunk/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java	2009-12-02 23:05:09 UTC (rev 8510)
+++ trunk/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java	2009-12-02 23:51:36 UTC (rev 8511)
@@ -264,54 +264,58 @@
       }
    }
 
-   private void initialise() throws Exception
+   private synchronized void initialise() throws Exception
    {
-      setThreadPools();
+      if (!readOnly)
+      {
+         readOnly = true;
+         setThreadPools();
 
-      instantiateLoadBalancingPolicy();
+         instantiateLoadBalancingPolicy();
 
-      if (discoveryAddress != null)
-      {
-         InetAddress groupAddress = InetAddress.getByName(discoveryAddress);
+         if (discoveryAddress != null)
+         {
+            InetAddress groupAddress = InetAddress.getByName(discoveryAddress);
 
-         discoveryGroup = new DiscoveryGroupImpl(UUIDGenerator.getInstance().generateStringUUID(),
-                                                 discoveryAddress,
-                                                 groupAddress,
-                                                 discoveryPort,
-                                                 discoveryRefreshTimeout);
+            discoveryGroup = new DiscoveryGroupImpl(UUIDGenerator.getInstance().generateStringUUID(),
+                                                    discoveryAddress,
+                                                    groupAddress,
+                                                    discoveryPort,
+                                                    discoveryRefreshTimeout);
 
-         discoveryGroup.registerListener(this);
+            discoveryGroup.registerListener(this);
 
-         discoveryGroup.start();
-      }
-      else if (staticConnectors != null)
-      {
-         for (Pair<TransportConfiguration, TransportConfiguration> pair : staticConnectors)
+            discoveryGroup.start();
+         }
+         else if (staticConnectors != null)
          {
-            FailoverManager cm = new FailoverManagerImpl(this,
-                                                         pair.a,
-                                                         pair.b,
-                                                         failoverOnServerShutdown,
-                                                         callTimeout,
-                                                         clientFailureCheckPeriod,
-                                                         connectionTTL,
-                                                         retryInterval,
-                                                         retryIntervalMultiplier,
-                                                         maxRetryInterval,
-                                                         reconnectAttempts,
-                                                         threadPool,
-                                                         scheduledThreadPool,
-                                                         interceptors);
+            for (Pair<TransportConfiguration, TransportConfiguration> pair : staticConnectors)
+            {
+               FailoverManager cm = new FailoverManagerImpl(this,
+                                                            pair.a,
+                                                            pair.b,
+                                                            failoverOnServerShutdown,
+                                                            callTimeout,
+                                                            clientFailureCheckPeriod,
+                                                            connectionTTL,
+                                                            retryInterval,
+                                                            retryIntervalMultiplier,
+                                                            maxRetryInterval,
+                                                            reconnectAttempts,
+                                                            threadPool,
+                                                            scheduledThreadPool,
+                                                            interceptors);
 
-            failoverManagerMap.put(pair, cm);
+               failoverManagerMap.put(pair, cm);
+            }
+
+            updatefailoverManagerArray();
          }
-
-         updatefailoverManagerArray();
+         else
+         {
+            throw new IllegalStateException("Before using a session factory you must either set discovery address and port or " + "provide some static transport configuration");
+         }
       }
-      else
-      {
-         throw new IllegalStateException("Before using a session factory you must either set discovery address and port or " + "provide some static transport configuration");
-      }
    }
 
    // Static
@@ -1077,7 +1081,7 @@
       }
    }
 
-   private synchronized ClientSession createSessionInternal(final String username,
+   private ClientSession createSessionInternal(final String username,
                                                final String password,
                                                final boolean xa,
                                                final boolean autoCommitSends,
@@ -1100,8 +1104,6 @@
          {
             throw new HornetQException(HornetQException.INTERNAL_ERROR, "Failed to initialise session factory", e);
          }
-
-         readOnly = true;
       }
 
       if (discoveryGroup != null && !receivedBroadcast)



More information about the hornetq-commits mailing list