diff options
Diffstat (limited to '')
7 files changed, 79 insertions, 6 deletions
diff --git a/otest/newlayout/tuscany-jms-test-runner/pom.xml b/otest/newlayout/tuscany-jms-test-runner/pom.xml index 55349fa98a..4116590e14 100644 --- a/otest/newlayout/tuscany-jms-test-runner/pom.xml +++ b/otest/newlayout/tuscany-jms-test-runner/pom.xml @@ -29,6 +29,19 @@ <name>Apache Tuscany SCA Specification Tests for JMS Binding</name>
<dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-node-impl</artifactId>
@@ -81,6 +94,12 @@ <artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
+ <version>2.0.0</version>
+ </dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
diff --git a/otest/newlayout/tuscany-jms-test-runner/src/test/resources/tuscany-oasis-sca-tests-errors.properties b/otest/newlayout/tuscany-jms-test-runner/src/test/resources/tuscany-oasis-sca-tests-errors.properties index 20cfb33893..b5e32a0d55 100644 --- a/otest/newlayout/tuscany-jms-test-runner/src/test/resources/tuscany-oasis-sca-tests-errors.properties +++ b/otest/newlayout/tuscany-jms-test-runner/src/test/resources/tuscany-oasis-sca-tests-errors.properties @@ -17,6 +17,8 @@ BJM_3014=org.apache.tuscany.sca.binding.jms.JMSBindingException: JMS Destination BJM_3014C=org.apache.tuscany.sca.binding.jms.JMSBindingException: JNDI resource 'TEST_BJM_3014_Queue' is not a JMS ConnectionFactory
BJM_3014D=org.apache.tuscany.sca.binding.jms.JMSBindingException: JMS Destination TEST_BJM_3014_Topic expecting type of queue but found topic while registering service Service1 listener
BJM_3015Aa=org.oasisopen.sca.ServiceRuntimeException: [Contribution: BJM_3015Aa, Artifact: Test_BJM_3015Aa.composite] - Must specify jndiName attribute when create mode is "never"
+BJM_3015Ab=org.apache.tuscany.sca.binding.jms.JMSBindingException: ActivationSpec specifies create mode of "never" but resource does not exist at jndiName DoesntExist
+BJM_3015Ac=org.apache.tuscany.sca.binding.jms.JMSBindingException: Incorrect resource type for ActivationSpec: org.apache.activemq.command.ActiveMQQueue
BJM_3015Ca=org.oasisopen.sca.ServiceRuntimeException: [Contribution: BJM_3015Ca, Artifact: Test_BJM_3015Ca.composite] - Missing ConnectionFactory Name
BJM_3015Cb=org.apache.tuscany.sca.binding.jms.JMSBindingException: connection factory not found: DoesntExist
BJM_3015Cc=org.apache.tuscany.sca.binding.jms.JMSBindingException: JNDI resource 'TEST_BJM_3015_Queue' is not a JMS ConnectionFactory
diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/binding-jms-runtime/META-INF/MANIFEST.MF index a25cc85adb..a16f0c48ca 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/META-INF/MANIFEST.MF +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/META-INF/MANIFEST.MF @@ -8,6 +8,7 @@ Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt Bundle-Description: Apache Tuscany SCA JMS Binding Runtime
Import-Package: javax.jms,
javax.naming,
+ javax.resource.spi,
javax.security.auth,
javax.xml.namespace,
javax.xml.stream,
diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/pom.xml b/sca-java-2.x/trunk/modules/binding-jms-runtime/pom.xml index 27dd79ff46..21fd859398 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/pom.xml +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/pom.xml @@ -91,6 +91,12 @@ <scope>provided</scope> </dependency> + <dependency> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId> + <version>2.0.0</version> + </dependency> + <dependency> <groupId>org.apache.tuscany.sca</groupId> <artifactId>tuscany-implementation-java-runtime</artifactId> diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListener.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListener.java index aca0d58697..94728699a2 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListener.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListener.java @@ -31,6 +31,7 @@ import javax.jms.Queue; import javax.jms.Session; import javax.jms.Topic; import javax.naming.NamingException; +import javax.resource.spi.ActivationSpec; import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.binding.jms.JMSBindingConstants; @@ -71,7 +72,7 @@ public class DefaultJMSServiceListener implements JMSServiceListener { this.running = true; try { - registerListerner(); + registerListener(); } catch (Exception e) { if (e instanceof JMSBindingException) throw (JMSBindingException)e; throw new JMSBindingException("Error starting JMSServiceBinding", e); @@ -94,9 +95,10 @@ public class DefaultJMSServiceListener implements JMSServiceListener { } } - private void registerListerner() throws NamingException, JMSException { + private void registerListener() throws NamingException, JMSException { Session session = jmsResourceFactory.createSession(); + lookupActivationSpec(); destination = lookupDestinationQueue(); if (destination == null) { destination = session.createTemporaryQueue(); @@ -146,7 +148,33 @@ public class DefaultJMSServiceListener implements JMSServiceListener { + ((destination instanceof Queue) ? ((Queue)destination).getQueueName() : ((Topic)destination).getTopicName())); } - /** + // Stub code for ActivationSpec support that throws appropriate errors + private void lookupActivationSpec() { + if ( jmsBinding.getActivationSpecName() != null ) { + String createMode = jmsBinding.getActivationSpecCreate(); + if ( JMSBindingConstants.CREATE_ALWAYS.equals(createMode) ) { + ActivationSpec spec = jmsResourceFactory.lookupActivationSpec(jmsBinding.getActivationSpecName()); + if ( spec != null ) { + throw new JMSBindingException("ActivationSpec specifies create mode of \"always\" but resource already exists."); + } + throw new JMSBindingException("Can not create ActivationSpec"); + } else if ( JMSBindingConstants.CREATE_IF_NOT_EXIST.equals(createMode)) { + ActivationSpec spec = jmsResourceFactory.lookupActivationSpec(jmsBinding.getActivationSpecName()); + if ( spec == null ) { + throw new JMSBindingException("Can not create ActivationSpec"); + } + } else if ( JMSBindingConstants.CREATE_NEVER.equals(createMode)) { + ActivationSpec spec = jmsResourceFactory.lookupActivationSpec(jmsBinding.getActivationSpecName()); + if ( spec == null ) + throw new JMSBindingException("ActivationSpec specifies create mode of \"never\" but resource does not exist at jndiName " + jmsBinding.getActivationSpecName()); + + } + + + } + } + + /** * Looks up the Destination Queue for the JMS Binding. * <p> * What happens in the look up will depend on the create mode specified for the JMS Binding: @@ -168,8 +196,8 @@ public class DefaultJMSServiceListener implements JMSServiceListener { if (isCallbackService && (jmsBinding.getDestinationName() == null)) { // if its a callback service returning null indicates to use a temporary queue return null; - } - + } + Destination destination = jmsResourceFactory.lookupDestination(jmsBinding.getDestinationName()); String qCreateMode = jmsBinding.getDestinationCreate(); @@ -236,7 +264,9 @@ public class DefaultJMSServiceListener implements JMSServiceListener { return destination; } - public String getDestinationName() { + + + public String getDestinationName() { try { if (destination instanceof Queue) { return ((Queue)destination).getQueueName(); diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java index cd53857ed8..5aaeca4ebc 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java @@ -24,6 +24,7 @@ import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.Session; import javax.naming.NamingException; +import javax.resource.spi.ActivationSpec; public interface JMSResourceFactory { @@ -92,4 +93,7 @@ public interface JMSResourceFactory { * shared with other users, or where connections cannot be held across transaction boundaries. */ public abstract boolean isConnectionClosedAfterUse(); + + public abstract ActivationSpec lookupActivationSpec( + String activationSpecName); } diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryImpl.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryImpl.java index c4c5f8c7af..9c1a384c7a 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryImpl.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryImpl.java @@ -28,6 +28,7 @@ import javax.jms.Session; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; +import javax.resource.spi.ActivationSpec; import org.apache.tuscany.sca.binding.jms.JMSBindingException; @@ -286,4 +287,14 @@ public class JMSResourceFactoryImpl implements JMSResourceFactory { return false; } + public ActivationSpec lookupActivationSpec(String activationSpecName) { + Object o = jndiLookUp(activationSpecName); + if ( o == null ) + return null; + else if (o instanceof ActivationSpec) + return (ActivationSpec) o; + + throw new JMSBindingException("Incorrect resource type for ActivationSpec: " + o.getClass().getName()); + } + } |