tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r1235221 - /tuscany/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java
Date Tue, 24 Jan 2012 12:29:04 GMT
Author: antelder
Date: Tue Jan 24 12:29:04 2012
New Revision: 1235221

URL: http://svn.apache.org/viewvc?rev=1235221&view=rev
Log:
Change the JMS binding MessageProcessor discovery to use ServiceDiscovery so that additional
processors can be added in OSGi

Modified:
    tuscany/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java

Modified: tuscany/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java?rev=1235221&r1=1235220&r2=1235221&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java
Tue Jan 24 12:29:04 2012
@@ -24,6 +24,7 @@ import java.lang.reflect.Constructor;
 import org.apache.tuscany.sca.binding.jms.JMSBinding;
 import org.apache.tuscany.sca.binding.jms.JMSBindingException;
 import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
 
 /**
  * Utility methods to load JMS message processors.
@@ -74,32 +75,19 @@ public class JMSMessageProcessorUtil {
 //    }
 //
     private static Object instantiate(ClassLoader cl, String className, JMSBinding binding,
ExtensionPointRegistry registry) {
-        Object instance;
-        if (cl == null) {
-            cl = binding.getClass().getClassLoader();
-        }
-
         try {
-            Class<?> clazz;
-
-            try {
-                clazz = cl.loadClass(className);
-            } catch (ClassNotFoundException e) {
-            	// MJE 07/12/2010 - for OSGi the default message processor belongs to the same
bundle as
-            	// this JMSMessageProcessorUtil itself and so the "correct" classloader to use
is the classloader
-            	// for THIS class, and not the binding class (which is a different bundle)
-                // clazz = binding.getClass().getClassLoader().loadClass(className);
-                clazz = JMSMessageProcessorUtil.class.getClassLoader().loadClass(className);
+            for (ServiceDeclaration sd : registry.getServiceDiscovery().getServiceDeclarations(JMSMessageProcessor.class))
{
+                if (className.equals(sd.getClassName())) {
+                    Class<?> clazz = sd.loadClass();
+                    Constructor<?> constructor = clazz.getDeclaredConstructor(new Class[]
{JMSBinding.class, ExtensionPointRegistry.class});
+                    return constructor.newInstance(binding, registry);
+                }
+                
             }
-
-            Constructor<?> constructor = clazz.getDeclaredConstructor(new Class[] {JMSBinding.class,
ExtensionPointRegistry.class});
-            instance = constructor.newInstance(binding, registry);
-
+            throw new JMSBindingException("Class not found: " + className);
         } catch (Throwable e) {
             throw new JMSBindingException("Exception instantiating OperationAndDataBinding
class", e);
         }
-
-        return instance;
     }
 
     public static JMSMessageProcessor getRequestMessageProcessor(ExtensionPointRegistry registry,
JMSBinding binding) {



Mime
View raw message