[jboss-svn-commits] JBL Code SVN: r23740 - labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/services/registry.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Nov 6 03:58:34 EST 2008
Author: kevin.conner at jboss.com
Date: 2008-11-06 03:58:34 -0500 (Thu, 06 Nov 2008)
New Revision: 23740
Modified:
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/services/registry/RegistryFactory.java
Log:
Do not recreate on every call: JBESB-2157
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/services/registry/RegistryFactory.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/services/registry/RegistryFactory.java 2008-11-06 05:55:55 UTC (rev 23739)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/services/registry/RegistryFactory.java 2008-11-06 08:58:34 UTC (rev 23740)
@@ -38,14 +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;
}
+ /**
+ * 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;
}
@@ -53,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);
@@ -80,6 +112,8 @@
+ e.getLocalizedMessage(), e);
}
+ singleton = registry;
+
return registry;
}
}
More information about the jboss-svn-commits
mailing list