[jboss-svn-commits] JBL Code SVN: r7310 - in labs/jbossesb/trunk/product/core/services: src/org/jboss/soa/esb/services/registry tests/src/org/jboss/soa/esb/services/registry
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Nov 1 20:49:03 EST 2006
Author: kurt.stam at jboss.com
Date: 2006-11-01 20:49:01 -0500 (Wed, 01 Nov 2006)
New Revision: 7310
Modified:
labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/Registry.java
labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/RegistryFactory.java
labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/RegistryUnitTest.java
Log:
Cleaning up registry
Modified: labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/Registry.java
===================================================================
--- labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/Registry.java 2006-11-02 01:46:14 UTC (rev 7309)
+++ labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/Registry.java 2006-11-02 01:49:01 UTC (rev 7310)
@@ -29,7 +29,7 @@
*
* @author Kurt Stam
*/
-interface Registry
+public interface Registry
{
/**
* Removes a service from the Registry along with all the ServiceBindings underneath it.
Modified: labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/RegistryFactory.java
===================================================================
--- labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/RegistryFactory.java 2006-11-02 01:46:14 UTC (rev 7309)
+++ labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/RegistryFactory.java 2006-11-02 01:49:01 UTC (rev 7310)
@@ -24,52 +24,30 @@
import org.apache.log4j.Logger;
import org.apache.log4j.Priority;
import org.jboss.soa.esb.common.Configuration;
+import org.jboss.soa.esb.common.Factory;
/**
* Returns an Instance of the Registry.
* @author kstam
*
*/
-public class RegistryFactory
+public class RegistryFactory extends Factory
{
- private static Logger logger = Logger.getLogger(RegistryFactory.class);
+ private static Logger logger = Logger.getLogger(RegistryException.class);
- public static Registry getRegistry() {
+ public static Registry getRegistry() throws RegistryException{
Registry registry = null;
String className = Configuration.getRegistryImplementationClass();
+ logger.log(Priority.INFO, "Going to load " + className);
try {
- // instruct class loader to load the TransportFactory
+ // instruct class loader to load the Registry Implementation
Class registryClass = getClassForName(className);
// Try to instance the Registry
registry = (Registry) registryClass.newInstance();
} catch (ClassNotFoundException cnfex) {
- cnfex.printStackTrace();
- } catch (java.lang.Exception ex) {
- ex.printStackTrace();
+ throw new RegistryException("Registry Implementation=" + className + " not found", cnfex);
+ } catch (Exception e) {
+ throw new RegistryException("Invokation exception. " + e.getLocalizedMessage(), e);
}
return registry;
}
-
- /**
- * Loads the class with the given name.
- * @param className - the className to be found
- * @return - the class
- * @throws ClassNotFoundException
- */
- private static Class getClassForName(String className) throws ClassNotFoundException
- {
- Class clazz = null;
- try {
- logger.log(Priority.DEBUG, "Using the Context ClassLoader");
- ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
- clazz = Class.forName(className, true, contextClassLoader);
- } catch (ClassNotFoundException classNotFound) {
- if (logger.isDebugEnabled()) {
- logger.log(Priority.WARN, "The Contect ClassLoader could not find the class.");
- logger.log(Priority.WARN, "Using the System ClassLoader");
- }
- ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
- clazz = Class.forName(className, true, systemClassLoader);
- }
- return clazz;
- }
}
Modified: labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/RegistryUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/RegistryUnitTest.java 2006-11-02 01:46:14 UTC (rev 7309)
+++ labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/RegistryUnitTest.java 2006-11-02 01:49:01 UTC (rev 7310)
@@ -66,9 +66,9 @@
@Test
public void publishEPR()
{
- Registry registry = RegistryFactory.getRegistry();
EPR epr = new EPR();
try {
+ Registry registry = RegistryFactory.getRegistry();
registry.registerEPR(CATEGORY, SERVICE_NAME, "Service for traveling",
epr, "Specific Service Binding for traveling");
} catch (RegistryException re) {
@@ -82,8 +82,8 @@
@Test
public void findService()
{
- Registry registry = RegistryFactory.getRegistry();
try {
+ Registry registry = RegistryFactory.getRegistry();
Collection<String> services = registry.findServices(CATEGORY);
for (Iterator i=services.iterator();i.hasNext();) {
String serviceName = (String) i.next();
@@ -101,8 +101,8 @@
@Test
public void findEPRs()
{
- Registry registry = RegistryFactory.getRegistry();
try {
+ Registry registry = RegistryFactory.getRegistry();
Collection<EPR> eprs = registry.findEPRs(CATEGORY, SERVICE_NAME);
for (Iterator i=eprs.iterator();i.hasNext();) {
EPR epr = (EPR) i.next();
@@ -116,8 +116,8 @@
@Test
public void unregisterEPR()
{
- Registry registry = RegistryFactory.getRegistry();
try {
+ Registry registry = RegistryFactory.getRegistry();
EPR eprToBeRemoved = new EPR();
registry.unRegisterEPR(CATEGORY, SERVICE_NAME, eprToBeRemoved);
// Now make sure this EPR is really gone
@@ -132,8 +132,8 @@
@Test
public void unregisterService()
{
- Registry registry = RegistryFactory.getRegistry();
try {
+ Registry registry = RegistryFactory.getRegistry();
registry.unRegisterService(CATEGORY, SERVICE_NAME);
//Make sure it's really gone
Collection<String> services = registry.findAllServices();
More information about the jboss-svn-commits
mailing list