You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sl...@apache.org on 2007/05/29 10:53:58 UTC

svn commit: r542463 [1/2] - in /incubator/tuscany/java/sca/modules/binding-jms: ./ src/main/java/org/apache/tuscany/sca/ src/main/java/org/apache/tuscany/sca/binding/ src/main/java/org/apache/tuscany/sca/binding/jms/ src/main/resources/META-INF/service...

Author: slaws
Date: Tue May 29 01:53:55 2007
New Revision: 542463

URL: http://svn.apache.org/viewvc?view=rev&rev=542463
Log:
Begin conversion of binding-jms over to the new SPIs

Added:
    incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/
    incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/
    incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/
    incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java   (with props)
    incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingConstants.java   (with props)
    incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingException.java   (with props)
    incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingFactory.java   (with props)
    incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingFactoryImpl.java   (with props)
    incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingImpl.java   (with props)
    incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingInvoker.java   (with props)
    incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingListener.java   (with props)
    incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingModuleActivator.java   (with props)
    incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java   (with props)
    incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProviderFactory.java   (with props)
    incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingReferenceBindingProvider.java   (with props)
    incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingServiceBindingProvider.java   (with props)
    incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSMessageProcessor.java   (with props)
    incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSMessageProcessorImpl.java   (with props)
    incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSResourceFactory.java   (with props)
    incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSResourceFactorySimpleImpl.java   (with props)
    incubator/tuscany/java/sca/modules/binding-jms/src/main/resources/META-INF/services/
    incubator/tuscany/java/sca/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator
    incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/
    incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/
    incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/
    incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java   (with props)
    incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java   (with props)
    incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java   (with props)
    incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSTestCase.java   (with props)
    incubator/tuscany/java/sca/modules/binding-jms/src/test/resources/JMSBindingTest.composite
Modified:
    incubator/tuscany/java/sca/modules/binding-jms/pom.xml

Modified: incubator/tuscany/java/sca/modules/binding-jms/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/pom.xml?view=diff&rev=542463&r1=542462&r2=542463
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-jms/pom.xml (original)
+++ incubator/tuscany/java/sca/modules/binding-jms/pom.xml Tue May 29 01:53:55 2007
@@ -18,16 +18,92 @@
  * under the License.
 -->
 <project>
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.tuscany.sca</groupId>
-        <artifactId>tuscany-modules</artifactId>
-        <version>${version}</version>
-        <relativePath>../pom.xml</relativePath>
-    </parent>
-    <artifactId>tuscany-binding-jms</artifactId>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tuscany.sca</groupId>
+        <artifactId>tuscany-modules</artifactId>
+        <version>1.0-incubating-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <artifactId>tuscany-binding-jms</artifactId>
     <name>Apache Tuscany JMS Binding</name>
 
+    <repositories>
+       <repository>
+          <id>apache.incubator</id>
+          <url>http://people.apache.org/repo/m2-incubating-repository</url>
+       </repository>
+    </repositories>
+
     <dependencies>
+            
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>sca-api</artifactId>
+            <version>1.0-incubating-SNAPSHOT</version>
+        </dependency>        
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-assembly</artifactId>
+            <version>1.0-incubating-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-core-spi</artifactId>
+            <version>1.0-incubating-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-host-embedded</artifactId>
+            <version>1.0-incubating-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-implementation-java-runtime</artifactId>
+            <version>1.0-incubating-SNAPSHOT</version>
+            <scope>runtime</scope>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-interface-java</artifactId>
+            <version>1.0-incubating-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-host-http</artifactId>
+            <version>1.0-incubating-SNAPSHOT</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.activemq</groupId>
+            <artifactId>apache-activemq</artifactId>
+            <version>4.1.1</version>
+        </dependency>  
+
+        <dependency>
+            <groupId>org.apache.ws.commons.axiom</groupId>
+            <artifactId>axiom-api</artifactId>
+            <version>1.2.4</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.ws.commons.axiom</groupId>
+            <artifactId>axiom-impl</artifactId>
+            <version>1.2.4</version>
+        </dependency>              
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.2</version>
+            <scope>test</scope>
+        </dependency>
+
     </dependencies>
 </project>

Added: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java?view=auto&rev=542463
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java (added)
+++ incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java Tue May 29 01:53:55 2007
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.binding.jms;
+
+import org.apache.tuscany.sca.assembly.Binding;
+
+/**
+ * A model for the JMS binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JMSBinding extends Binding {
+    
+    // XML Related operations
+    public void setCorrelationScheme(String correlationScheme);
+    public String getCorrelationScheme();
+    
+    public String getInitialContextFactoryName();
+    public void setInitialContextFactoryName(String initialContextFactoryName);
+    
+    public String getJndiURL();
+    public void setJndiURL(String jndiURL);
+    
+    public String getDestinationName();
+    public void setDestinationName(String destinationName);
+    
+    public int getDestinationType();
+    public void setDestinationType(int destinationType);    
+    
+    public String getDestinationCreate();    
+    public void setDestinationCreate(String create);
+    
+    public String getConnectionFactoryName();
+    public void setConnectionFactoryName(String connectionFactoryName);
+    
+    public String getConnectionFactoryCreate();    
+    public void setConnectionFactoryCreate(String create);
+    
+    public String getActivationSpecName();
+    public void setActivationSpecName(String activationSpecName);  
+    
+    public String getActivationSpecCreate();     
+    public void setActivationSpecCreate(String create); 
+    
+    public String getResponseDestinationName();   
+    public void setResponseDestinationName(String name);    
+    
+    public int getResponseDestinationType(); 
+    public void setResponseDestinationType(int type); 
+    
+    public String getresponseDestinationCreate();   
+    public void setresponseDestinationCreate(String create);  
+    
+    public int getDeliveryMode();
+    public void setDeliveryMode(int deliveryMode);
+    
+    public int getTimeToLive();
+    public void setTimeToLive(int timeToLive);
+    
+    public int getPriority();
+    public void setPriority(int priority);
+    
+    // other operations
+    public String getJmsResourceFactoryName();
+    public void setJmsResourceFactoryName(String jmsResourceFactoryName);
+    public JMSResourceFactory getJmsResourceFactory();     
+    
+    public void setRequestMessageProcessorName(String name);
+    public String getRequestMessageProcessorName();
+    public JMSMessageProcessor getRequestMessageProcessor();    
+
+    public void setResponseMessageProcessorName(String name);
+    public String getResponseMessageProcessorName();
+    public JMSMessageProcessor getResponseMessageProcessor();    
+    
+    public String getOperationSelectorPropertyName();
+    public void setOperationSelectorPropertyName(String operationSelectorPropertyName);
+    
+    public String getOperationSelectorName();
+    public void setOperationSelectorName(String operationSelectorName);
+    
+    public boolean getXMLFormat();
+    public void setXMLFormat(boolean b);     
+}

Propchange: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingConstants.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingConstants.java?view=auto&rev=542463
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingConstants.java (added)
+++ incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingConstants.java Tue May 29 01:53:55 2007
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import java.util.Arrays;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.xml.Constants;
+
+public interface JMSBindingConstants {
+
+    // Contants used when describing the JMS binding
+    // model and for setting up defaults
+    public static final String BINDING_JMS                       = "binding.jms";
+    public static final QName  BINDING_JMS_QNAME                 = new QName(Constants.SCA10_NS, BINDING_JMS);    
+    public final static String CORRELATE_MSG_ID                  = "requestmsgidtocorrelid";
+    public final static String CORRELATE_CORRELATION_ID          = "requestcorrelidtocorrelid";
+    public final static String CORRELATE_NONE                    = "none";
+    public static final List<String> VALID_CORRELATION_SCHEMES   = Arrays.asList(new String[] {CORRELATE_MSG_ID, 
+                                                                                               CORRELATE_CORRELATION_ID, 
+                                                                                               CORRELATE_NONE});    
+    public final static int    DESTINATION_TYPE_QUEUE            = 0;
+    public final static int    DESTINATION_TYPE_TOPIC            = 1;
+    public final static String CREATE_ALLWAYS                    = "allways";
+    public final static String CREATE_NEVER                      = "never";    
+    public final static String DEFAULT_DESTINATION_NAME          = "dynamicQueues/SCARequestQ";
+    public final static String DEFAULT_RESPONSE_DESTINATION_NAME = "dynamicQueues/SCAResponseQ";    
+    public final static String DEFAULT_CONNECTION_FACTORY_NAME   = "ConnectionFactory";    
+    public final static String DEFAULT_CONTEXT_FACTORY_NAME      = "org.apache.activemq.jndi.ActiveMQInitialContextFactory";
+    public final static String DEFAULT_JNDI_URL                  = "tcp://localhost:61616";
+    public final static int    DEFAULT_TIME_TO_LIVE              = 10000; // in milli seconds
+    public final static int    DEFAULT_PRIORITY                  = 1; 
+    public static final String DEFAULT_RF_CLASSNAME              = JMSResourceFactorySimpleImpl.class.getName();    
+    public static final String DEFAULT_MP_CLASSNAME              = JMSMessageProcessorImpl.class.getName();
+    public static final String DEFAULT_OPERATION_PROP_NAME       = "scaOperationName";
+
+}

Propchange: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingConstants.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingException.java?view=auto&rev=542463
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingException.java (added)
+++ incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingException.java Tue May 29 01:53:55 2007
@@ -0,0 +1,38 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+public class JMSBindingException extends RuntimeException {
+    private static final long serialVersionUID = 1L;
+
+    public JMSBindingException() {
+        super();
+    }
+
+    public JMSBindingException(String arg0, Throwable arg1) {
+        super(arg0, arg1);
+    }
+
+    public JMSBindingException(String arg0) {
+        super(arg0);
+    }
+
+    public JMSBindingException(Throwable arg0) {
+        super(arg0);
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingException.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingFactory.java?view=auto&rev=542463
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingFactory.java (added)
+++ incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingFactory.java Tue May 29 01:53:55 2007
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.binding.jms;
+
+/**
+ * A factory for the JSONRPC binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JMSBindingFactory {
+    
+    /**
+     * Creates a new JSONRPC binding.
+     * 
+     * @return a new JSONRPC binding
+     */
+    JMSBinding createJMSBinding();
+}

Propchange: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingFactory.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingFactoryImpl.java?view=auto&rev=542463
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingFactoryImpl.java (added)
+++ incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingFactoryImpl.java Tue May 29 01:53:55 2007
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+
+/**
+ * A factory for the JMS Binding model.
+ * 
+ * @version $Rev$ $Date$
+ */
+public class JMSBindingFactoryImpl implements JMSBindingFactory {
+    
+    public JMSBindingFactoryImpl() {
+    }
+    
+    public JMSBinding createJMSBinding() {
+        return new JMSBindingImpl();
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingFactoryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingFactoryImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingImpl.java?view=auto&rev=542463
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingImpl.java (added)
+++ incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingImpl.java Tue May 29 01:53:55 2007
@@ -0,0 +1,435 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jms.DeliveryMode;
+
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+
+/**
+ * Models a binding to a JMS resource.
+ */
+
+public class JMSBindingImpl implements JMSBinding {
+    
+    // properties required to implement the Tuscany 
+    // binding extension SPI
+    private String uri                   = null;
+    private String name                  = null;
+    private boolean unresolved           = false;    
+    private List<PolicySet> policySets   = new ArrayList<PolicySet>();
+    private List<Intent> requiredIntents = new ArrayList<Intent>();  
+    private List<Object> extensions      = new ArrayList<Object>();    
+    
+
+    
+    // Properties required to describe the JMS 
+    // binding model
+    
+    // <binding.jms correlationScheme="string"?
+    //              initialContextFactory="xs:anyURI"?
+    //              jndiURL="xs:anyURI"?
+    //              requestConnection="QName"?
+    //              responseConnection="QName"?
+    //              operationProperties="QName"?
+    //              ...>
+    private String correlationScheme         = JMSBindingConstants.CORRELATE_MSG_ID;    
+    private String initialContextFactoryName = JMSBindingConstants.DEFAULT_CONTEXT_FACTORY_NAME;
+    private String jndiURL                   = JMSBindingConstants.DEFAULT_JNDI_URL;  
+    // 
+    //     <destination name="xs:anyURI" type="string"? create="string"?>
+    //         <property name="NMTOKEN" type="NMTOKEN">*
+    //     </destination>?
+    private String destinationName           = JMSBindingConstants.DEFAULT_DESTINATION_NAME; 
+    private int    destinationType           = JMSBindingConstants.DESTINATION_TYPE_QUEUE;    
+    private String destinationCreate         = JMSBindingConstants.CREATE_ALLWAYS; 
+    // 
+    //     <connectionFactory name="xs:anyURI" create="string"?>
+    //         <property name="NMTOKEN" type="NMTOKEN">*
+    //     </connectionFactory>?
+    private String connectionFactoryName     = JMSBindingConstants.DEFAULT_CONNECTION_FACTORY_NAME;
+    private String connectionFactoryCreate   = JMSBindingConstants.CREATE_ALLWAYS;    
+    // 
+    //     <activationSpec name="xs:anyURI" create="string"?>
+    //         <property name="NMTOKEN" type="NMTOKEN">*
+    //     </activationSpec>?
+    private String activationSpecName        = null;
+    private String activationSpecCreate      = null;
+    // 
+    //     <response>
+    //         <destination name="xs:anyURI" type="string"? create="string"?>
+    //             <property name="NMTOKEN" type="NMTOKEN">*
+    //         </destination>?
+    private String responseDestinationName   = JMSBindingConstants.DEFAULT_RESPONSE_DESTINATION_NAME; 
+    private int    responseDestinationType   = JMSBindingConstants.DESTINATION_TYPE_QUEUE;    
+    private String responseDestinationCreate = JMSBindingConstants.CREATE_ALLWAYS;    
+    // 
+    //         <connectionFactory name="xs:anyURI" create="string"?>
+    //             <property name="NMTOKEN" type="NMTOKEN">*
+    //         </connectionFactory>?
+    private String responseConnectionFactoryName     = JMSBindingConstants.DEFAULT_CONNECTION_FACTORY_NAME;
+    private String responseConnectionFactoryCreate   = JMSBindingConstants.CREATE_ALLWAYS;    
+    // 
+    //         <activationSpec name="xs:anyURI" create="string"?>
+    //             <property name="NMTOKEN" type="NMTOKEN">*
+    //         </activationSpec>?
+    private String responseActivationSpecName        = null;
+    private String responseActivationSpecCreate      = null;    
+    //     </response>?
+    // 
+    //     <resourceAdapter name="NMTOKEN">?
+    //         <property name="NMTOKEN" type="NMTOKEN">*
+    //     </resourceAdapter>?
+    // 
+    //     <headers JMSType="string"?
+    //              JMSCorrelationId="string"?
+    //              JMSDeliveryMode="string"?
+    //              JMSTimeToLive="int"?
+    //              JMSPriority="string"?>
+    //         <property name="NMTOKEN" type="NMTOKEN">*
+    //     </headers>?
+    private int deliveryMode                 = DeliveryMode.NON_PERSISTENT; // Maps to javax.jms.DeliveryMode
+    private int timeToLive                   = JMSBindingConstants.DEFAULT_TIME_TO_LIVE;
+    private int priority                     = JMSBindingConstants.DEFAULT_PRIORITY;    
+    // 
+    //     <operationProperties name="string" nativeOperation="string"?>
+    //         <property name="NMTOKEN" type="NMTOKEN">*
+    //         <headers JMSType="string"?
+    //                  JMSCorrelationId="string"?
+    //                  JMSDeliveryMode="string"?
+    //                  JMSTimeToLive="int"?
+    //                  JMSPriority="string"?>
+    //             <property name="NMTOKEN" type="NMTOKEN">*
+    //         </headers>?
+    //     </operationProperties>*
+    // </binding.jms>
+
+    // Other properties not directly related to the
+    // XML definition of the JMS binding
+    
+    
+    // Provides the name of the factory that interfaces to the 
+    // JMS API for us. 
+    private String jmsResourceFactoryName                  = JMSBindingConstants.DEFAULT_RF_CLASSNAME;
+    
+    // Message processors used to deal with the request
+    // and response messages
+    public String requestMessageProcessorName              = JMSBindingConstants.DEFAULT_MP_CLASSNAME;
+    public String responseMessageProcessorName             = JMSBindingConstants.DEFAULT_MP_CLASSNAME;
+    
+    // The JMS message property used to hold the name of the 
+    // operation being called
+    private String operationSelectorPropertyName           = JMSBindingConstants.DEFAULT_OPERATION_PROP_NAME;
+    
+    // If the operation selector is derived automatically from the service
+    // interface it's stored here
+    private String operationSelectorName                   = null;
+    
+    // Set true if messages are sent/received in XML format
+    private boolean xmlFormat                              = false;    
+    
+    
+//TODO .....  
+    private String replyTo;
+
+
+    // Methods required by the Tuscany SPI
+
+    /**
+     * No arg constructor used by the JSMBindingFactoryImpl
+     * to create JMS binding model objects
+     *
+     */
+    public JMSBindingImpl() {
+        super();
+    }
+    
+    /**
+     * Returns the binding URI.
+     * 
+     * @return the binding uri
+     */
+    public String getURI() {
+        return this.uri;
+    }
+
+    /**
+     * Sets the binding URI.
+     * 
+     * @param uri the binding uri
+     */
+    public void setURI(String uri) {
+        this.uri = uri;
+    }
+
+    /**
+     * Returns the binding name.
+     * 
+     * @return the binding name
+     */
+    public String getName() {
+        return this.name;
+    }
+
+    /**
+     * Sets the binding name.
+     * 
+     * @param name the binding name
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+    
+    public List<Intent> getRequiredIntents() {
+        return requiredIntents;
+    }
+
+    public boolean isUnresolved() {
+        return this.unresolved;
+    }
+    
+    public void setUnresolved(boolean unresolved) {
+        this.unresolved = unresolved;
+    }  
+
+    public List<PolicySet> getPolicySets() {
+        return policySets;
+    }
+         
+    public List<Object> getExtensions() {
+        return extensions;
+    }    
+    
+    // Methods for getting/setting JMS binding model information  
+    // as derived from the XML of the binding.jms element
+    
+    public void setCorrelationScheme(String correlationScheme) {
+        this.correlationScheme = correlationScheme;
+    }
+    public String getCorrelationScheme() {
+        return correlationScheme;
+    }
+    
+    public String getInitialContextFactoryName() {
+        return initialContextFactoryName;
+    }
+    public void setInitialContextFactoryName(String initialContextFactoryName) {
+        this.initialContextFactoryName = initialContextFactoryName;
+    } 
+    
+    public String getJndiURL() {
+        return this.jndiURL;
+    }
+    public void setJndiURL(String jndiURL) {
+        this.jndiURL = jndiURL;
+    }
+
+    public String getDestinationName() {
+        return destinationName;
+    }
+    public void setDestinationName(String destinationName) {
+        this.destinationName = destinationName;
+    }
+    
+    public int getDestinationType() {
+        return destinationType;
+    }
+    public void setDestinationType(int destinationType) {
+        this.destinationType = destinationType;
+    }    
+    
+    public String getDestinationCreate() {
+        return this.destinationCreate;
+    }     
+    public void setDestinationCreate(String create) {
+        this.destinationCreate = create;
+    }    
+    
+    public String getConnectionFactoryName() {
+        return connectionFactoryName;
+    }
+    public void setConnectionFactoryName(String connectionFactoryName) {
+        this.connectionFactoryName = connectionFactoryName;
+    } 
+    
+    public String getConnectionFactoryCreate() {
+        return this.connectionFactoryCreate;
+    }     
+    public void setConnectionFactoryCreate(String create) {
+        this.connectionFactoryCreate = create;
+    }
+    
+    public String getActivationSpecName() {
+        return activationSpecName;
+    }
+    public void setActivationSpecName(String activationSpecName) {
+        this.activationSpecName = activationSpecName;
+    }  
+    
+    public String getActivationSpecCreate() {
+        return this.activationSpecCreate;
+    }     
+    public void setActivationSpecCreate(String create) {
+        this.activationSpecCreate = create;
+    }  
+    
+    public String getResponseDestinationName() {
+        return this.responseDestinationName;
+    }     
+    public void setResponseDestinationName(String name) {
+        this.responseDestinationName = name;
+    }     
+    
+    public int getResponseDestinationType() {
+        return this.responseDestinationType;
+    }     
+    public void setResponseDestinationType(int type) {
+        this.responseDestinationType = type;
+    }     
+    
+    public String getresponseDestinationCreate() {
+        return this.responseDestinationCreate;
+    }     
+    public void setresponseDestinationCreate(String create) {
+        this.responseDestinationCreate = create;
+    }      
+    
+    public int getDeliveryMode() {
+        return deliveryMode;
+    }
+    public void setDeliveryMode(int deliveryMode) {
+        this.deliveryMode = deliveryMode;
+    } 
+    
+    public int getTimeToLive() {
+        return timeToLive;
+    }
+    public void setTimeToLive(int timeToLive) {
+        this.timeToLive = timeToLive;
+    } 
+    
+    public int getPriority() {
+        return priority;
+    }
+    public void setPriority(int priority) {
+        this.priority = priority;
+    }    
+    
+    // operations to manage the other information required by the 
+    // JMS binding
+    
+    public String getJmsResourceFactoryName() {
+        return jmsResourceFactoryName;
+    }
+    public void setJmsResourceFactoryName(String jmsResourceFactoryName) {
+        this.jmsResourceFactoryName = jmsResourceFactoryName;
+    }    
+    public JMSResourceFactory getJmsResourceFactory() {
+        return (JMSResourceFactory)instantiate(null,jmsResourceFactoryName);
+    }    
+    
+    public void setRequestMessageProcessorName(String name) {
+        this.requestMessageProcessorName = name;
+    }
+    public String getRequestMessageProcessorName() {
+        return requestMessageProcessorName;
+    }
+    public JMSMessageProcessor getRequestMessageProcessor() {
+        return (JMSMessageProcessor)instantiate(null,requestMessageProcessorName);
+    }    
+    
+    public void setResponseMessageProcessorName(String name) {
+        this.responseMessageProcessorName = name;
+    }
+    public String getResponseMessageProcessorName() {
+        return responseMessageProcessorName;
+    }    
+    public JMSMessageProcessor getResponseMessageProcessor() {
+        return (JMSMessageProcessor)instantiate(null,requestMessageProcessorName);
+    }    
+    
+    public String getOperationSelectorPropertyName() {
+        return operationSelectorPropertyName;
+    }
+    public void setOperationSelectorPropertyName(String operationSelectorPropertyName) {
+        this.operationSelectorPropertyName = operationSelectorPropertyName;
+    }   
+    
+    public String getOperationSelectorName() {
+        return operationSelectorName;
+    }
+    public void setOperationSelectorName(String operationSelectorName) {
+        this.operationSelectorName = operationSelectorName;
+    }    
+    
+    public boolean getXMLFormat() {
+        return xmlFormat;
+    }
+    public void setXMLFormat(boolean b) {
+        this.xmlFormat = b;
+    }  
+    
+    protected Object instantiate(ClassLoader cl, String className) {
+        Object instance;
+        if (cl == null) {
+            cl = this.getClass().getClassLoader();
+        }
+
+        try {
+            Class clazz;
+            
+            try {
+                clazz = cl.loadClass(className);
+            } catch (ClassNotFoundException e) {
+                clazz = this.getClass().getClassLoader().loadClass(className);
+            }
+            
+            Constructor constructor = clazz.getDeclaredConstructor(new Class[]{JMSBinding.class});
+            instance = constructor.newInstance(this);
+
+        } catch (Throwable e) {
+            throw new JMSBindingException("Exception instantiating OperationAndDataBinding class", e);
+        }
+        
+        return instance;
+    }    
+    
+    
+// TODO...    
+
+
+    public String getReplyTo() {
+        return replyTo;
+    }
+
+    public void setReplyTo(String replyTo) {
+        this.replyTo = replyTo;
+    }
+
+    
+
+    
+}

Propchange: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingInvoker.java?view=auto&rev=542463
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingInvoker.java (added)
+++ incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingInvoker.java Tue May 29 01:53:55 2007
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+
+/**
+ * Interceptor for the JMS binding.
+ * 
+ * @version $Rev$ $Date$
+ */
+public class JMSBindingInvoker implements Invoker {
+
+    protected Operation           operation;
+    protected String              operationName; 
+    
+    protected JMSBinding          jmsBinding;
+    protected JMSResourceFactory  jmsResourceFactory;
+    protected JMSMessageProcessor requestMessageProcessor;
+    protected JMSMessageProcessor responseMessageProcessor;
+    protected Destination         requestDest;
+    protected Destination         replyDest;
+
+    public JMSBindingInvoker(JMSBinding jmsBinding,
+                             Operation  operation ) {
+        
+        this.operation           = operation;
+        operationName            = operation.getName();
+        
+        this.jmsBinding          = jmsBinding;
+        jmsResourceFactory       = jmsBinding.getJmsResourceFactory();
+        requestMessageProcessor  = jmsBinding.getRequestMessageProcessor();
+        responseMessageProcessor = jmsBinding.getResponseMessageProcessor();
+        try {
+            requestDest          = jmsResourceFactory.lookupDestination(jmsBinding.getDestinationName());
+            replyDest            = jmsResourceFactory.lookupDestination(jmsBinding.getResponseDestinationName());          
+        } catch (NamingException e) {
+            throw new JMSBindingException(e);
+        }            
+
+    }
+
+    public org.apache.tuscany.sca.invocation.Message invoke(org.apache.tuscany.sca.invocation.Message msg) {
+        try {
+            Object resp = invokeTarget((Object[])msg.getBody(), (short)0);
+            msg.setBody(resp);
+        } catch (InvocationTargetException e) {
+            msg.setFaultBody(e.getCause());
+        } catch (Throwable e) {
+            msg.setFaultBody(e);
+        }
+        return msg;
+    }
+    
+    public Object invokeTarget(Object payload, final short sequence) throws InvocationTargetException {
+        try {
+            Session session = jmsResourceFactory.createSession();
+            try {
+
+                Destination replyToDest = (replyDest != null) ? replyDest : session.createTemporaryQueue();
+                
+                Message requestMsg = sendRequest((Object[])payload, session, replyToDest);
+                Message replyMsg = receiveReply(session, replyToDest, requestMsg.getJMSMessageID());
+
+                return responseMessageProcessor.extractPayloadFromJMSMessage(replyMsg);
+
+            } finally {
+                session.close();
+            }
+        } catch (JMSException e) {
+            throw new InvocationTargetException(e);
+        } catch (NamingException e) {
+            throw new InvocationTargetException(e);
+        }
+    }
+
+    protected Message sendRequest(Object[] payload, Session session, Destination replyToDest) throws JMSException {
+
+        Message requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, payload);
+
+        requestMsg.setJMSDeliveryMode(jmsBinding.getDeliveryMode());
+        requestMsg.setJMSPriority(jmsBinding.getPriority());
+
+        requestMessageProcessor.setOperationName(operationName, requestMsg);
+        requestMsg.setJMSReplyTo(replyToDest);
+
+        MessageProducer producer = session.createProducer(requestDest);
+        try {
+            producer.send(requestMsg);
+        } finally {
+            producer.close();
+        }
+        return requestMsg;
+    }
+
+    protected Message receiveReply(Session session, Destination replyToDest, String requestMsgId) throws JMSException,
+        NamingException {
+        String msgSelector = "JMSCorrelationID = '" + requestMsgId + "'";
+        MessageConsumer consumer = session.createConsumer(replyToDest, msgSelector);
+        Message replyMsg;
+        try {
+            jmsResourceFactory.startConnection();
+            replyMsg = consumer.receive(jmsBinding.getTimeToLive());
+        } finally {
+            consumer.close();
+        }
+        return replyMsg;
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingInvoker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingInvoker.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingListener.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingListener.java?view=auto&rev=542463
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingListener.java (added)
+++ incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingListener.java Tue May 29 01:53:55 2007
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.naming.NamingException;
+
+import org.apache.tuscany.sca.core.invocation.MessageFactoryImpl;
+import org.apache.tuscany.sca.core.invocation.ThreadMessageContext;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+public class JMSBindingListener implements MessageListener {
+
+   
+    private JMSBinding              jmsBinding;
+    private JMSResourceFactory      jmsResourceFactory;
+    private RuntimeComponentService service;
+    private JMSMessageProcessor     requestMessageProcessor;
+    private JMSMessageProcessor     responseMessageProcessor;
+    private String                  correlationScheme;
+    private MessageFactory          messageFactory;
+    private Method                  operationMethod;    
+
+    public JMSBindingListener(JMSBinding              jmsBinding,
+                              JMSResourceFactory      jmsResourceFactory,
+                              RuntimeComponentService service) 
+      throws NamingException {
+        this.jmsBinding          = jmsBinding;
+        this.jmsResourceFactory  = jmsResourceFactory;
+        this.service             = service;
+        requestMessageProcessor  = jmsBinding.getRequestMessageProcessor();
+        responseMessageProcessor = jmsBinding.getResponseMessageProcessor();
+        correlationScheme        = jmsBinding.getCorrelationScheme();
+        messageFactory           = new MessageFactoryImpl();
+    }
+
+    public void onMessage(Message requestJMSMsg) {
+        try {
+            Object responsePayload = invokeService(requestJMSMsg);
+            sendReply(requestJMSMsg, responsePayload);
+        } catch (Exception e) {
+            sendFaultReply(requestJMSMsg, e);
+        }
+    }
+
+    /** 
+     * Turn the JMS message back into a Tuscany message and invoke the
+     * target component
+     * 
+     * @param requestJMSMsg
+     * @return
+     * @throws JMSException
+     * @throws InvocationTargetException
+     */
+    protected Object invokeService(Message requestJMSMsg) 
+      throws JMSException, InvocationTargetException {
+
+        String operationName = requestMessageProcessor.getOperationName(requestJMSMsg);
+        Object requestPayload = requestMessageProcessor.extractPayloadFromJMSMessage(requestJMSMsg);
+
+        org.apache.tuscany.sca.invocation.Message requestMsg = messageFactory.createMessage();
+
+        requestMsg.setBody(requestPayload);
+
+        org.apache.tuscany.sca.invocation.Message workContext = ThreadMessageContext.getMessageContext();
+        ThreadMessageContext.setMessageContext(requestMsg);
+        
+        try {
+            /* TODO - work out how to do this bit 
+             
+            if (isConversational() && conversationID != null) {
+                    requestMsg.setConversationID(conversationID);
+            } else {
+                    requestMsg.setConversationID(null);
+            }
+            */
+            // get the operation object
+            List<Operation> opList = service.getInterfaceContract().getInterface().getOperations();
+            
+            Operation operation = null;
+            
+            for(Operation op : opList){
+                if ( op.getName().equals(operationName)) {
+                    operation = op;
+                    break;
+                }
+            }
+            
+            if ( operation != null ){
+            
+                // get the component invoker
+                Invoker invoker = service.getInvoker(jmsBinding, operation);
+    
+                org.apache.tuscany.sca.invocation.Message responseMsg = invoker.invoke(requestMsg);
+
+                if (responseMsg.isFault()) {
+                    throw new InvocationTargetException((Throwable)responseMsg.getBody());
+                }
+                return responseMsg.getBody();
+            } else {
+                throw new JMSBindingException("Can't find operation " + operationName );
+            }
+
+        } finally {
+            ThreadMessageContext.setMessageContext(workContext);
+        }   
+    }
+
+    protected void sendReply(Message requestJMSMsg, Object responsePayload) {
+        try {
+
+            if (requestJMSMsg.getJMSReplyTo() == null) {
+                // assume no reply is expected
+                return;
+            }
+
+            Session session = jmsResourceFactory.createSession();
+            Message replyJMSMsg = responseMessageProcessor.insertPayloadIntoJMSMessage(session, responsePayload);
+
+            replyJMSMsg.setJMSDeliveryMode(requestJMSMsg.getJMSDeliveryMode());
+            replyJMSMsg.setJMSPriority(requestJMSMsg.getJMSPriority());
+
+            if (correlationScheme == null || 
+                JMSBindingConstants.CORRELATE_MSG_ID.equalsIgnoreCase(correlationScheme)) {
+                replyJMSMsg.setJMSCorrelationID(requestJMSMsg.getJMSMessageID());
+            } else if (JMSBindingConstants.CORRELATE_CORRELATION_ID.equalsIgnoreCase(correlationScheme)) {
+                replyJMSMsg.setJMSCorrelationID(requestJMSMsg.getJMSCorrelationID());
+            }
+
+            Destination destination = requestJMSMsg.getJMSReplyTo();
+            MessageProducer producer = session.createProducer(destination);
+
+            producer.send(replyJMSMsg);
+
+            producer.close();
+            session.close();
+
+        } catch (JMSException e) {
+            throw new JMSBindingException(e);
+        } catch (NamingException e) {
+            throw new JMSBindingException(e);
+        }
+    }
+
+    protected void sendFaultReply(Message requestJMSMsg, Exception e) {
+        sendReply(requestJMSMsg, new JMSBindingException("exception invoking JMS service", e));
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingListener.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingModuleActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingModuleActivator.java?view=auto&rev=542463
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingModuleActivator.java (added)
+++ incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingModuleActivator.java Tue May 29 01:53:55 2007
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.binding.jms;
+
+/*
+import org.apache.tuscany.sca.binding.jsonrpc.DefaultJSONRPCBindingFactory;
+import org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBindingFactory;
+import org.apache.tuscany.sca.binding.jsonrpc.impl.JSONRPCBindingProcessor;
+import org.apache.tuscany.sca.binding.jsonrpc.provider.JSONRPCBindingProviderFactory;
+*/
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ModuleActivator;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
+
+/**
+ * A module activator for the JMS binding extension.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JMSBindingModuleActivator implements ModuleActivator {
+    
+    public Object[] getExtensionPoints() {
+        // No extensionPoints being contributed here
+        return null;
+    }
+
+    public void start(ExtensionPointRegistry registry) {
+        // Create the JMS model factory
+        JMSBindingFactory bindingFactory = new JMSBindingFactoryImpl();
+
+        // Add the JMSBindingProcessor extension
+        AssemblyFactory assemblyFactory = registry.getExtensionPoint(AssemblyFactory.class); 
+        PolicyFactory policyFactory = registry.getExtensionPoint(PolicyFactory.class);
+        JMSBindingProcessor bindingProcessor = new JMSBindingProcessor(assemblyFactory,
+                                                                          policyFactory,
+                                                                          bindingFactory);
+        
+        StAXArtifactProcessorExtensionPoint processors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+        processors.addArtifactProcessor(bindingProcessor);       
+ 
+        // Add the JMSBindingProviderFactory extension
+        JMSBindingProviderFactory providerFactory = new JMSBindingProviderFactory();
+        
+        ProviderFactoryExtensionPoint providerFactories = registry.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+        providerFactories.addProviderFactory(providerFactory);
+    }
+
+    public void stop(ExtensionPointRegistry registry) {        
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingModuleActivator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingModuleActivator.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java?view=auto&rev=542463
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java Tue May 29 01:53:55 2007
@@ -0,0 +1,358 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.binding.jms;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.binding.jms.JMSBindingDefinition;
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+
+/**
+ * A processor to read the XML that describes the JMS binding...
+ * 
+ * <binding.jms correlationScheme="string"?
+ *              initialContextFactory="xs:anyURI"?
+ *              jndiURL="xs:anyURI"?
+ *              requestConnection="QName"?
+ *              responseConnection="QName"?
+ *              operationProperties="QName"?
+ *              ...>
+ * 
+ *     <destination name="xs:anyURI" type="string"? create="string"?>
+ *         <property name="NMTOKEN" type="NMTOKEN">*
+ *     </destination>?
+ * 
+ *     <connectionFactory name="xs:anyURI" create="string"?>
+ *         <property name="NMTOKEN" type="NMTOKEN">*
+ *     </connectionFactory>?
+ * 
+ *     <activationSpec name="xs:anyURI" create="string"?>
+ *         <property name="NMTOKEN" type="NMTOKEN">*
+ *     </activationSpec>?
+ * 
+ *     <response>
+ *         <destination name="xs:anyURI" type="string"? create="string"?>
+ *             <property name="NMTOKEN" type="NMTOKEN">*
+ *         </destination>?
+ * 
+ *         <connectionFactory name="xs:anyURI" create="string"?>
+ *             <property name="NMTOKEN" type="NMTOKEN">*
+ *         </connectionFactory>?
+ * 
+ *         <activationSpec name="xs:anyURI" create="string"?>
+ *             <property name="NMTOKEN" type="NMTOKEN">*
+ *         </activationSpec>?
+ *     </response>?
+ * 
+ *     <resourceAdapter name="NMTOKEN">?
+ *         <property name="NMTOKEN" type="NMTOKEN">*
+ *     </resourceAdapter>?
+ * 
+ *     <headers JMSType="string"?
+ *              JMSCorrelationId="string"?
+ *              JMSDeliveryMode="string"?
+ *              JMSTimeToLive="int"?
+ *              JMSPriority="string"?>
+ *         <property name="NMTOKEN" type="NMTOKEN">*
+ *     </headers>?
+ * 
+ *     <operationProperties name="string" nativeOperation="string"?>
+ *         <property name="NMTOKEN" type="NMTOKEN">*
+ *         <headers JMSType="string"?
+ *                  JMSCorrelationId="string"?
+ *                  JMSDeliveryMode="string"?
+ *                  JMSTimeToLive="int"?
+ *                  JMSPriority="string"?>
+ *             <property name="NMTOKEN" type="NMTOKEN">*
+ *         </headers>?
+ *     </operationProperties>*
+ * </binding.jms>
+ */
+
+public class JMSBindingProcessor implements StAXArtifactProcessor<JMSBinding>{
+    
+    private AssemblyFactory assemblyFactory;
+    private PolicyFactory policyFactory;    
+    private JMSBindingFactory jmsBindingFactory;
+
+
+    public JMSBindingProcessor(AssemblyFactory assemblyFactory,
+                               PolicyFactory policyFactory,
+                               JMSBindingFactory jmsBindingFactory) {
+        this.assemblyFactory = assemblyFactory;
+        this.policyFactory = policyFactory;
+        this.jmsBindingFactory = jmsBindingFactory;
+    }
+
+    public QName getArtifactType() {
+        return JMSBindingConstants.BINDING_JMS_QNAME;
+    }
+
+    public Class<JMSBinding> getModelType() {
+        return JMSBinding.class;
+    }
+
+    public JMSBinding read(XMLStreamReader reader) 
+      throws ContributionReadException {
+        try {
+            JMSBinding jmsBinding = jmsBindingFactory.createJMSBinding();
+            
+            //Read policies
+            readPolicies(jmsBinding, reader);
+
+            // Read binding URI
+            String uri = reader.getAttributeValue(null, "uri");
+            if (uri != null && uri.length() > 0) {
+                jmsBinding.setURI(uri);
+            }
+
+            // Read correlation scheme
+            String correlationScheme = reader.getAttributeValue(null, "correlationScheme");
+            if (correlationScheme != null && correlationScheme.length() > 0) {
+                if (JMSBindingConstants.VALID_CORRELATION_SCHEMES.contains(correlationScheme.toLowerCase())) {
+                    jmsBinding.setCorrelationScheme(correlationScheme);
+                } else {
+                    throw new JMSBindingException("invalid correlationScheme: " + correlationScheme);
+                }
+            }
+
+            // Read initial context factory
+            String initialContextFactory = reader.getAttributeValue(null, "initialContextFactory");
+            if (initialContextFactory != null && initialContextFactory.length() > 0) {
+                jmsBinding.setInitialContextFactoryName(initialContextFactory);
+            }
+
+            // Read jndi URL
+            String jndiURL = reader.getAttributeValue(null, "jndiURL");
+            if (jndiURL != null && jndiURL.length() > 0) {
+                jmsBinding.setJndiURL(jndiURL);
+            }
+            
+            // Read requestConnection
+            // TODO
+            // Read reponseConnection
+            // TODO
+            // Read operationProperties
+            // TODO
+            
+            // Read subelements of binding.jms
+            while (true) {
+                switch (reader.next()) {
+                    case START_ELEMENT:
+                        String elementName = reader.getName().getLocalPart();
+                        if ("destination".equals(elementName)) {
+                            parseDestination(reader, jmsBinding);
+                        } else if ("connectionFactory".equals(elementName)) {
+                            parseConnectionFactory(reader, jmsBinding);
+                        } else if ("activationSpec".equals(elementName)) {
+                            parseActivationSpec(reader, jmsBinding);
+                        } else if ("response".equals(elementName)) {
+                            parseResponse(reader, jmsBinding);
+                        } else if ("resourceAdapter".equals(elementName)) {
+                            parseResourceAdapter(reader, jmsBinding);                            
+                        } else if ("headers".equals(elementName)) {
+                            parseHeaders(reader, jmsBinding);
+                        } else if ("operationProperties".equals(elementName)) {
+                            parseOperationProperties(reader, jmsBinding);
+                        } 
+                        reader.next();
+                        break;
+                    case END_ELEMENT:
+                        QName x = reader.getName();
+                        if (x.equals(JMSBindingConstants.BINDING_JMS_QNAME)) {
+                            return jmsBinding;
+                        }
+                        throw new RuntimeException("Incomplete binding.jms definition found unexpected element " + x.toString());
+                }
+            }
+ /*           
+            // Skip to end element
+            while (reader.hasNext()) {
+                if (reader.next() == END_ELEMENT && 
+                    BINDING_JMS_QNAME.equals(reader.getName())) {
+                    break;
+                }
+            }
+            return jmsBinding;
+*/
+        } catch (XMLStreamException e) {
+            throw new ContributionReadException(e);
+        }
+    }
+    
+    public void resolve(JMSBinding model, ModelResolver resolver) throws ContributionResolveException {
+    }    
+
+    public void write(JMSBinding rmiBinding, XMLStreamWriter writer) throws ContributionWriteException {
+        try {
+            // Write a <binding.ws>
+            writer.writeStartElement(Constants.SCA10_NS, JMSBindingConstants.BINDING_JMS);
+/*            
+            if (rmiBinding.getRmiHostName() != null) {
+                writer.writeAttribute(RMIBindingConstants.RMI_HOST, rmiBinding.getRmiHostName());
+            }
+            
+            if (rmiBinding.getRmiPort() != null) {
+                writer.writeAttribute(RMIBindingConstants.RMI_PORT, rmiBinding.getRmiPort());
+            }
+            
+            if (rmiBinding.getRmiServiceName() != null) {
+                writer.writeAttribute(RMIBindingConstants.RMI_SERVICE, rmiBinding.getRmiServiceName());
+            }
+*/            
+            writer.writeEndElement();
+
+        } catch (XMLStreamException e) {
+            throw new ContributionWriteException(e);
+        }
+    }
+
+
+    /**
+     * Reads policy intents and policy sets.
+     * @param attachPoint where the intents and policy sets will be stored
+     * @param reader the XML stream reader
+     */
+    private void readPolicies(PolicySetAttachPoint attachPoint, XMLStreamReader reader) {
+        String value = reader.getAttributeValue(null, Constants.REQUIRES);
+        if (value != null) {
+            List<Intent> requiredIntents = attachPoint.getRequiredIntents();
+            for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+                QName qname = getQNameValue(reader, tokens.nextToken());
+                Intent intent = policyFactory.createIntent();
+                intent.setName(qname);
+                requiredIntents.add(intent);
+            }
+        }
+
+        value = reader.getAttributeValue(null, Constants.POLICY_SETS);
+        if (value != null) {
+            List<PolicySet> policySets = attachPoint.getPolicySets();
+            for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+                QName qname = getQNameValue(reader, tokens.nextToken());
+                PolicySet policySet = policyFactory.createPolicySet();
+                policySet.setName(qname);
+                policySets.add(policySet);
+            }
+        }
+    }
+    
+    /**
+     * Returns a qname from a string.  
+     * @param reader the XML stream reader
+     * @param value the string version of the QName
+     * @return
+     */
+    private QName getQNameValue(XMLStreamReader reader, String value) {
+        if (value != null) {
+            int index = value.indexOf(':');
+            String prefix = index == -1 ? "" : value.substring(0, index);
+            String localName = index == -1 ? value : value.substring(index + 1);
+            String ns = reader.getNamespaceContext().getNamespaceURI(prefix);
+            if (ns == null) {
+                ns = "";
+            }
+            return new QName(ns, localName, prefix);
+        } else {
+            return null;
+        }
+    } 
+    
+    protected void parseDestination(XMLStreamReader reader, JMSBinding jmsBinding) throws XMLStreamException {
+        String name = reader.getAttributeValue(null, "name");
+        if (name != null && name.length() > 0) {
+            jmsBinding.setDestinationName(name);
+        }
+        String type = reader.getAttributeValue(null, "type");
+        if (type != null && type.length() > 0) {
+            if ("queue".equalsIgnoreCase(type)) {
+                jmsBinding.setDestinationType(JMSBindingDefinition.DESTINATION_TYPE_QUEUE);
+            } else if ("topic".equalsIgnoreCase("type")) {
+                jmsBinding.setDestinationType(JMSBindingDefinition.DESTINATION_TYPE_TOPIC);
+            } else {
+                throw new RuntimeException("invalid destination type: " + type);
+            }
+        }
+        String create = reader.getAttributeValue(null, "create");
+        if (create != null && create.length() > 0) {
+            jmsBinding.setDestinationCreate(create);
+        }
+    } 
+    
+    protected void parseConnectionFactory(XMLStreamReader reader, JMSBinding jmsBinding) {
+        String name = reader.getAttributeValue(null, "name");
+        if (name != null && name.length() > 0) {
+            jmsBinding.setConnectionFactoryName(name);
+        } else {
+            throw new RuntimeException("missing connectionFactory name");
+        }
+    }    
+
+    protected void parseActivationSpec(XMLStreamReader reader, JMSBinding jmsBinding) {
+        String name = reader.getAttributeValue(null, "name");
+        if (name != null && name.length() > 0) {
+            jmsBinding.setActivationSpecName(name);
+        } else {
+            throw new RuntimeException("missing ActivationSpec name");
+        }
+    }
+
+    protected void parseResponse(XMLStreamReader reader, JMSBinding jmsBinding) {
+        // TODO 
+    }
+
+    protected void parseResourceAdapter(XMLStreamReader reader, JMSBinding jmsBinding) throws XMLStreamException {
+        // TODO 
+    }
+    
+    protected void parseHeaders(XMLStreamReader reader, JMSBinding jmsBinding) throws XMLStreamException {
+        // TODO 
+    }    
+
+    protected void parseOperationProperties(XMLStreamReader reader, JMSBinding jmsBinding) throws XMLStreamException {
+        // TODO 
+    }
+
+
+
+    
+    
+
+}

Propchange: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProviderFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProviderFactory.java?view=auto&rev=542463
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProviderFactory.java (added)
+++ incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProviderFactory.java Tue May 29 01:53:55 2007
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.binding.jms;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.http.ServletHost;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+
+
+/**
+ * Implementation of the JSONRPC binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JMSBindingProviderFactory implements BindingProviderFactory<JMSBinding> {
+    
+    public JMSBindingProviderFactory() {        
+    }
+
+    public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component, RuntimeComponentReference reference, JMSBinding binding) {
+        return new JMSBindingReferenceBindingProvider(component, reference, binding);
+    }
+
+    public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component, RuntimeComponentService service, JMSBinding binding) {
+        return new JMSBindingServiceBindingProvider(component, service, binding);
+    }
+    
+    public Class<JMSBinding> getModelType() {
+        return JMSBinding.class;
+    }
+}

Propchange: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProviderFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProviderFactory.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingReferenceBindingProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingReferenceBindingProvider.java?view=auto&rev=542463
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingReferenceBindingProvider.java (added)
+++ incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingReferenceBindingProvider.java Tue May 29 01:53:55 2007
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.binding.jms;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+
+
+/**
+ * Implementation of the JSONRPC binding provider.
+ * 
+ * @version $Rev$ $Date$
+ */
+public class JMSBindingReferenceBindingProvider implements ReferenceBindingProvider {
+
+    private RuntimeComponent          component;
+    private RuntimeComponentReference reference;
+    private JMSBinding                jmsBinding;
+
+    public JMSBindingReferenceBindingProvider(RuntimeComponent component,
+                                              RuntimeComponentReference reference,
+                                              JMSBinding binding) {
+        this.component  = component;
+        this.reference  = reference;
+        this.jmsBinding = binding;
+    }
+
+    public Invoker createInvoker(Operation operation, boolean isCallback) {
+        if (isCallback) {
+            throw new UnsupportedOperationException();
+        } else {
+            return new JMSBindingInvoker(jmsBinding,
+                                         operation);                                      
+        }
+    }
+
+    public InterfaceContract getBindingInterfaceContract() {
+        return reference.getInterfaceContract();
+    }
+
+    public void start() {
+        
+    }
+
+    public void stop() {
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingReferenceBindingProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingReferenceBindingProvider.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingServiceBindingProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingServiceBindingProvider.java?view=auto&rev=542463
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingServiceBindingProvider.java (added)
+++ incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingServiceBindingProvider.java Tue May 29 01:53:55 2007
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.binding.jms;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.Session;
+import javax.naming.NamingException;
+
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * Implementation of the JSONRPC binding provider.
+ * 
+ * @version $Rev$ $Date$
+ */
+public class JMSBindingServiceBindingProvider implements ServiceBindingProvider {
+
+
+    private RuntimeComponent        component;
+    private RuntimeComponentService service;
+    private JMSBinding              jmsBinding;
+    private JMSResourceFactory      jmsResourceFactory; 
+    private MessageConsumer         consumer;
+
+    public JMSBindingServiceBindingProvider(RuntimeComponent component,
+                                            RuntimeComponentService service,
+                                            JMSBinding binding) {
+        this.component     = component;
+        this.service       = service;
+        this.jmsBinding    = binding;
+        
+        jmsResourceFactory = jmsBinding.getJmsResourceFactory();        
+    }
+
+    public InterfaceContract getBindingInterfaceContract() {
+        return service.getInterfaceContract();
+    }
+
+    public void start() {
+
+        try {
+            registerListerner();
+        } catch (Exception e) {
+            throw new JMSBindingException("Error starting JMSServiceBinding", e);
+        }      
+    }
+
+    public void stop() {
+        try {
+            consumer.close();
+            jmsResourceFactory.closeConnection();
+        } catch (Exception e) {
+            throw new JMSBindingException("Error stopping JMSServiceBinding", e);
+        }      
+    }
+    
+    private void registerListerner() throws NamingException, JMSException {
+
+        Session session         = jmsResourceFactory.createSession();
+//        Destination destination = session.createQueue("SCAMessageQ");//jmsBinding.getDestinationName());
+        Destination destination = jmsResourceFactory.lookupDestination(jmsBinding.getDestinationName());
+        consumer = session.createConsumer(destination);
+        
+        // TODO - We assume the target is a Java class here!!!
+        //Class<?> aClass = getTargetJavaClass(getBindingInterfaceContract().getInterface());
+       // Object instance = component.createSelfReference(aClass).getService();
+
+        consumer.setMessageListener(new JMSBindingListener(jmsBinding, jmsResourceFactory, service));
+
+        jmsResourceFactory.startConnection();
+
+    }    
+
+    private Class<?> getTargetJavaClass(Interface targetInterface) {
+        // TODO: right now assume that the target is always a Java
+        // Implementation. Need to figure out
+        // how to generate Java Interface in cases where the target is not a
+        // Java Implementation
+        return ((JavaInterface)targetInterface).getJavaClass();
+    }
+}

Propchange: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingServiceBindingProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingServiceBindingProvider.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org