servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r391596 - in /incubator/servicemix/trunk/servicemix-jms/src/main: java/org/apache/servicemix/jms/ java/org/apache/servicemix/jms/multiplexing/ resources/META-INF/services/ resources/META-INF/services/org/ resources/META-INF/services/org/apa...
Date Wed, 05 Apr 2006 12:03:29 GMT
Author: gnodet
Date: Wed Apr  5 05:03:27 2006
New Revision: 391596

URL: http://svn.apache.org/viewcvs?rev=391596&view=rev
Log:
First step before SM-378 to allow different jms processors to be used

Added:
    incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/multiplexing/
    incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/multiplexing/MultiplexingConsumerProcessor.java
      - copied, changed from r391398, incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/MultiplexingConsumerProcessor.java
    incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/multiplexing/MultiplexingProviderProcessor.java
      - copied, changed from r391398, incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/MultiplexingProviderProcessor.java
    incubator/servicemix/trunk/servicemix-jms/src/main/resources/META-INF/services/
    incubator/servicemix/trunk/servicemix-jms/src/main/resources/META-INF/services/org/
    incubator/servicemix/trunk/servicemix-jms/src/main/resources/META-INF/services/org/apache/
    incubator/servicemix/trunk/servicemix-jms/src/main/resources/META-INF/services/org/apache/servicemix/
    incubator/servicemix/trunk/servicemix-jms/src/main/resources/META-INF/services/org/apache/servicemix/jms/
    incubator/servicemix/trunk/servicemix-jms/src/main/resources/META-INF/services/org/apache/servicemix/jms/multiplexing
Removed:
    incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/MultiplexingConsumerProcessor.java
    incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/MultiplexingProviderProcessor.java
Modified:
    incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsConfiguration.java
    incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsConfigurationMBean.java
    incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsEndpoint.java
    incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsLifeCycle.java

Modified: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsConfiguration.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsConfiguration.java?rev=391596&r1=391595&r2=391596&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsConfiguration.java
(original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsConfiguration.java
Wed Apr  5 05:03:27 2006
@@ -15,13 +15,16 @@
  */
 package org.apache.servicemix.jms;
 
-public class JmsConfiguration implements JmsConfigurationMBean {
+import org.apache.servicemix.common.PersistentConfiguration;
+
+public class JmsConfiguration extends PersistentConfiguration implements JmsConfigurationMBean
{
 
     private String userName;
     private String password;
     private String jndiInitialContextFactory;
     private String jndiProviderUrl;
-    private String jndiName;
+    private String jndiConnectionFactoryName;
+    private String processorName = "multiplexing";
     
     /**
      * @return Returns the password.
@@ -34,6 +37,7 @@
      */
     public void setPassword(String password) {
         this.password = password;
+        save();
     }
     /**
      * @return Returns the userName.
@@ -46,18 +50,20 @@
      */
     public void setUserName(String userName) {
         this.userName = userName;
+        save();
     }
     /**
      * @return Returns the jndiName.
      */
-    public String getJndiName() {
-        return jndiName;
+    public String getJndiConnectionFactoryName() {
+        return jndiConnectionFactoryName;
     }
     /**
      * @param jndiName The jndiName to set.
      */
-    public void setJndiName(String jndiName) {
-        this.jndiName = jndiName;
+    public void setJndiConnectionFactoryName(String jndiName) {
+        this.jndiConnectionFactoryName = jndiName;
+        save();
     }
     /**
      * @return Returns the jndiInitialContextFactory.
@@ -70,6 +76,7 @@
      */
     public void setJndiInitialContextFactory(String jndiInitialContextFactory) {
         this.jndiInitialContextFactory = jndiInitialContextFactory;
+        save();
     }
     /**
      * @return Returns the jndiProviderUrl.
@@ -82,8 +89,56 @@
      */
     public void setJndiProviderUrl(String jndiProviderUrl) {
         this.jndiProviderUrl = jndiProviderUrl;
+        save();
+    }
+    /**
+     * @return Returns the processorName.
+     */
+    public String getProcessorName() {
+        return processorName;
+    }
+    /**
+     * @param processorName The processorName to set.
+     */
+    public void setProcessorName(String processorName) {
+        this.processorName = processorName;
+        save();
     }
     
+    public void save() {
+        properties.setProperty("userName", userName);
+        properties.setProperty("password", password);
+        properties.setProperty("jndiInitialContextFactory", jndiInitialContextFactory);
+        properties.setProperty("jndiProviderUrl", jndiProviderUrl);
+        properties.setProperty("jndiName", jndiConnectionFactoryName);
+        properties.setProperty("processorName", processorName);
+        super.save();
+    }
     
-    
+    public boolean load() {
+        if (super.load()) {
+            if (properties.getProperty("userName") != null) {
+                userName = properties.getProperty("userName");
+            }
+            if (properties.getProperty("password") != null) {
+                password = properties.getProperty("password");
+            }
+            if (properties.getProperty("jndiInitialContextFactory") != null) {
+                jndiInitialContextFactory = properties.getProperty("jndiInitialContextFactory");
+            }
+            if (properties.getProperty("jndiProviderUrl") != null) {
+                jndiProviderUrl = properties.getProperty("jndiProviderUrl");
+            }
+            if (properties.getProperty("jndiName") != null) {
+                jndiConnectionFactoryName = properties.getProperty("jndiName");
+            }
+            if (properties.getProperty("processorName") != null) {
+                processorName = properties.getProperty("processorName");
+            }
+            return true;
+        } else {
+            return false;
+        }
+    }
+
 }

Modified: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsConfigurationMBean.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsConfigurationMBean.java?rev=391596&r1=391595&r2=391596&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsConfigurationMBean.java
(original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsConfigurationMBean.java
Wed Apr  5 05:03:27 2006
@@ -34,11 +34,35 @@
      */
     public void setUserName(String userName);
     /**
-     * @return Returns the jndiName.
+     * @return Returns the jndiConnectionFactoryName.
      */
-    public String getJndiName();
+    public String getJndiConnectionFactoryName();
     /**
-     * @param jndiName The jndiName to set.
+     * @param jndiConnectionFactoryName The jndiName to set.
      */
-    public void setJndiName(String jndiName);
+    public void setJndiConnectionFactoryName(String jndiConnectionFactoryName);
+    /**
+     * @return Returns the jndiInitialContextFactory.
+     */
+    public String getJndiInitialContextFactory();
+    /**
+     * @param jndiInitialContextFactory The jndiInitialContextFactory to set.
+     */
+    public void setJndiInitialContextFactory(String jndiInitialContextFactory);
+    /**
+     * @return Returns the jndiProviderUrl.
+     */
+    public String getJndiProviderUrl();
+    /**
+     * @param jndiProviderUrl The jndiProviderUrl to set.
+     */
+    public void setJndiProviderUrl(String jndiProviderUrl);
+    /**
+     * @return Returns the processName.
+     */
+    public String getProcessorName();
+    /**
+     * @param processorName The processorName to set.
+     */
+    public void setProcessorName(String processorName);
 }

Modified: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsEndpoint.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsEndpoint.java?rev=391596&r1=391595&r2=391596&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsEndpoint.java
(original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsEndpoint.java
Wed Apr  5 05:03:27 2006
@@ -15,7 +15,10 @@
  */
 package org.apache.servicemix.jms;
 
+import java.io.InputStream;
+import java.lang.reflect.Constructor;
 import java.util.Iterator;
+import java.util.Properties;
 
 import javax.jbi.servicedesc.ServiceEndpoint;
 import javax.jms.ConnectionFactory;
@@ -49,6 +52,7 @@
     // Spring configuration
     protected ConnectionFactory connectionFactory;
     protected Destination destination;
+    protected String processorName;
     
     public JmsEndpoint() {
     }
@@ -187,11 +191,62 @@
     }
 
     protected ExchangeProcessor createProviderProcessor() {
-        return new MultiplexingProviderProcessor(this);
+        return createProcessor("provider");
     }
 
     protected ExchangeProcessor createConsumerProcessor() {
-        return new MultiplexingConsumerProcessor(this);
+        return createProcessor("consumer");
+    }
+    
+    protected ExchangeProcessor createProcessor(String type) {
+        try {
+            String procName = processorName;
+            if (processorName == null) {
+                JmsLifeCycle lf = (JmsLifeCycle) getServiceUnit().getComponent().getLifeCycle();
+                procName = lf.getConfiguration().getProcessorName();
+            }
+            String uri = "META-INF/services/org/apache/servicemix/jms/" + procName;
+            InputStream in = loadResource(uri);
+            Properties props = new Properties();
+            props.load(in);
+            String className = props.getProperty(type);
+            Class cl = loadClass(className);
+            Constructor cns = cl.getConstructor(new Class[] { getClass() });
+            return (ExchangeProcessor) cns.newInstance(new Object[] { this });
+        } catch (Exception e) {
+            throw new RuntimeException("Could not create processor of type " + type + " and
name " + processorName, e);
+        }
+    }
+
+    /**
+     * Attempts to load the class on the current thread context class loader or
+     * the class loader which loaded us
+     */
+    protected Class loadClass(String name) throws ClassNotFoundException {
+        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+        if (contextClassLoader != null) {
+            try {
+                return contextClassLoader.loadClass(name);
+            }
+            catch (ClassNotFoundException e) {
+            }
+        }
+        return getClass().getClassLoader().loadClass(name);
+    }
+
+    /**
+     * Loads the resource from the given URI
+     */
+    protected InputStream loadResource(String uri) {
+        // lets try the thread context class loader first
+        InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(uri);
+        if (in == null) {
+            in = getClass().getClassLoader().getResourceAsStream(uri);
+            if (in == null) {
+                logger.debug("Could not find resource: " + uri);
+            }
+        }
+        return in;
     }
 
     protected ServiceEndpoint createExternalEndpoint() {
@@ -248,6 +303,20 @@
                 "endpoint: " + endpoint + ", " + 
                 "address: " + jndiDestinationName + "(" + destinationStyle + "), " + 
                 "soap: " + soap + "]";
+    }
+
+    /**
+     * @return Returns the processorName.
+     */
+    public String getProcessorName() {
+        return processorName;
+    }
+
+    /**
+     * @param processorName The processorName to set.
+     */
+    public void setProcessorName(String processorName) {
+        this.processorName = processorName;
     }
 
 }

Modified: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsLifeCycle.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsLifeCycle.java?rev=391596&r1=391595&r2=391596&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsLifeCycle.java
(original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/JmsLifeCycle.java
Wed Apr  5 05:03:27 2006
@@ -34,6 +34,15 @@
         return configuration;
     }
 
+    /* (non-Javadoc)
+     * @see org.apache.servicemix.common.BaseLifeCycle#doInit()
+     */
+    protected void doInit() throws Exception {
+        super.doInit();
+        configuration.setRootDir(context.getWorkspaceRoot());
+        configuration.load();
+    }
+    
     /**
      * @return Returns the configuration.
      */

Copied: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/multiplexing/MultiplexingConsumerProcessor.java
(from r391398, incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/MultiplexingConsumerProcessor.java)
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/multiplexing/MultiplexingConsumerProcessor.java?p2=incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/multiplexing/MultiplexingConsumerProcessor.java&p1=incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/MultiplexingConsumerProcessor.java&r1=391398&r2=391596&rev=391596&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/MultiplexingConsumerProcessor.java
(original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/multiplexing/MultiplexingConsumerProcessor.java
Wed Apr  5 05:03:27 2006
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.servicemix.jms;
+package org.apache.servicemix.jms.multiplexing;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -39,6 +39,8 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.servicemix.common.BaseLifeCycle;
+import org.apache.servicemix.jms.AbstractJmsProcessor;
+import org.apache.servicemix.jms.JmsEndpoint;
 import org.apache.servicemix.soap.Context;
 import org.apache.servicemix.soap.SoapFault;
 import org.apache.servicemix.soap.SoapHelper;

Copied: incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/multiplexing/MultiplexingProviderProcessor.java
(from r391398, incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/MultiplexingProviderProcessor.java)
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/multiplexing/MultiplexingProviderProcessor.java?p2=incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/multiplexing/MultiplexingProviderProcessor.java&p1=incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/MultiplexingProviderProcessor.java&r1=391398&r2=391596&rev=391596&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/MultiplexingProviderProcessor.java
(original)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/java/org/apache/servicemix/jms/multiplexing/MultiplexingProviderProcessor.java
Wed Apr  5 05:03:27 2006
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.servicemix.jms;
+package org.apache.servicemix.jms.multiplexing;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -45,6 +45,8 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.servicemix.JbiConstants;
+import org.apache.servicemix.jms.AbstractJmsProcessor;
+import org.apache.servicemix.jms.JmsEndpoint;
 import org.apache.servicemix.soap.marshalers.JBIMarshaler;
 import org.apache.servicemix.soap.marshalers.SoapMarshaler;
 import org.apache.servicemix.soap.marshalers.SoapMessage;

Added: incubator/servicemix/trunk/servicemix-jms/src/main/resources/META-INF/services/org/apache/servicemix/jms/multiplexing
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jms/src/main/resources/META-INF/services/org/apache/servicemix/jms/multiplexing?rev=391596&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-jms/src/main/resources/META-INF/services/org/apache/servicemix/jms/multiplexing
(added)
+++ incubator/servicemix/trunk/servicemix-jms/src/main/resources/META-INF/services/org/apache/servicemix/jms/multiplexing
Wed Apr  5 05:03:27 2006
@@ -0,0 +1,2 @@
+consumer=org.apache.servicemix.jms.multiplexing.MultiplexingConsumerProcessor
+provider=org.apache.servicemix.jms.multiplexing.MultiplexingProviderProcessor
\ No newline at end of file



Mime
View raw message