[jboss-svn-commits] JBL Code SVN: r20126 - labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/registry.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri May 23 09:07:51 EDT 2008


Author: mark.little at jboss.com
Date: 2008-05-23 09:07:51 -0400 (Fri, 23 May 2008)
New Revision: 20126

Modified:
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/registry/RegistryFactory.java
Log:
http://jira.jboss.com/jira/browse/JBESB-1755

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/registry/RegistryFactory.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/registry/RegistryFactory.java	2008-05-23 12:47:41 UTC (rev 20125)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/registry/RegistryFactory.java	2008-05-23 13:07:51 UTC (rev 20126)
@@ -38,17 +38,36 @@
 
    private static Registry singleton;
 
+   /**
+    * Set the singleton. Any existing instance will be overwritten.
+    * 
+    * @param registry
+    */
+   
    public static synchronized void setRegistry(Registry registry)
    {
       singleton = registry;
    }
 
-    public static Registry getRegistrySingleton() {
+   /**
+    * Get the singleton.
+    * 
+    * @return the singleton or <code>null</code> if one has not been created.
+    */
+   
+    public static synchronized Registry getRegistrySingleton() {
         return singleton;
     }
 
-    public static Registry getRegistry() throws RegistryException {
-        // no synchronized block as there should be a service that initializes this
+    /**
+     * Obtain the current registry singleton or create a new instance if one
+     * is not available. This will assign the singleton as well.
+     * 
+     * @return the singleton
+     * @throws RegistryException
+     */
+    
+    public static synchronized Registry getRegistry() throws RegistryException {
         if (singleton != null) {
             return singleton;
         }
@@ -56,9 +75,19 @@
         return createRegistry();
     }
 
-    public static Registry createRegistry()
+    /**
+     * Create a new registry (singleton) or return a pre-existing instance.
+     * 
+     * @return the registry singleton
+     * @throws RegistryException
+     */
+    
+    public static synchronized Registry createRegistry()
            throws RegistryException
    {
+        if (singleton != null)
+            return singleton;
+        
       Registry registry = null;
       String className = Configuration.getRegistryImplementationClass();
       logger.log(Level.DEBUG, "Going to load " + className);
@@ -83,6 +112,8 @@
                + e.getLocalizedMessage(), e);
       }
 
+      singleton = registry;
+      
       return registry;
    }
 }




More information about the jboss-svn-commits mailing list