From 7eebc571e4e502003f47967069ad273ad63ac363 Mon Sep 17 00:00:00 2001 From: rfeng Date: Wed, 15 Oct 2008 20:56:35 +0000 Subject: Restrict Export-Package and refactor some internal classes git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@705041 13f79535-47bb-0310-9956-ffa450edef68 --- .../modules/binding-jms-runtime/pom.xml | 2 +- .../jms/provider/AbstractMessageProcessor.java | 6 +- .../binding/jms/provider/JMSBindingInvoker.java | 6 +- .../binding/jms/provider/JMSBindingListener.java | 6 +- .../jms/provider/JMSBindingProviderFactory.java | 2 +- .../JMSBindingReferenceBindingProvider.java | 6 +- .../provider/JMSBindingServiceBindingProvider.java | 6 +- .../jms/provider/JMSMessageProcessorUtil.java | 4 +- .../binding/jms/provider/JMSResourceFactory.java | 4 +- .../jms/provider/ObjectMessageProcessor.java | 4 +- .../binding/jms/provider/TextMessageProcessor.java | 4 +- .../jms/provider/XMLTextMessageProcessor.java | 4 +- ...che.tuscany.sca.provider.BindingProviderFactory | 2 +- branches/sca-equinox/modules/binding-jms/pom.xml | 2 +- .../apache/tuscany/sca/binding/jms/JMSBinding.java | 241 ++++++++ .../sca/binding/jms/JMSBindingException.java | 45 ++ .../tuscany/sca/binding/jms/JMSBindingFactory.java | 31 + .../tuscany/sca/binding/jms/impl/JMSBinding.java | 572 ----------------- .../sca/binding/jms/impl/JMSBindingConstants.java | 72 --- .../sca/binding/jms/impl/JMSBindingException.java | 45 -- .../binding/jms/impl/JMSBindingFactoryImpl.java | 34 + .../sca/binding/jms/impl/JMSBindingImpl.java | 573 +++++++++++++++++ .../sca/binding/jms/impl/JMSBindingProcessor.java | 683 -------------------- .../sca/binding/jms/xml/JMSBindingConstants.java | 72 +++ .../sca/binding/jms/xml/JMSBindingProcessor.java | 688 +++++++++++++++++++++ ...pache.tuscany.sca.binding.jms.JMSBindingFactory | 17 + ...ca.contribution.processor.StAXArtifactProcessor | 2 +- .../jms/impl/JMSBindingProcessorTestCase.java | 10 +- 28 files changed, 1736 insertions(+), 1407 deletions(-) create mode 100644 branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java create mode 100644 branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingException.java create mode 100644 branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingFactory.java delete mode 100644 branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java delete mode 100644 branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingConstants.java delete mode 100644 branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingException.java create mode 100644 branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingFactoryImpl.java create mode 100644 branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingImpl.java delete mode 100644 branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java create mode 100644 branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/xml/JMSBindingConstants.java create mode 100644 branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/xml/JMSBindingProcessor.java create mode 100644 branches/sca-equinox/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.jms.JMSBindingFactory diff --git a/branches/sca-equinox/modules/binding-jms-runtime/pom.xml b/branches/sca-equinox/modules/binding-jms-runtime/pom.xml index 75224861a5..ea751f349f 100644 --- a/branches/sca-equinox/modules/binding-jms-runtime/pom.xml +++ b/branches/sca-equinox/modules/binding-jms-runtime/pom.xml @@ -126,7 +126,7 @@ ${tuscany.version} org.apache.tuscany.sca.binding.jms.runtime ${pom.name} - org.apache.tuscany.sca.binding.jms.provider* + org.apache.tuscany.sca.binding.jms.provider diff --git a/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java b/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java index 2fcb07a07f..398b364c13 100644 --- a/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java +++ b/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java @@ -23,9 +23,9 @@ import javax.jms.Message; import javax.jms.ObjectMessage; import javax.jms.Session; -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; +import org.apache.tuscany.sca.binding.jms.JMSBinding; +import org.apache.tuscany.sca.binding.jms.JMSBindingException; +import org.apache.tuscany.sca.binding.jms.xml.JMSBindingConstants; import org.osoa.sca.ServiceRuntimeException; /** diff --git a/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java b/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java index a14e2bd018..51166e5b30 100644 --- a/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java +++ b/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java @@ -30,9 +30,9 @@ import javax.jms.MessageProducer; import javax.jms.Session; import javax.naming.NamingException; -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; +import org.apache.tuscany.sca.binding.jms.JMSBinding; +import org.apache.tuscany.sca.binding.jms.JMSBindingException; +import org.apache.tuscany.sca.binding.jms.xml.JMSBindingConstants; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.interfacedef.java.JavaInterface; import org.apache.tuscany.sca.invocation.DataExchangeSemantics; diff --git a/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingListener.java b/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingListener.java index 1990e553e0..07a617bc6c 100644 --- a/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingListener.java +++ b/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingListener.java @@ -34,9 +34,9 @@ import javax.jms.Topic; import javax.naming.NamingException; import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; +import org.apache.tuscany.sca.binding.jms.JMSBinding; +import org.apache.tuscany.sca.binding.jms.JMSBindingException; +import org.apache.tuscany.sca.binding.jms.xml.JMSBindingConstants; import org.apache.tuscany.sca.core.assembly.EndpointReferenceImpl; import org.apache.tuscany.sca.core.invocation.MessageImpl; import org.apache.tuscany.sca.interfacedef.Operation; diff --git a/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingProviderFactory.java b/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingProviderFactory.java index e0cd756849..0fe28e5a0f 100644 --- a/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingProviderFactory.java +++ b/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingProviderFactory.java @@ -19,7 +19,7 @@ package org.apache.tuscany.sca.binding.jms.provider; -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; +import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.provider.BindingProviderFactory; diff --git a/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java b/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java index 4266a6c7c8..901eb42650 100644 --- a/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java +++ b/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java @@ -25,9 +25,9 @@ import java.util.List; import javax.jms.JMSException; import org.apache.axiom.om.OMElement; -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; +import org.apache.tuscany.sca.binding.jms.JMSBinding; +import org.apache.tuscany.sca.binding.jms.JMSBindingException; +import org.apache.tuscany.sca.binding.jms.xml.JMSBindingConstants; import org.apache.tuscany.sca.binding.ws.WebServiceBinding; import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory; import org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator; diff --git a/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java b/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java index 7db640b7d1..9c391bacf9 100644 --- a/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java +++ b/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java @@ -33,9 +33,9 @@ import javax.naming.NamingException; import org.apache.axiom.om.OMElement; import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; +import org.apache.tuscany.sca.binding.jms.JMSBinding; +import org.apache.tuscany.sca.binding.jms.JMSBindingException; +import org.apache.tuscany.sca.binding.jms.xml.JMSBindingConstants; import org.apache.tuscany.sca.binding.ws.WebServiceBinding; import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory; import org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator; diff --git a/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java b/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java index 699b1cb176..09fe7310e6 100644 --- a/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java +++ b/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java @@ -21,8 +21,8 @@ package org.apache.tuscany.sca.binding.jms.provider; import java.lang.reflect.Constructor; -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; +import org.apache.tuscany.sca.binding.jms.JMSBinding; +import org.apache.tuscany.sca.binding.jms.JMSBindingException; /** * Utility methods to load JMS message processors. diff --git a/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java b/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java index a1308d98cf..6cf69abe5b 100644 --- a/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java +++ b/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java @@ -29,8 +29,8 @@ import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; +import org.apache.tuscany.sca.binding.jms.JMSBindingException; +import org.apache.tuscany.sca.binding.jms.xml.JMSBindingConstants; /** * Abstracts away any JMS provide specific feature from the JMS binding diff --git a/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/ObjectMessageProcessor.java b/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/ObjectMessageProcessor.java index e9ae3cecaa..477ec2c2ae 100644 --- a/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/ObjectMessageProcessor.java +++ b/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/ObjectMessageProcessor.java @@ -25,8 +25,8 @@ import javax.jms.Message; import javax.jms.ObjectMessage; import javax.jms.Session; -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; +import org.apache.tuscany.sca.binding.jms.JMSBinding; +import org.apache.tuscany.sca.binding.jms.JMSBindingException; /** * MessageProcessor for sending/receiving Serializable objects with the JMSBinding. diff --git a/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/TextMessageProcessor.java b/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/TextMessageProcessor.java index d8490c6223..32d024ec32 100644 --- a/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/TextMessageProcessor.java +++ b/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/TextMessageProcessor.java @@ -23,8 +23,8 @@ import javax.jms.Message; import javax.jms.Session; import javax.jms.TextMessage; -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; +import org.apache.tuscany.sca.binding.jms.JMSBinding; +import org.apache.tuscany.sca.binding.jms.JMSBindingException; /** * MessageProcessor for sending/receiving javax.jms.TextMessage with the JMSBinding. diff --git a/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLTextMessageProcessor.java b/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLTextMessageProcessor.java index 88dd41cc57..6e5556df01 100644 --- a/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLTextMessageProcessor.java +++ b/branches/sca-equinox/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLTextMessageProcessor.java @@ -30,8 +30,8 @@ import javax.xml.stream.XMLStreamReader; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.impl.builder.StAXOMBuilder; -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; +import org.apache.tuscany.sca.binding.jms.JMSBinding; +import org.apache.tuscany.sca.binding.jms.JMSBindingException; /** * MessageProcessor for sending/receiving XML javax.jms.TextMessage with the JMSBinding. diff --git a/branches/sca-equinox/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/branches/sca-equinox/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory index dec0991984..4cb8e90b7a 100644 --- a/branches/sca-equinox/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory +++ b/branches/sca-equinox/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory @@ -16,4 +16,4 @@ # under the License. # Implementation class for the binding extension -org.apache.tuscany.sca.binding.jms.provider.JMSBindingProviderFactory;model=org.apache.tuscany.sca.binding.jms.impl.JMSBinding +org.apache.tuscany.sca.binding.jms.provider.JMSBindingProviderFactory;model=org.apache.tuscany.sca.binding.jms.JMSBinding diff --git a/branches/sca-equinox/modules/binding-jms/pom.xml b/branches/sca-equinox/modules/binding-jms/pom.xml index e7dd413a78..7726c41098 100644 --- a/branches/sca-equinox/modules/binding-jms/pom.xml +++ b/branches/sca-equinox/modules/binding-jms/pom.xml @@ -56,7 +56,7 @@ ${tuscany.version} org.apache.tuscany.sca.binding.jms ${pom.name} - org.apache.tuscany.sca.binding.jms* + org.apache.tuscany.sca.binding.jms diff --git a/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java b/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java new file mode 100644 index 0000000000..ddc41a463a --- /dev/null +++ b/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java @@ -0,0 +1,241 @@ +/* + * 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.List; +import java.util.Map; +import java.util.Set; + +import org.apache.tuscany.sca.assembly.Binding; + +/** + * Models a binding to a JMS resource. + * + * @version $Rev$ $Date$ + */ + +public interface JMSBinding extends Binding { + + public Object clone() throws CloneNotSupportedException; + + /** + * Returns the binding URI. + * + * @return the binding URI + */ + public String getURI(); + + /** + * Sets the binding URI. + * + * @param uri the binding URI + */ + public void setURI(String uri); + + /** + * Returns the binding name. + * + * @return the binding name + */ + public String getName(); + + /** + * Sets the binding name. + * + * @param name the binding name + */ + public void setName(String name); + + public boolean isUnresolved(); + + public void setUnresolved(boolean unresolved); + + public List getExtensions(); + + // Methods for getting/setting JMS binding model information + // as derived from the XML of the binding.jms element + + 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 String getDestinationType(); + + public void setDestinationType(String 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 String getResponseDestinationType(); + + public void setResponseDestinationType(String type); + + public String getResponseDestinationCreate(); + + public void setResponseDestinationCreate(String create); + + public String getResponseConnectionFactoryName(); + + public void setResponseConnectionFactoryName(String connectionFactoryName); + + public String getResponseConnectionFactoryCreate(); + + public void setResponseConnectionFactoryCreate(String create); + + public String getResponseActivationSpecName(); + + public void setResponseActivationSpecName(String activationSpecName); + + public String getResponseActivationSpecCreate(); + + public void setResponseActivationSpecCreate(String create); + + public String getJmsResourceFactoryName(); + + public void setJmsResourceFactoryName(String jmsResourceFactoryName); + + public void setRequestMessageProcessorName(String name); + + public String getRequestMessageProcessorName(); + + public void setResponseMessageProcessorName(String name); + + public String getResponseMessageProcessorName(); + + public String getOperationSelectorPropertyName(); + + public void setOperationSelectorPropertyName(String operationSelectorPropertyName); + + public String getOperationSelectorName(); + + public void setOperationSelectorName(String operationSelectorName); + + public String getReplyTo(); + + public void setReplyTo(String replyTo); + + public String getJMSType(); + + public void setJMSType(String jmsType); + + public String getJMSCorrelationId(); + + public void setJMSCorrelationId(String jmsCorrelationId); + + public Boolean isdeliveryModePersistent(); + + public void setJMSDeliveryMode(boolean persistent); + + public Integer getJMSPriority(); + + public void setJMSPriority(int jmsPriority); + + public Long getJMSTimeToLive(); + + public void setJMSTimeToLive(long timeToLive); + + public Set getPropertyNames(); + + public Object getProperty(String name); + + public void setProperty(String name, Object value); + + public Map getOperationProperties(String opName); + + public void setOperationProperty(String opName, String propName, Object value); + + public boolean hasNativeOperationName(String opName); + + public String getNativeOperationName(String opName); + + public void setNativeOperationName(String opName, String nativeOpName); + + public String getOperationJMSType(String opName); + + public void setOperationJMSType(String opName, String jmsType); + + public String getOperationJMSCorrelationId(String opName); + + public void setOperationJMSCorrelationId(String opName, String jmsCorrelationId); + + public Boolean getOperationJMSDeliveryMode(String opName); + + public void setOperationJMSDeliveryMode(String opName, boolean b); + + public Long getOperationJMSTimeToLive(String opName); + + public void setOperationJMSTimeToLive(String opName, Long ttl); + + public Integer getOperationJMSPriority(String opName); + + public void setOperationJMSPriority(String opName, int p); + + public String getJMSSelector(); + + public void setJMSSelector(String jmsSelector); + + public String getRequestConnectionName(); + + public void setRequestConnectionName(String requestConnectionName); + + public void setResponseConnectionName(String responseConnectionName); + + public String getResponseConnectionName(); + + public void setRequestConnectionBinding(JMSBinding binding); + + public JMSBinding getRequestConnectionBinding(); + + public void setResponseConnectionBinding(JMSBinding binding); + + public JMSBinding getResponseConnectionBinding(); +} diff --git a/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingException.java b/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingException.java new file mode 100644 index 0000000000..74f030ca21 --- /dev/null +++ b/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingException.java @@ -0,0 +1,45 @@ +/* + * 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; + +/** + * Base exception for the JMSBinding. + * + * @version $Rev$ $Date$ + */ +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); + } + +} diff --git a/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingFactory.java b/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingFactory.java new file mode 100644 index 0000000000..d96dadf8c5 --- /dev/null +++ b/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingFactory.java @@ -0,0 +1,31 @@ +/* + * 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; + +/** + * Factroy interface to create JMSBinding model + * + */ +public interface JMSBindingFactory { + /** + * Create an instance of JMSBinding + * @return A new instance of JMSBinding + */ + JMSBinding createJMSBinding(); +} diff --git a/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java b/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java deleted file mode 100644 index bd493bb658..0000000000 --- a/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java +++ /dev/null @@ -1,572 +0,0 @@ -/* - * 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.impl; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.tuscany.sca.assembly.Binding; - -/** - * Models a binding to a JMS resource. - * - * @version $Rev$ $Date$ - */ - -public class JMSBinding implements Binding { - - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - // properties required to implement the Tuscany binding extension SPI - private String uri = null; - private String name = null; - private boolean unresolved = false; - private List extensions = new ArrayList(); - - // Properties required to describe the JMS binding model - - private String correlationScheme = JMSBindingConstants.CORRELATE_MSG_ID; - private String initialContextFactoryName; - private String jndiURL; - - private String destinationName = JMSBindingConstants.DEFAULT_DESTINATION_NAME; - private String destinationType = JMSBindingConstants.DESTINATION_TYPE_QUEUE; - private String destinationCreate = JMSBindingConstants.CREATE_IF_NOT_EXIST; - - private String connectionFactoryName = JMSBindingConstants.DEFAULT_CONNECTION_FACTORY_NAME; - private String connectionFactoryCreate = JMSBindingConstants.CREATE_IF_NOT_EXIST; - - private String activationSpecName = null; - private String activationSpecCreate = null; - - private String responseActivationSpecName = null; - private String responseActivationSpecCreate = null; - - private String responseDestinationName = JMSBindingConstants.DEFAULT_RESPONSE_DESTINATION_NAME; - private String responseDestinationType = JMSBindingConstants.DESTINATION_TYPE_QUEUE; - private String responseDestinationCreate = JMSBindingConstants.CREATE_IF_NOT_EXIST; - - private String responseConnectionFactoryName = JMSBindingConstants.DEFAULT_CONNECTION_FACTORY_NAME; - private String responseConnectionFactoryCreate = JMSBindingConstants.CREATE_IF_NOT_EXIST; - - // 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; - - private String replyTo; - private String jmsType; - private String jmsCorrelationId; - private Boolean deliveryModePersistent; - private Long timeToLive; - private Integer jmsPriority; - - private Map properties = new HashMap(); - private Map> operationProperties = new HashMap>(); - private Map nativeOperationNames = new HashMap(); - private Map operationJMSTypes = new HashMap(); - private Map operationJMSCorrelationIds = new HashMap(); - private Map operationJMSDeliveryModes = new HashMap(); - private Map operationJMSTimeToLives = new HashMap(); - private Map operationJMSPriorities = new HashMap(); - private String jmsSelector; - private String requestConnectionName; - private String responseConnectionName; - private JMSBinding requestConnectionBinding; - private JMSBinding responseConnectionBinding; - - public JMSBinding() { - 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 boolean isUnresolved() { - return this.unresolved; - } - - public void setUnresolved(boolean unresolved) { - this.unresolved = unresolved; - } - - public List 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() { - if (requestConnectionBinding != null && requestConnectionBinding.getDestinationName() != null) { - return requestConnectionBinding.getDestinationName(); - } else { - return destinationName; - } - } - - public void setDestinationName(String destinationName) { - this.destinationName = destinationName; - } - - public String getDestinationType() { - if (requestConnectionBinding != null && requestConnectionBinding.getDestinationType() != null) { - return requestConnectionBinding.getDestinationType(); - } else { - return destinationType; - } - } - - public void setDestinationType(String destinationType) { - this.destinationType = destinationType; - } - - public String getDestinationCreate() { - if (requestConnectionBinding != null && requestConnectionBinding.getDestinationCreate() != null) { - return requestConnectionBinding.getDestinationCreate(); - } else { - return this.destinationCreate; - } - } - - public void setDestinationCreate(String create) { - this.destinationCreate = create; - } - - public String getConnectionFactoryName() { - if (requestConnectionBinding != null && requestConnectionBinding.getConnectionFactoryName() != null) { - return requestConnectionBinding.getConnectionFactoryName(); - } else { - return connectionFactoryName; - } - } - - public void setConnectionFactoryName(String connectionFactoryName) { - this.connectionFactoryName = connectionFactoryName; - } - - public String getConnectionFactoryCreate() { - if (requestConnectionBinding != null && requestConnectionBinding.getConnectionFactoryCreate() != null) { - return requestConnectionBinding.getConnectionFactoryCreate(); - } else { - return this.connectionFactoryCreate; - } - } - - public void setConnectionFactoryCreate(String create) { - this.connectionFactoryCreate = create; - } - - public String getActivationSpecName() { - if (requestConnectionBinding != null && requestConnectionBinding.getActivationSpecName() != null) { - return requestConnectionBinding.getActivationSpecName(); - } else { - return activationSpecName; - } - } - - public void setActivationSpecName(String activationSpecName) { - this.activationSpecName = activationSpecName; - } - - public String getActivationSpecCreate() { - if (requestConnectionBinding != null && requestConnectionBinding.getActivationSpecCreate() != null) { - return requestConnectionBinding.getActivationSpecCreate(); - } else { - return this.activationSpecCreate; - } - } - - public void setActivationSpecCreate(String create) { - this.activationSpecCreate = create; - } - - public String getResponseDestinationName() { - if (requestConnectionBinding != null && requestConnectionBinding.getResponseDestinationName() != null) { - return requestConnectionBinding.getResponseDestinationName(); - } else { - return this.responseDestinationName; - } - } - - public void setResponseDestinationName(String name) { - this.responseDestinationName = name; - } - - public String getResponseDestinationType() { - if (requestConnectionBinding != null && requestConnectionBinding.getResponseDestinationType() != null) { - return requestConnectionBinding.getResponseDestinationType(); - } else { - return this.responseDestinationType; - } - } - - public void setResponseDestinationType(String type) { - this.responseDestinationType = type; - } - - public String getResponseDestinationCreate() { - if (requestConnectionBinding != null && requestConnectionBinding.getResponseDestinationCreate() != null) { - return requestConnectionBinding.getResponseDestinationCreate(); - } else { - return this.responseDestinationCreate; - } - } - - public void setResponseDestinationCreate(String create) { - this.responseDestinationCreate = create; - } - - public String getResponseConnectionFactoryName() { - if (requestConnectionBinding != null && requestConnectionBinding.getResponseConnectionFactoryName() != null) { - return requestConnectionBinding.getResponseConnectionFactoryName(); - } else { - return responseConnectionFactoryName; - } - } - - public void setResponseConnectionFactoryName(String connectionFactoryName) { - this.responseConnectionFactoryName = connectionFactoryName; - } - - public String getResponseConnectionFactoryCreate() { - if (requestConnectionBinding != null && requestConnectionBinding.getResponseConnectionFactoryCreate() != null) { - return requestConnectionBinding.getResponseConnectionFactoryCreate(); - } else { - return this.responseConnectionFactoryCreate; - } - } - - public void setResponseConnectionFactoryCreate(String create) { - this.responseConnectionFactoryCreate = create; - } - - public String getResponseActivationSpecName() { - if (requestConnectionBinding != null && requestConnectionBinding.getResponseActivationSpecName() != null) { - return requestConnectionBinding.getResponseActivationSpecName(); - } else { - return responseActivationSpecName; - } - } - - public void setResponseActivationSpecName(String activationSpecName) { - this.responseActivationSpecName = activationSpecName; - } - - public String getResponseActivationSpecCreate() { - if (requestConnectionBinding != null && requestConnectionBinding.getResponseActivationSpecCreate() != null) { - return requestConnectionBinding.getResponseActivationSpecCreate(); - } else { - return this.responseActivationSpecCreate; - } - } - - public void setResponseActivationSpecCreate(String create) { - this.responseActivationSpecCreate = create; - } - - public String getJmsResourceFactoryName() { - return jmsResourceFactoryName; - } - - public void setJmsResourceFactoryName(String jmsResourceFactoryName) { - this.jmsResourceFactoryName = jmsResourceFactoryName; - } - - public void setRequestMessageProcessorName(String name) { - this.requestMessageProcessorName = name; - } - - public String getRequestMessageProcessorName() { - return requestMessageProcessorName; - } - - public void setResponseMessageProcessorName(String name) { - this.responseMessageProcessorName = name; - } - - public String getResponseMessageProcessorName() { - return responseMessageProcessorName; - } - - 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 String getReplyTo() { - return replyTo; - } - - public void setReplyTo(String replyTo) { - this.replyTo = replyTo; - } - - public String getJMSType() { - return jmsType; - } - public void setJMSType(String jmsType) { - this.jmsType = jmsType; - } - - public String getJMSCorrelationId() { - return jmsCorrelationId; - } - - public void setJMSCorrelationId(String jmsCorrelationId) { - this.jmsCorrelationId = jmsCorrelationId; - } - - public Boolean isdeliveryModePersistent() { - return deliveryModePersistent; - } - public void setJMSDeliveryMode(boolean persistent) { - this.deliveryModePersistent = Boolean.valueOf(persistent); - } - - public Integer getJMSPriority() { - return jmsPriority; - } - - public void setJMSPriority(int jmsPriority) { - this.jmsPriority = Integer.valueOf(jmsPriority); - } - - public Long getJMSTimeToLive() { - return timeToLive.longValue(); - } - - public void setJMSTimeToLive(long timeToLive) { - this.timeToLive = Long.valueOf(timeToLive); - } - - public Set getPropertyNames() { - return properties.keySet(); - } - - public Object getProperty(String name) { - return properties.get(name); - } - - public void setProperty(String name, Object value) { - properties.put(name, value); - } - - public Map getOperationProperties(String opName) { - return operationProperties.get(opName); - } - - public void setOperationProperty(String opName, String propName, Object value) { - Map props = operationProperties.get(opName); - if (props == null) { - props = new HashMap(); - operationProperties.put(opName, props); - } - props.put(propName, value); - } - - public boolean hasNativeOperationName(String opName) { - return nativeOperationNames.containsKey(opName); - } - - public String getNativeOperationName(String opName) { - if (nativeOperationNames.containsKey(opName)) { - return nativeOperationNames.get(opName); - } else { - return opName; - } - } - - public void setNativeOperationName(String opName, String nativeOpName) { - this.nativeOperationNames .put(opName, nativeOpName); - } - - public String getOperationJMSType(String opName) { - if (operationJMSTypes.containsKey(opName)) { - return operationJMSTypes.get(opName); - } else { - return jmsType; - } - } - public void setOperationJMSType(String opName, String jmsType) { - this.operationJMSTypes.put(opName, jmsType); - } - - public String getOperationJMSCorrelationId(String opName) { - if (operationJMSCorrelationIds.containsKey(opName)) { - return operationJMSCorrelationIds.get(opName); - } else { - return jmsCorrelationId; - } - } - public void setOperationJMSCorrelationId(String opName, String jmsCorrelationId) { - operationJMSCorrelationIds.put(opName, jmsCorrelationId); - } - - public Boolean getOperationJMSDeliveryMode(String opName) { - if (operationJMSDeliveryModes.containsKey(opName)) { - return operationJMSDeliveryModes.get(opName); - } else { - return deliveryModePersistent; - } - } - public void setOperationJMSDeliveryMode(String opName, boolean b) { - operationJMSDeliveryModes.put(opName, b); - } - - public Long getOperationJMSTimeToLive(String opName) { - if (operationJMSTimeToLives.containsKey(opName)) { - return operationJMSTimeToLives.get(opName); - } else { - return timeToLive; - } - } - public void setOperationJMSTimeToLive(String opName, Long ttl) { - operationJMSTimeToLives.put(opName, ttl); - } - - public Integer getOperationJMSPriority(String opName) { - if (operationJMSPriorities.containsKey(opName)) { - return operationJMSPriorities.get(opName); - } else { - return jmsPriority; - } - } - public void setOperationJMSPriority(String opName, int p) { - operationJMSPriorities.put(opName, p); - } - - public String getJMSSelector() { - return jmsSelector; - } - public void setJMSSelector(String jmsSelector) { - this.jmsSelector = jmsSelector; - } - - public String getRequestConnectionName() { - return requestConnectionName; - } - - public void setRequestConnectionName(String requestConnectionName) { - this.requestConnectionName = requestConnectionName; - } - - public void setResponseConnectionName(String responseConnectionName) { - this.responseConnectionName = responseConnectionName; - } - public String getResponseConnectionName() { - return responseConnectionName; - } - - public void setRequestConnectionBinding(JMSBinding binding) { - this.requestConnectionBinding = binding; - } - public JMSBinding getRequestConnectionBinding() { - return requestConnectionBinding; - } - - public void setResponseConnectionBinding(JMSBinding binding) { - this.responseConnectionBinding = binding; - } - public JMSBinding getResponseConnectionBinding() { - return responseConnectionBinding; - } -} diff --git a/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingConstants.java b/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingConstants.java deleted file mode 100644 index 7317c2118d..0000000000 --- a/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingConstants.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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.impl; - -import java.util.Arrays; -import java.util.List; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.xml.Constants; - -/** - * Constants for the JMS binding. - * - * @version $Rev$ $Date$ - */ -public interface JMSBindingConstants { - - // Constants used when describing the JMS binding - // model and for setting up defaults - String BINDING_JMS = "binding.jms"; - QName BINDING_JMS_QNAME = new QName(Constants.SCA10_NS, BINDING_JMS); - String CORRELATE_MSG_ID = "requestmsgidtocorrelid"; - String CORRELATE_CORRELATION_ID = "requestcorrelidtocorrelid"; - String CORRELATE_NONE = "none"; - List VALID_CORRELATION_SCHEMES = - Arrays.asList(new String[] {CORRELATE_MSG_ID, CORRELATE_CORRELATION_ID, CORRELATE_NONE}); - String DESTINATION_TYPE_QUEUE = "queue"; // 0 - String DESTINATION_TYPE_TOPIC = "topic"; // 1 - List VALID_DESTINATION_TYPES = - Arrays.asList(new String[] {DESTINATION_TYPE_QUEUE, DESTINATION_TYPE_TOPIC}); - String CREATE_ALWAYS = "always"; - String CREATE_NEVER = "never"; - String CREATE_IF_NOT_EXIST = "ifnotexist"; - String DEFAULT_DESTINATION_NAME = "NODESTINATION"; - String DEFAULT_RESPONSE_DESTINATION_NAME = "NORESPONSEDESTINATION"; - String DEFAULT_CONNECTION_FACTORY_NAME = "ConnectionFactory"; - String DEFAULT_CONTEXT_FACTORY_NAME = "org.apache.activemq.jndi.ActiveMQInitialContextFactory"; - String DEFAULT_JNDI_URL = "tcp://localhost:61616"; - int DEFAULT_TIME_TO_LIVE = 20000; // in milliseconds - int DEFAULT_PRIORITY = 1; - int NON_PERSISTENT = 1; // Maps to javax.jms.DeliveryMode - String DEFAULT_RF_CLASSNAME = "org.apache.tuscany.sca.host.jms.activemq.JMSResourceFactoryImpl"; - String XML_MP_CLASSNAME = "org.apache.tuscany.sca.binding.jms.provider.XMLTextMessageProcessor"; - String TEXT_MP_CLASSNAME = "org.apache.tuscany.sca.binding.jms.provider.TextMessageProcessor"; - String OBJECT_MP_CLASSNAME = "org.apache.tuscany.sca.binding.jms.provider.ObjectMessageProcessor"; - String DEFAULT_MP_CLASSNAME = XML_MP_CLASSNAME; - String DEFAULT_OPERATION_PROP_NAME = "scaOperationName"; - - String FAULT_PROPERTY = "org_apache_tuscany_sca_fault"; - - String CALLBACK_ID_PROPERTY = "CallbackID"; - String CALLBACK_Q_PROPERTY = "scaCallbackQueue "; - String CONVERSATION_ID_PROPERTY = "scaConversationId"; - -} diff --git a/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingException.java b/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingException.java deleted file mode 100644 index 0928e02082..0000000000 --- a/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingException.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.impl; - -/** - * Base exception for the JMSBinding. - * - * @version $Rev$ $Date$ - */ -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); - } - -} diff --git a/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingFactoryImpl.java b/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingFactoryImpl.java new file mode 100644 index 0000000000..b67ee97eb3 --- /dev/null +++ b/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingFactoryImpl.java @@ -0,0 +1,34 @@ +/* + * 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.impl; + +import org.apache.tuscany.sca.binding.jms.JMSBinding; +import org.apache.tuscany.sca.binding.jms.JMSBindingFactory; + +/** + * Default implementation of JMSBindingFactory + * + */ +public class JMSBindingFactoryImpl implements JMSBindingFactory { + + public JMSBinding createJMSBinding() { + return new JMSBindingImpl(); + } + +} diff --git a/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingImpl.java b/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingImpl.java new file mode 100644 index 0000000000..b6bb6fe67c --- /dev/null +++ b/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingImpl.java @@ -0,0 +1,573 @@ +/* + * 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.impl; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.tuscany.sca.binding.jms.JMSBinding; +import org.apache.tuscany.sca.binding.jms.xml.JMSBindingConstants; + +/** + * Models a binding to a JMS resource. + * + * @version $Rev$ $Date$ + */ + +public class JMSBindingImpl implements JMSBinding { + + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + // properties required to implement the Tuscany binding extension SPI + private String uri = null; + private String name = null; + private boolean unresolved = false; + private List extensions = new ArrayList(); + + // Properties required to describe the JMS binding model + + private String correlationScheme = JMSBindingConstants.CORRELATE_MSG_ID; + private String initialContextFactoryName; + private String jndiURL; + + private String destinationName = JMSBindingConstants.DEFAULT_DESTINATION_NAME; + private String destinationType = JMSBindingConstants.DESTINATION_TYPE_QUEUE; + private String destinationCreate = JMSBindingConstants.CREATE_IF_NOT_EXIST; + + private String connectionFactoryName = JMSBindingConstants.DEFAULT_CONNECTION_FACTORY_NAME; + private String connectionFactoryCreate = JMSBindingConstants.CREATE_IF_NOT_EXIST; + + private String activationSpecName = null; + private String activationSpecCreate = null; + + private String responseActivationSpecName = null; + private String responseActivationSpecCreate = null; + + private String responseDestinationName = JMSBindingConstants.DEFAULT_RESPONSE_DESTINATION_NAME; + private String responseDestinationType = JMSBindingConstants.DESTINATION_TYPE_QUEUE; + private String responseDestinationCreate = JMSBindingConstants.CREATE_IF_NOT_EXIST; + + private String responseConnectionFactoryName = JMSBindingConstants.DEFAULT_CONNECTION_FACTORY_NAME; + private String responseConnectionFactoryCreate = JMSBindingConstants.CREATE_IF_NOT_EXIST; + + // 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; + + private String replyTo; + private String jmsType; + private String jmsCorrelationId; + private Boolean deliveryModePersistent; + private Long timeToLive; + private Integer jmsPriority; + + private Map properties = new HashMap(); + private Map> operationProperties = new HashMap>(); + private Map nativeOperationNames = new HashMap(); + private Map operationJMSTypes = new HashMap(); + private Map operationJMSCorrelationIds = new HashMap(); + private Map operationJMSDeliveryModes = new HashMap(); + private Map operationJMSTimeToLives = new HashMap(); + private Map operationJMSPriorities = new HashMap(); + private String jmsSelector; + private String requestConnectionName; + private String responseConnectionName; + private JMSBinding requestConnectionBinding; + private JMSBinding responseConnectionBinding; + + 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 boolean isUnresolved() { + return this.unresolved; + } + + public void setUnresolved(boolean unresolved) { + this.unresolved = unresolved; + } + + public List 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() { + if (requestConnectionBinding != null && requestConnectionBinding.getDestinationName() != null) { + return requestConnectionBinding.getDestinationName(); + } else { + return destinationName; + } + } + + public void setDestinationName(String destinationName) { + this.destinationName = destinationName; + } + + public String getDestinationType() { + if (requestConnectionBinding != null && requestConnectionBinding.getDestinationType() != null) { + return requestConnectionBinding.getDestinationType(); + } else { + return destinationType; + } + } + + public void setDestinationType(String destinationType) { + this.destinationType = destinationType; + } + + public String getDestinationCreate() { + if (requestConnectionBinding != null && requestConnectionBinding.getDestinationCreate() != null) { + return requestConnectionBinding.getDestinationCreate(); + } else { + return this.destinationCreate; + } + } + + public void setDestinationCreate(String create) { + this.destinationCreate = create; + } + + public String getConnectionFactoryName() { + if (requestConnectionBinding != null && requestConnectionBinding.getConnectionFactoryName() != null) { + return requestConnectionBinding.getConnectionFactoryName(); + } else { + return connectionFactoryName; + } + } + + public void setConnectionFactoryName(String connectionFactoryName) { + this.connectionFactoryName = connectionFactoryName; + } + + public String getConnectionFactoryCreate() { + if (requestConnectionBinding != null && requestConnectionBinding.getConnectionFactoryCreate() != null) { + return requestConnectionBinding.getConnectionFactoryCreate(); + } else { + return this.connectionFactoryCreate; + } + } + + public void setConnectionFactoryCreate(String create) { + this.connectionFactoryCreate = create; + } + + public String getActivationSpecName() { + if (requestConnectionBinding != null && requestConnectionBinding.getActivationSpecName() != null) { + return requestConnectionBinding.getActivationSpecName(); + } else { + return activationSpecName; + } + } + + public void setActivationSpecName(String activationSpecName) { + this.activationSpecName = activationSpecName; + } + + public String getActivationSpecCreate() { + if (requestConnectionBinding != null && requestConnectionBinding.getActivationSpecCreate() != null) { + return requestConnectionBinding.getActivationSpecCreate(); + } else { + return this.activationSpecCreate; + } + } + + public void setActivationSpecCreate(String create) { + this.activationSpecCreate = create; + } + + public String getResponseDestinationName() { + if (requestConnectionBinding != null && requestConnectionBinding.getResponseDestinationName() != null) { + return requestConnectionBinding.getResponseDestinationName(); + } else { + return this.responseDestinationName; + } + } + + public void setResponseDestinationName(String name) { + this.responseDestinationName = name; + } + + public String getResponseDestinationType() { + if (requestConnectionBinding != null && requestConnectionBinding.getResponseDestinationType() != null) { + return requestConnectionBinding.getResponseDestinationType(); + } else { + return this.responseDestinationType; + } + } + + public void setResponseDestinationType(String type) { + this.responseDestinationType = type; + } + + public String getResponseDestinationCreate() { + if (requestConnectionBinding != null && requestConnectionBinding.getResponseDestinationCreate() != null) { + return requestConnectionBinding.getResponseDestinationCreate(); + } else { + return this.responseDestinationCreate; + } + } + + public void setResponseDestinationCreate(String create) { + this.responseDestinationCreate = create; + } + + public String getResponseConnectionFactoryName() { + if (requestConnectionBinding != null && requestConnectionBinding.getResponseConnectionFactoryName() != null) { + return requestConnectionBinding.getResponseConnectionFactoryName(); + } else { + return responseConnectionFactoryName; + } + } + + public void setResponseConnectionFactoryName(String connectionFactoryName) { + this.responseConnectionFactoryName = connectionFactoryName; + } + + public String getResponseConnectionFactoryCreate() { + if (requestConnectionBinding != null && requestConnectionBinding.getResponseConnectionFactoryCreate() != null) { + return requestConnectionBinding.getResponseConnectionFactoryCreate(); + } else { + return this.responseConnectionFactoryCreate; + } + } + + public void setResponseConnectionFactoryCreate(String create) { + this.responseConnectionFactoryCreate = create; + } + + public String getResponseActivationSpecName() { + if (requestConnectionBinding != null && requestConnectionBinding.getResponseActivationSpecName() != null) { + return requestConnectionBinding.getResponseActivationSpecName(); + } else { + return responseActivationSpecName; + } + } + + public void setResponseActivationSpecName(String activationSpecName) { + this.responseActivationSpecName = activationSpecName; + } + + public String getResponseActivationSpecCreate() { + if (requestConnectionBinding != null && requestConnectionBinding.getResponseActivationSpecCreate() != null) { + return requestConnectionBinding.getResponseActivationSpecCreate(); + } else { + return this.responseActivationSpecCreate; + } + } + + public void setResponseActivationSpecCreate(String create) { + this.responseActivationSpecCreate = create; + } + + public String getJmsResourceFactoryName() { + return jmsResourceFactoryName; + } + + public void setJmsResourceFactoryName(String jmsResourceFactoryName) { + this.jmsResourceFactoryName = jmsResourceFactoryName; + } + + public void setRequestMessageProcessorName(String name) { + this.requestMessageProcessorName = name; + } + + public String getRequestMessageProcessorName() { + return requestMessageProcessorName; + } + + public void setResponseMessageProcessorName(String name) { + this.responseMessageProcessorName = name; + } + + public String getResponseMessageProcessorName() { + return responseMessageProcessorName; + } + + 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 String getReplyTo() { + return replyTo; + } + + public void setReplyTo(String replyTo) { + this.replyTo = replyTo; + } + + public String getJMSType() { + return jmsType; + } + public void setJMSType(String jmsType) { + this.jmsType = jmsType; + } + + public String getJMSCorrelationId() { + return jmsCorrelationId; + } + + public void setJMSCorrelationId(String jmsCorrelationId) { + this.jmsCorrelationId = jmsCorrelationId; + } + + public Boolean isdeliveryModePersistent() { + return deliveryModePersistent; + } + public void setJMSDeliveryMode(boolean persistent) { + this.deliveryModePersistent = Boolean.valueOf(persistent); + } + + public Integer getJMSPriority() { + return jmsPriority; + } + + public void setJMSPriority(int jmsPriority) { + this.jmsPriority = Integer.valueOf(jmsPriority); + } + + public Long getJMSTimeToLive() { + return timeToLive.longValue(); + } + + public void setJMSTimeToLive(long timeToLive) { + this.timeToLive = Long.valueOf(timeToLive); + } + + public Set getPropertyNames() { + return properties.keySet(); + } + + public Object getProperty(String name) { + return properties.get(name); + } + + public void setProperty(String name, Object value) { + properties.put(name, value); + } + + public Map getOperationProperties(String opName) { + return operationProperties.get(opName); + } + + public void setOperationProperty(String opName, String propName, Object value) { + Map props = operationProperties.get(opName); + if (props == null) { + props = new HashMap(); + operationProperties.put(opName, props); + } + props.put(propName, value); + } + + public boolean hasNativeOperationName(String opName) { + return nativeOperationNames.containsKey(opName); + } + + public String getNativeOperationName(String opName) { + if (nativeOperationNames.containsKey(opName)) { + return nativeOperationNames.get(opName); + } else { + return opName; + } + } + + public void setNativeOperationName(String opName, String nativeOpName) { + this.nativeOperationNames .put(opName, nativeOpName); + } + + public String getOperationJMSType(String opName) { + if (operationJMSTypes.containsKey(opName)) { + return operationJMSTypes.get(opName); + } else { + return jmsType; + } + } + public void setOperationJMSType(String opName, String jmsType) { + this.operationJMSTypes.put(opName, jmsType); + } + + public String getOperationJMSCorrelationId(String opName) { + if (operationJMSCorrelationIds.containsKey(opName)) { + return operationJMSCorrelationIds.get(opName); + } else { + return jmsCorrelationId; + } + } + public void setOperationJMSCorrelationId(String opName, String jmsCorrelationId) { + operationJMSCorrelationIds.put(opName, jmsCorrelationId); + } + + public Boolean getOperationJMSDeliveryMode(String opName) { + if (operationJMSDeliveryModes.containsKey(opName)) { + return operationJMSDeliveryModes.get(opName); + } else { + return deliveryModePersistent; + } + } + public void setOperationJMSDeliveryMode(String opName, boolean b) { + operationJMSDeliveryModes.put(opName, b); + } + + public Long getOperationJMSTimeToLive(String opName) { + if (operationJMSTimeToLives.containsKey(opName)) { + return operationJMSTimeToLives.get(opName); + } else { + return timeToLive; + } + } + public void setOperationJMSTimeToLive(String opName, Long ttl) { + operationJMSTimeToLives.put(opName, ttl); + } + + public Integer getOperationJMSPriority(String opName) { + if (operationJMSPriorities.containsKey(opName)) { + return operationJMSPriorities.get(opName); + } else { + return jmsPriority; + } + } + public void setOperationJMSPriority(String opName, int p) { + operationJMSPriorities.put(opName, p); + } + + public String getJMSSelector() { + return jmsSelector; + } + public void setJMSSelector(String jmsSelector) { + this.jmsSelector = jmsSelector; + } + + public String getRequestConnectionName() { + return requestConnectionName; + } + + public void setRequestConnectionName(String requestConnectionName) { + this.requestConnectionName = requestConnectionName; + } + + public void setResponseConnectionName(String responseConnectionName) { + this.responseConnectionName = responseConnectionName; + } + public String getResponseConnectionName() { + return responseConnectionName; + } + + public void setRequestConnectionBinding(JMSBinding binding) { + this.requestConnectionBinding = binding; + } + public JMSBinding getRequestConnectionBinding() { + return requestConnectionBinding; + } + + public void setResponseConnectionBinding(JMSBinding binding) { + this.responseConnectionBinding = binding; + } + public JMSBinding getResponseConnectionBinding() { + return responseConnectionBinding; + } +} diff --git a/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java b/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java deleted file mode 100644 index 3990a55b96..0000000000 --- a/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java +++ /dev/null @@ -1,683 +0,0 @@ -/* - * 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.impl; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; - -import java.util.Map; -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.sca.assembly.xml.Constants; -import org.apache.tuscany.sca.assembly.xml.PolicyAttachPointProcessor; -import org.apache.tuscany.sca.contribution.processor.ContributionReadException; -import org.apache.tuscany.sca.contribution.processor.ContributionResolveException; -import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver; -import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.monitor.Problem.Severity; -import org.apache.tuscany.sca.policy.PolicyFactory; - -/** - * A processor to read the XML that describes the JMS binding... - * - * - * - * - * * - * ? - * - * - * * - * ? - * - * - * * - * ? - * - * - * - * * - * ? - * - * - * * - * ? - * - * - * * - * ? - * ? - * - * - * - * - * - * ? - * * - * ? - * - * - * * - * ? - * - * - * * - * - * * - * ? - * * - * - * - * @version $Rev$ $Date$ - */ - -public class JMSBindingProcessor implements StAXArtifactProcessor { - - private PolicyFactory policyFactory; - private PolicyAttachPointProcessor policyProcessor; - private Monitor monitor; - - public JMSBindingProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) { - this.policyFactory = modelFactories.getFactory(PolicyFactory.class); - this.policyProcessor = new PolicyAttachPointProcessor(policyFactory); - this.monitor = monitor; - } - - /** - * Report a error. - * - * @param problems - * @param message - * @param model - */ - private void warning(String message, Object model, Object... messageParameters) { - if (monitor != null) { - Problem problem = monitor.createProblem(this.getClass().getName(), "binding-jms-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters); - monitor.problem(problem); - } - } - - /** - * Report a error. - * - * @param problems - * @param message - * @param model - */ - private void error(String message, Object model, Object... messageParameters) { - if (monitor != null) { - Problem problem = monitor.createProblem(this.getClass().getName(), "binding-jms-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters); - monitor.problem(problem); - } - } - - public QName getArtifactType() { - return JMSBindingConstants.BINDING_JMS_QNAME; - } - - public Class getModelType() { - return JMSBinding.class; - } - - public JMSBinding read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - JMSBinding jmsBinding = new JMSBinding(); - - // Read policies - policyProcessor.readPolicies(jmsBinding, reader); - - // Read binding name - String name = reader.getAttributeValue(null, "name"); - if (name != null) { - jmsBinding.setName(name); - } - - // Read binding URI - String uri = reader.getAttributeValue(null, "uri"); - if (uri != null && uri.length() > 0) { - parseURI(uri, jmsBinding); - } - - // 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 { - error("InvalidCorrelationScheme", reader, 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 message processor class name - String messageProcessorName = reader.getAttributeValue(null, "messageProcessor"); - if (messageProcessorName != null && messageProcessorName.length() > 0) { - if ("XMLTextMessage".equalsIgnoreCase(messageProcessorName)) { - messageProcessorName = JMSBindingConstants.XML_MP_CLASSNAME; - } else if ("TextMessage".equalsIgnoreCase(messageProcessorName)) { - messageProcessorName = JMSBindingConstants.TEXT_MP_CLASSNAME; - } else if ("ObjectMessage".equalsIgnoreCase(messageProcessorName)) { - messageProcessorName = JMSBindingConstants.OBJECT_MP_CLASSNAME; - } - jmsBinding.setRequestMessageProcessorName(messageProcessorName); - jmsBinding.setResponseMessageProcessorName(messageProcessorName); - - } - - String requestConnectionName = reader.getAttributeValue(null, "requestConnection"); - if (requestConnectionName != null && requestConnectionName.length() > 0) { - jmsBinding.setRequestConnectionName(requestConnectionName); - } - String responseConnectionName = reader.getAttributeValue(null, "responseConnection"); - if (responseConnectionName != null && responseConnectionName.length() > 0) { - jmsBinding.setResponseConnectionName(responseConnectionName); - } - - // Read sub-elements of binding.jms - boolean endFound = false; - while (!endFound) { - int fg = reader.next(); - switch (fg) { - 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); - } else if ("SubscriptionHeaders".equals(elementName)) { - parseSubscriptionHeaders(reader, jmsBinding); - } - reader.next(); - break; - case END_ELEMENT: - QName x = reader.getName(); - if (x.equals(JMSBindingConstants.BINDING_JMS_QNAME)) { - endFound = true; - } else { - error("UnexpectedElement", reader, x.toString()); - } - } - } - - validate(); - - return jmsBinding; - } - - protected void parseURI(String uri, JMSBinding jmsBinding) { - if (!uri.startsWith("jms:")) { - error("MustStartWithSchema", jmsBinding, uri); - return; - } - int i = uri.indexOf('?'); - if (i >= 0) { - StringTokenizer st = new StringTokenizer(uri.substring(i+1),"&"); - while (st.hasMoreTokens()) { - String s = st.nextToken(); - if (s.startsWith("connectionFactoryName=")) { - jmsBinding.setConnectionFactoryName(s.substring(22)); - } else { - error("UnknownTokenInURI", jmsBinding, s, uri); - //throw new JMSBindingException("unknown token '" + s + "' in uri: " + uri); - return; - } - } - jmsBinding.setDestinationName(uri.substring(4, i)); - } else { - jmsBinding.setDestinationName(uri.substring(4)); - } - } - - public void resolve(JMSBinding model, ModelResolver resolver) throws ContributionResolveException { - if (model.getRequestConnectionName() != null) { - model.setRequestConnectionBinding(getConnectionBinding(model.getRequestConnectionName(), resolver)); - } - if (model.getResponseConnectionName() != null) { - model.setResponseConnectionBinding(getConnectionBinding(model.getResponseConnectionName(), resolver)); - } - } - - @SuppressWarnings("unchecked") - private JMSBinding getConnectionBinding(String bindingName, ModelResolver resolver) { - if (resolver instanceof ExtensibleModelResolver) { - DefaultModelResolver dr = (DefaultModelResolver)((ExtensibleModelResolver) resolver).getDefaultModelResolver(); - Map models = dr.getModels(); - for (Object o : models.keySet()) { - if (o instanceof JMSBinding) { - JMSBinding binding = (JMSBinding) o; - if (bindingName.equals(binding.getName())) { - return binding; - } - } - } - } - return null; - } - - public void write(JMSBinding rmiBinding, XMLStreamWriter writer) throws ContributionWriteException, - XMLStreamException { - // Write a - writer.writeStartElement(Constants.SCA10_NS, JMSBindingConstants.BINDING_JMS); - - // FIXME Implement - - writer.writeEndElement(); - } - - private 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) { - warning("DoesntProcessDestinationType", jmsBinding); - if (JMSBindingConstants.DESTINATION_TYPE_QUEUE.equalsIgnoreCase(type)) { - jmsBinding.setDestinationType(JMSBindingConstants.DESTINATION_TYPE_QUEUE); - } else if (JMSBindingConstants.DESTINATION_TYPE_TOPIC.equalsIgnoreCase(type)) { - jmsBinding.setDestinationType(JMSBindingConstants.DESTINATION_TYPE_TOPIC); - } else { - warning("InvalidDestinationType", reader, type); - } - } - - String create = reader.getAttributeValue(null, "create"); - if (create != null && create.length() > 0) { - jmsBinding.setDestinationCreate(create); - } - } - - private void parseConnectionFactory(XMLStreamReader reader, JMSBinding jmsBinding) { - String name = reader.getAttributeValue(null, "name"); - if (name != null && name.length() > 0) { - jmsBinding.setConnectionFactoryName(name); - } else { - error("MissingConnectionFactoryName", reader); - } - } - - private void parseActivationSpec(XMLStreamReader reader, JMSBinding jmsBinding) { - String name = reader.getAttributeValue(null, "name"); - if (name != null && name.length() > 0) { - warning("DoesntProcessActivationSpec", jmsBinding); - jmsBinding.setActivationSpecName(name); - } else { - warning("MissingActivationSpecName", reader); - } - } - - private void parseResponseDestination(XMLStreamReader reader, JMSBinding jmsBinding) throws XMLStreamException { - String name = reader.getAttributeValue(null, "name"); - if (name != null && name.length() > 0) { - jmsBinding.setResponseDestinationName(name); - } - - String type = reader.getAttributeValue(null, "type"); - if (type != null && type.length() > 0) { - warning("DoesntProcessResponseDestinationType", jmsBinding); - if (JMSBindingConstants.DESTINATION_TYPE_QUEUE.equalsIgnoreCase(type)) { - jmsBinding.setResponseDestinationType(JMSBindingConstants.DESTINATION_TYPE_QUEUE); - } else if (JMSBindingConstants.DESTINATION_TYPE_TOPIC.equalsIgnoreCase(type)) { - jmsBinding.setResponseDestinationType(JMSBindingConstants.DESTINATION_TYPE_TOPIC); - } else { - warning("InvalidResponseDestinationType", reader, type); - } - } - - String create = reader.getAttributeValue(null, "create"); - if (create != null && create.length() > 0) { - jmsBinding.setResponseDestinationCreate(create); - } - } - - private void parseResponseConnectionFactory(XMLStreamReader reader, JMSBinding jmsBinding) { - String name = reader.getAttributeValue(null, "name"); - if (name != null && name.length() > 0) { - warning("DoesntProcessResponseConnectionFactory", jmsBinding); - jmsBinding.setResponseConnectionFactoryName(name); - } else { - warning("MissingResponseConnectionFactory", reader); - } - } - - private void parseResponseActivationSpec(XMLStreamReader reader, JMSBinding jmsBinding) { - String name = reader.getAttributeValue(null, "name"); - if (name != null && name.length() > 0) { - warning("DoesntProcessResponseActivationSpec", jmsBinding); - jmsBinding.setResponseActivationSpecName(name); - } else { - warning("MissingResponseActivationSpec", reader); - } - } - - private void parseResponse(XMLStreamReader reader, JMSBinding jmsBinding) throws XMLStreamException { - // Read sub-elements of response - while (true) { - switch (reader.next()) { - case START_ELEMENT: - String elementName = reader.getName().getLocalPart(); - if ("destination".equals(elementName)) { - parseResponseDestination(reader, jmsBinding); - } else if ("connectionFactory".equals(elementName)) { - parseResponseConnectionFactory(reader, jmsBinding); - } else if ("activationSpec".equals(elementName)) { - parseResponseActivationSpec(reader, jmsBinding); - } - reader.next(); - break; - case END_ELEMENT: - QName x = reader.getName(); - if (x.getLocalPart().equals("response")) { - return; - } else { - error("UnexpectedResponseElement", reader, x.toString()); - } - } - } - } - - private void parseResourceAdapter(XMLStreamReader reader, JMSBinding jmsBinding) throws XMLStreamException { - warning("DoesntProcessResourceAdapter", jmsBinding); - } - - /** - * - * * - * ? - */ - private void parseHeaders(XMLStreamReader reader, JMSBinding jmsBinding) throws XMLStreamException { - - String jmsType = reader.getAttributeValue(null, "JMSType"); - if (jmsType != null && jmsType.length() > 0) { - jmsBinding.setJMSType(jmsType); - } - - String jmsCorrelationId = reader.getAttributeValue(null, "JMSCorrelationID"); - if (jmsCorrelationId != null && jmsCorrelationId.length() > 0) { - jmsBinding.setJMSCorrelationId(jmsCorrelationId); - } - - String jmsDeliveryMode = reader.getAttributeValue(null, "JMSDeliveryMode"); - if (jmsDeliveryMode != null && jmsDeliveryMode.length() > 0) { - if ("PERSISTENT".equalsIgnoreCase(jmsDeliveryMode)) { - jmsBinding.setJMSDeliveryMode(true); - } else if ("NON_PERSISTENT".equalsIgnoreCase(jmsDeliveryMode)) { - jmsBinding.setJMSDeliveryMode(false); - } else { - warning("InvalidJMSDeliveryMode", jmsBinding, jmsDeliveryMode); - } - } - - String jmsTimeToLive = reader.getAttributeValue(null, "JMSTimeToLive"); - if (jmsTimeToLive != null && jmsTimeToLive.length() > 0) { - jmsBinding.setJMSTimeToLive(Long.parseLong(jmsTimeToLive)); - } - - String jmsPriority = reader.getAttributeValue(null, "JMSPriority"); - if (jmsPriority != null && jmsPriority.length() > 0) { - int p = Integer.parseInt(jmsPriority); - if (p >= 0 && p <= 9) { - jmsBinding.setJMSPriority(p); - } else { - warning("InvalidJMSPriority", jmsBinding, jmsPriority); - } - } - - while (true) { - switch (reader.next()) { - case START_ELEMENT: - if (reader.getName().getLocalPart().equals("property")) { - parseProperty(reader, jmsBinding); - } - break; - case END_ELEMENT: - QName x = reader.getName(); - if (x.getLocalPart().equals("headers")) { - return; - } else { - error("UnexpectedResponseElement", reader, x.toString()); - } - } - } - } - - private void parseProperty(XMLStreamReader reader, JMSBinding jmsBinding) throws XMLStreamException { - String name = reader.getAttributeValue(null, "name"); - String type = reader.getAttributeValue(null, "type"); - if (name != null && name.length() > 0) { - Object value = reader.getElementText(); - if ("boolean".equalsIgnoreCase(type)) { - value = Boolean.parseBoolean((String)value); - } else if ("byte".equalsIgnoreCase(type)) { - value = Byte.parseByte(((String)value)); - } else if ("short".equalsIgnoreCase(type)) { - value = Short.parseShort((String)value); - } else if ("int".equalsIgnoreCase(type)) { - value = Integer.parseInt((String)value); - } else if ("long".equalsIgnoreCase(type)) { - value = Long.parseLong((String)value); - } else if ("float".equalsIgnoreCase(type)) { - value = Float.parseFloat((String)value); - } else if ("double".equalsIgnoreCase(type)) { - value = Double.parseDouble((String)value); - } else if ("String".equalsIgnoreCase(type)) { - // its already a string - } - jmsBinding.setProperty(name, value); - } - } - - /** - * - * * - * - * * - * ? - * * - */ - private void parseOperationProperties(XMLStreamReader reader, JMSBinding jmsBinding) throws XMLStreamException { - String opName = reader.getAttributeValue(null, "name"); - if (opName == null || opName.length() < 1) { - warning("MissingJMSOperationPropertyName", jmsBinding); - return; - } - String nativeOpName = reader.getAttributeValue(null, "nativeOperation"); - if (nativeOpName != null && nativeOpName.length() > 0) { - jmsBinding.setNativeOperationName(opName, nativeOpName); - } - - while (true) { - switch (reader.next()) { - case START_ELEMENT: - if (reader.getName().getLocalPart().equals("headers")) { - parseOperationHeaders(reader, jmsBinding, opName); - } - break; - case END_ELEMENT: - QName x = reader.getName(); - if (x.getLocalPart().equals("operationProperties")) { - return; - } else { - error("UnexpectedResponseElement", reader, x.toString()); - } - } - } - } - - private void parseOperationHeaders(XMLStreamReader reader, JMSBinding jmsBinding, String opName) throws XMLStreamException { - String jmsType = reader.getAttributeValue(null, "JMSType"); - if (jmsType != null && jmsType.length() > 0) { - jmsBinding.setOperationJMSType(opName, jmsType); - } - - String jmsCorrelationId = reader.getAttributeValue(null, "JMSCorrelationID"); - if (jmsCorrelationId != null && jmsCorrelationId.length() > 0) { - jmsBinding.setOperationJMSCorrelationId(opName, jmsCorrelationId); - } - - String jmsDeliveryMode = reader.getAttributeValue(null, "JMSDeliveryMode"); - if (jmsDeliveryMode != null && jmsDeliveryMode.length() > 0) { - if ("PERSISTENT".equalsIgnoreCase(jmsDeliveryMode)) { - jmsBinding.setJMSDeliveryMode(true); - } else if ("NON_PERSISTENT".equalsIgnoreCase(jmsDeliveryMode)) { - jmsBinding.setOperationJMSDeliveryMode(opName, false); - } else { - warning("InvalidOPJMSDeliveryMode", jmsBinding, jmsDeliveryMode); - } - } - - String jmsTimeToLive = reader.getAttributeValue(null, "JMSTimeToLive"); - if (jmsTimeToLive != null && jmsTimeToLive.length() > 0) { - jmsBinding.setOperationJMSTimeToLive(opName, Long.parseLong(jmsTimeToLive)); - } - - String jmsPriority = reader.getAttributeValue(null, "JMSPriority"); - if (jmsPriority != null && jmsPriority.length() > 0) { - int p = Integer.parseInt(jmsPriority); - if (p >= 0 && p <= 9) { - jmsBinding.setOperationJMSPriority(opName, p); - } else { - warning("InvalidOPJMSPriority", jmsBinding, jmsPriority); - } - } - - while (true) { - switch (reader.next()) { - case START_ELEMENT: - if (reader.getName().getLocalPart().equals("property")) { - parseOperationPropertyProperties(reader, jmsBinding, opName); - } - break; - case END_ELEMENT: - QName x = reader.getName(); - if (x.getLocalPart().equals("headers")) { - return; - } else { - error("UnexpectedResponseElement", reader, x.toString()); - } - } - } - } - - private void parseOperationPropertyProperties(XMLStreamReader reader, JMSBinding jmsBinding, String opName) throws XMLStreamException { - String propName = reader.getAttributeValue(null, "name"); - String type = reader.getAttributeValue(null, "type"); - if (propName != null && propName.length() > 0) { - Object value = reader.getElementText(); - if ("boolean".equalsIgnoreCase(type)) { - value = Boolean.parseBoolean((String)value); - } else if ("byte".equalsIgnoreCase(type)) { - value = Byte.parseByte(((String)value)); - } else if ("short".equalsIgnoreCase(type)) { - value = Short.parseShort((String)value); - } else if ("int".equalsIgnoreCase(type)) { - value = Integer.parseInt((String)value); - } else if ("long".equalsIgnoreCase(type)) { - value = Long.parseLong((String)value); - } else if ("float".equalsIgnoreCase(type)) { - value = Float.parseFloat((String)value); - } else if ("double".equalsIgnoreCase(type)) { - value = Double.parseDouble((String)value); - } else if ("String".equalsIgnoreCase(type)) { - // its already a string - } - jmsBinding.setOperationProperty(opName, propName, value); - } - } - - private void parseSubscriptionHeaders(XMLStreamReader reader, JMSBinding jmsBinding) { - String jmsSelector = reader.getAttributeValue(null, "JMSSelector"); - if (jmsSelector != null && jmsSelector.length() > 0) { - jmsBinding.setJMSSelector(jmsSelector); - } - } - - /** - * The validation rules for the JMS model are relatively complicated to they all live together here - */ - public void validate() throws JMSBindingException { - /* - * first fix up anything now the model has been read - */ - - /* - * Now some cross field validation - */ - - // connection factory doesn't contradict destination type - // connection factory and activation Specification are mutually exclusive - // TODO check Specification for all validations - } - -} diff --git a/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/xml/JMSBindingConstants.java b/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/xml/JMSBindingConstants.java new file mode 100644 index 0000000000..e299e54cbe --- /dev/null +++ b/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/xml/JMSBindingConstants.java @@ -0,0 +1,72 @@ +/* + * 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.xml; + +import java.util.Arrays; +import java.util.List; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.xml.Constants; + +/** + * Constants for the JMS binding. + * + * @version $Rev$ $Date$ + */ +public interface JMSBindingConstants { + + // Constants used when describing the JMS binding + // model and for setting up defaults + String BINDING_JMS = "binding.jms"; + QName BINDING_JMS_QNAME = new QName(Constants.SCA10_NS, BINDING_JMS); + String CORRELATE_MSG_ID = "requestmsgidtocorrelid"; + String CORRELATE_CORRELATION_ID = "requestcorrelidtocorrelid"; + String CORRELATE_NONE = "none"; + List VALID_CORRELATION_SCHEMES = + Arrays.asList(new String[] {CORRELATE_MSG_ID, CORRELATE_CORRELATION_ID, CORRELATE_NONE}); + String DESTINATION_TYPE_QUEUE = "queue"; // 0 + String DESTINATION_TYPE_TOPIC = "topic"; // 1 + List VALID_DESTINATION_TYPES = + Arrays.asList(new String[] {DESTINATION_TYPE_QUEUE, DESTINATION_TYPE_TOPIC}); + String CREATE_ALWAYS = "always"; + String CREATE_NEVER = "never"; + String CREATE_IF_NOT_EXIST = "ifnotexist"; + String DEFAULT_DESTINATION_NAME = "NODESTINATION"; + String DEFAULT_RESPONSE_DESTINATION_NAME = "NORESPONSEDESTINATION"; + String DEFAULT_CONNECTION_FACTORY_NAME = "ConnectionFactory"; + String DEFAULT_CONTEXT_FACTORY_NAME = "org.apache.activemq.jndi.ActiveMQInitialContextFactory"; + String DEFAULT_JNDI_URL = "tcp://localhost:61616"; + int DEFAULT_TIME_TO_LIVE = 20000; // in milliseconds + int DEFAULT_PRIORITY = 1; + int NON_PERSISTENT = 1; // Maps to javax.jms.DeliveryMode + String DEFAULT_RF_CLASSNAME = "org.apache.tuscany.sca.host.jms.activemq.JMSResourceFactoryImpl"; + String XML_MP_CLASSNAME = "org.apache.tuscany.sca.binding.jms.provider.XMLTextMessageProcessor"; + String TEXT_MP_CLASSNAME = "org.apache.tuscany.sca.binding.jms.provider.TextMessageProcessor"; + String OBJECT_MP_CLASSNAME = "org.apache.tuscany.sca.binding.jms.provider.ObjectMessageProcessor"; + String DEFAULT_MP_CLASSNAME = XML_MP_CLASSNAME; + String DEFAULT_OPERATION_PROP_NAME = "scaOperationName"; + + String FAULT_PROPERTY = "org_apache_tuscany_sca_fault"; + + String CALLBACK_ID_PROPERTY = "CallbackID"; + String CALLBACK_Q_PROPERTY = "scaCallbackQueue "; + String CONVERSATION_ID_PROPERTY = "scaConversationId"; + +} diff --git a/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/xml/JMSBindingProcessor.java b/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/xml/JMSBindingProcessor.java new file mode 100644 index 0000000000..6b39a9d8d1 --- /dev/null +++ b/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/xml/JMSBindingProcessor.java @@ -0,0 +1,688 @@ +/* + * 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.xml; + +import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; +import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; + +import java.util.Map; +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.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.assembly.xml.PolicyAttachPointProcessor; +import org.apache.tuscany.sca.binding.jms.JMSBinding; +import org.apache.tuscany.sca.binding.jms.JMSBindingException; +import org.apache.tuscany.sca.binding.jms.JMSBindingFactory; +import org.apache.tuscany.sca.contribution.processor.ContributionReadException; +import org.apache.tuscany.sca.contribution.processor.ContributionResolveException; +import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver; +import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.core.FactoryExtensionPoint; +import org.apache.tuscany.sca.monitor.Monitor; +import org.apache.tuscany.sca.monitor.Problem; +import org.apache.tuscany.sca.monitor.Problem.Severity; +import org.apache.tuscany.sca.policy.PolicyFactory; + +/** + * A processor to read the XML that describes the JMS binding... + * + * + * + * + * * + * ? + * + * + * * + * ? + * + * + * * + * ? + * + * + * + * * + * ? + * + * + * * + * ? + * + * + * * + * ? + * ? + * + * + * + * + * + * ? + * * + * ? + * + * + * * + * ? + * + * + * * + * + * * + * ? + * * + * + * + * @version $Rev$ $Date$ + */ + +public class JMSBindingProcessor implements StAXArtifactProcessor { + + private PolicyFactory policyFactory; + private PolicyAttachPointProcessor policyProcessor; + private Monitor monitor; + private JMSBindingFactory jmsBindingFactory; + + public JMSBindingProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) { + this.policyFactory = modelFactories.getFactory(PolicyFactory.class); + this.policyProcessor = new PolicyAttachPointProcessor(policyFactory); + this.jmsBindingFactory = modelFactories.getFactory(JMSBindingFactory.class); + this.monitor = monitor; + } + + /** + * Report a error. + * + * @param problems + * @param message + * @param model + */ + private void warning(String message, Object model, Object... messageParameters) { + if (monitor != null) { + Problem problem = monitor.createProblem(this.getClass().getName(), "binding-jms-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters); + monitor.problem(problem); + } + } + + /** + * Report a error. + * + * @param problems + * @param message + * @param model + */ + private void error(String message, Object model, Object... messageParameters) { + if (monitor != null) { + Problem problem = monitor.createProblem(this.getClass().getName(), "binding-jms-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters); + monitor.problem(problem); + } + } + + public QName getArtifactType() { + return JMSBindingConstants.BINDING_JMS_QNAME; + } + + public Class getModelType() { + return JMSBinding.class; + } + + public JMSBinding read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + JMSBinding jmsBinding = jmsBindingFactory.createJMSBinding(); + + // Read policies + policyProcessor.readPolicies(jmsBinding, reader); + + // Read binding name + String name = reader.getAttributeValue(null, "name"); + if (name != null) { + jmsBinding.setName(name); + } + + // Read binding URI + String uri = reader.getAttributeValue(null, "uri"); + if (uri != null && uri.length() > 0) { + parseURI(uri, jmsBinding); + } + + // 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 { + error("InvalidCorrelationScheme", reader, 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 message processor class name + String messageProcessorName = reader.getAttributeValue(null, "messageProcessor"); + if (messageProcessorName != null && messageProcessorName.length() > 0) { + if ("XMLTextMessage".equalsIgnoreCase(messageProcessorName)) { + messageProcessorName = JMSBindingConstants.XML_MP_CLASSNAME; + } else if ("TextMessage".equalsIgnoreCase(messageProcessorName)) { + messageProcessorName = JMSBindingConstants.TEXT_MP_CLASSNAME; + } else if ("ObjectMessage".equalsIgnoreCase(messageProcessorName)) { + messageProcessorName = JMSBindingConstants.OBJECT_MP_CLASSNAME; + } + jmsBinding.setRequestMessageProcessorName(messageProcessorName); + jmsBinding.setResponseMessageProcessorName(messageProcessorName); + + } + + String requestConnectionName = reader.getAttributeValue(null, "requestConnection"); + if (requestConnectionName != null && requestConnectionName.length() > 0) { + jmsBinding.setRequestConnectionName(requestConnectionName); + } + String responseConnectionName = reader.getAttributeValue(null, "responseConnection"); + if (responseConnectionName != null && responseConnectionName.length() > 0) { + jmsBinding.setResponseConnectionName(responseConnectionName); + } + + // Read sub-elements of binding.jms + boolean endFound = false; + while (!endFound) { + int fg = reader.next(); + switch (fg) { + 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); + } else if ("SubscriptionHeaders".equals(elementName)) { + parseSubscriptionHeaders(reader, jmsBinding); + } + reader.next(); + break; + case END_ELEMENT: + QName x = reader.getName(); + if (x.equals(JMSBindingConstants.BINDING_JMS_QNAME)) { + endFound = true; + } else { + error("UnexpectedElement", reader, x.toString()); + } + } + } + + validate(); + + return jmsBinding; + } + + protected void parseURI(String uri, JMSBinding jmsBinding) { + if (!uri.startsWith("jms:")) { + error("MustStartWithSchema", jmsBinding, uri); + return; + } + int i = uri.indexOf('?'); + if (i >= 0) { + StringTokenizer st = new StringTokenizer(uri.substring(i+1),"&"); + while (st.hasMoreTokens()) { + String s = st.nextToken(); + if (s.startsWith("connectionFactoryName=")) { + jmsBinding.setConnectionFactoryName(s.substring(22)); + } else { + error("UnknownTokenInURI", jmsBinding, s, uri); + //throw new JMSBindingException("unknown token '" + s + "' in uri: " + uri); + return; + } + } + jmsBinding.setDestinationName(uri.substring(4, i)); + } else { + jmsBinding.setDestinationName(uri.substring(4)); + } + } + + public void resolve(JMSBinding model, ModelResolver resolver) throws ContributionResolveException { + if (model.getRequestConnectionName() != null) { + model.setRequestConnectionBinding(getConnectionBinding(model.getRequestConnectionName(), resolver)); + } + if (model.getResponseConnectionName() != null) { + model.setResponseConnectionBinding(getConnectionBinding(model.getResponseConnectionName(), resolver)); + } + } + + @SuppressWarnings("unchecked") + private JMSBinding getConnectionBinding(String bindingName, ModelResolver resolver) { + if (resolver instanceof ExtensibleModelResolver) { + DefaultModelResolver dr = (DefaultModelResolver)((ExtensibleModelResolver) resolver).getDefaultModelResolver(); + Map models = dr.getModels(); + for (Object o : models.keySet()) { + if (o instanceof JMSBinding) { + JMSBinding binding = (JMSBinding) o; + if (bindingName.equals(binding.getName())) { + return binding; + } + } + } + } + return null; + } + + public void write(JMSBinding rmiBinding, XMLStreamWriter writer) throws ContributionWriteException, + XMLStreamException { + // Write a + writer.writeStartElement(Constants.SCA10_NS, JMSBindingConstants.BINDING_JMS); + + // FIXME Implement + + writer.writeEndElement(); + } + + private 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) { + warning("DoesntProcessDestinationType", jmsBinding); + if (JMSBindingConstants.DESTINATION_TYPE_QUEUE.equalsIgnoreCase(type)) { + jmsBinding.setDestinationType(JMSBindingConstants.DESTINATION_TYPE_QUEUE); + } else if (JMSBindingConstants.DESTINATION_TYPE_TOPIC.equalsIgnoreCase(type)) { + jmsBinding.setDestinationType(JMSBindingConstants.DESTINATION_TYPE_TOPIC); + } else { + warning("InvalidDestinationType", reader, type); + } + } + + String create = reader.getAttributeValue(null, "create"); + if (create != null && create.length() > 0) { + jmsBinding.setDestinationCreate(create); + } + } + + private void parseConnectionFactory(XMLStreamReader reader, JMSBinding jmsBinding) { + String name = reader.getAttributeValue(null, "name"); + if (name != null && name.length() > 0) { + jmsBinding.setConnectionFactoryName(name); + } else { + error("MissingConnectionFactoryName", reader); + } + } + + private void parseActivationSpec(XMLStreamReader reader, JMSBinding jmsBinding) { + String name = reader.getAttributeValue(null, "name"); + if (name != null && name.length() > 0) { + warning("DoesntProcessActivationSpec", jmsBinding); + jmsBinding.setActivationSpecName(name); + } else { + warning("MissingActivationSpecName", reader); + } + } + + private void parseResponseDestination(XMLStreamReader reader, JMSBinding jmsBinding) throws XMLStreamException { + String name = reader.getAttributeValue(null, "name"); + if (name != null && name.length() > 0) { + jmsBinding.setResponseDestinationName(name); + } + + String type = reader.getAttributeValue(null, "type"); + if (type != null && type.length() > 0) { + warning("DoesntProcessResponseDestinationType", jmsBinding); + if (JMSBindingConstants.DESTINATION_TYPE_QUEUE.equalsIgnoreCase(type)) { + jmsBinding.setResponseDestinationType(JMSBindingConstants.DESTINATION_TYPE_QUEUE); + } else if (JMSBindingConstants.DESTINATION_TYPE_TOPIC.equalsIgnoreCase(type)) { + jmsBinding.setResponseDestinationType(JMSBindingConstants.DESTINATION_TYPE_TOPIC); + } else { + warning("InvalidResponseDestinationType", reader, type); + } + } + + String create = reader.getAttributeValue(null, "create"); + if (create != null && create.length() > 0) { + jmsBinding.setResponseDestinationCreate(create); + } + } + + private void parseResponseConnectionFactory(XMLStreamReader reader, JMSBinding jmsBinding) { + String name = reader.getAttributeValue(null, "name"); + if (name != null && name.length() > 0) { + warning("DoesntProcessResponseConnectionFactory", jmsBinding); + jmsBinding.setResponseConnectionFactoryName(name); + } else { + warning("MissingResponseConnectionFactory", reader); + } + } + + private void parseResponseActivationSpec(XMLStreamReader reader, JMSBinding jmsBinding) { + String name = reader.getAttributeValue(null, "name"); + if (name != null && name.length() > 0) { + warning("DoesntProcessResponseActivationSpec", jmsBinding); + jmsBinding.setResponseActivationSpecName(name); + } else { + warning("MissingResponseActivationSpec", reader); + } + } + + private void parseResponse(XMLStreamReader reader, JMSBinding jmsBinding) throws XMLStreamException { + // Read sub-elements of response + while (true) { + switch (reader.next()) { + case START_ELEMENT: + String elementName = reader.getName().getLocalPart(); + if ("destination".equals(elementName)) { + parseResponseDestination(reader, jmsBinding); + } else if ("connectionFactory".equals(elementName)) { + parseResponseConnectionFactory(reader, jmsBinding); + } else if ("activationSpec".equals(elementName)) { + parseResponseActivationSpec(reader, jmsBinding); + } + reader.next(); + break; + case END_ELEMENT: + QName x = reader.getName(); + if (x.getLocalPart().equals("response")) { + return; + } else { + error("UnexpectedResponseElement", reader, x.toString()); + } + } + } + } + + private void parseResourceAdapter(XMLStreamReader reader, JMSBinding jmsBinding) throws XMLStreamException { + warning("DoesntProcessResourceAdapter", jmsBinding); + } + + /** + * + * * + * ? + */ + private void parseHeaders(XMLStreamReader reader, JMSBinding jmsBinding) throws XMLStreamException { + + String jmsType = reader.getAttributeValue(null, "JMSType"); + if (jmsType != null && jmsType.length() > 0) { + jmsBinding.setJMSType(jmsType); + } + + String jmsCorrelationId = reader.getAttributeValue(null, "JMSCorrelationID"); + if (jmsCorrelationId != null && jmsCorrelationId.length() > 0) { + jmsBinding.setJMSCorrelationId(jmsCorrelationId); + } + + String jmsDeliveryMode = reader.getAttributeValue(null, "JMSDeliveryMode"); + if (jmsDeliveryMode != null && jmsDeliveryMode.length() > 0) { + if ("PERSISTENT".equalsIgnoreCase(jmsDeliveryMode)) { + jmsBinding.setJMSDeliveryMode(true); + } else if ("NON_PERSISTENT".equalsIgnoreCase(jmsDeliveryMode)) { + jmsBinding.setJMSDeliveryMode(false); + } else { + warning("InvalidJMSDeliveryMode", jmsBinding, jmsDeliveryMode); + } + } + + String jmsTimeToLive = reader.getAttributeValue(null, "JMSTimeToLive"); + if (jmsTimeToLive != null && jmsTimeToLive.length() > 0) { + jmsBinding.setJMSTimeToLive(Long.parseLong(jmsTimeToLive)); + } + + String jmsPriority = reader.getAttributeValue(null, "JMSPriority"); + if (jmsPriority != null && jmsPriority.length() > 0) { + int p = Integer.parseInt(jmsPriority); + if (p >= 0 && p <= 9) { + jmsBinding.setJMSPriority(p); + } else { + warning("InvalidJMSPriority", jmsBinding, jmsPriority); + } + } + + while (true) { + switch (reader.next()) { + case START_ELEMENT: + if (reader.getName().getLocalPart().equals("property")) { + parseProperty(reader, jmsBinding); + } + break; + case END_ELEMENT: + QName x = reader.getName(); + if (x.getLocalPart().equals("headers")) { + return; + } else { + error("UnexpectedResponseElement", reader, x.toString()); + } + } + } + } + + private void parseProperty(XMLStreamReader reader, JMSBinding jmsBinding) throws XMLStreamException { + String name = reader.getAttributeValue(null, "name"); + String type = reader.getAttributeValue(null, "type"); + if (name != null && name.length() > 0) { + Object value = reader.getElementText(); + if ("boolean".equalsIgnoreCase(type)) { + value = Boolean.parseBoolean((String)value); + } else if ("byte".equalsIgnoreCase(type)) { + value = Byte.parseByte(((String)value)); + } else if ("short".equalsIgnoreCase(type)) { + value = Short.parseShort((String)value); + } else if ("int".equalsIgnoreCase(type)) { + value = Integer.parseInt((String)value); + } else if ("long".equalsIgnoreCase(type)) { + value = Long.parseLong((String)value); + } else if ("float".equalsIgnoreCase(type)) { + value = Float.parseFloat((String)value); + } else if ("double".equalsIgnoreCase(type)) { + value = Double.parseDouble((String)value); + } else if ("String".equalsIgnoreCase(type)) { + // its already a string + } + jmsBinding.setProperty(name, value); + } + } + + /** + * + * * + * + * * + * ? + * * + */ + private void parseOperationProperties(XMLStreamReader reader, JMSBinding jmsBinding) throws XMLStreamException { + String opName = reader.getAttributeValue(null, "name"); + if (opName == null || opName.length() < 1) { + warning("MissingJMSOperationPropertyName", jmsBinding); + return; + } + String nativeOpName = reader.getAttributeValue(null, "nativeOperation"); + if (nativeOpName != null && nativeOpName.length() > 0) { + jmsBinding.setNativeOperationName(opName, nativeOpName); + } + + while (true) { + switch (reader.next()) { + case START_ELEMENT: + if (reader.getName().getLocalPart().equals("headers")) { + parseOperationHeaders(reader, jmsBinding, opName); + } + break; + case END_ELEMENT: + QName x = reader.getName(); + if (x.getLocalPart().equals("operationProperties")) { + return; + } else { + error("UnexpectedResponseElement", reader, x.toString()); + } + } + } + } + + private void parseOperationHeaders(XMLStreamReader reader, JMSBinding jmsBinding, String opName) throws XMLStreamException { + String jmsType = reader.getAttributeValue(null, "JMSType"); + if (jmsType != null && jmsType.length() > 0) { + jmsBinding.setOperationJMSType(opName, jmsType); + } + + String jmsCorrelationId = reader.getAttributeValue(null, "JMSCorrelationID"); + if (jmsCorrelationId != null && jmsCorrelationId.length() > 0) { + jmsBinding.setOperationJMSCorrelationId(opName, jmsCorrelationId); + } + + String jmsDeliveryMode = reader.getAttributeValue(null, "JMSDeliveryMode"); + if (jmsDeliveryMode != null && jmsDeliveryMode.length() > 0) { + if ("PERSISTENT".equalsIgnoreCase(jmsDeliveryMode)) { + jmsBinding.setJMSDeliveryMode(true); + } else if ("NON_PERSISTENT".equalsIgnoreCase(jmsDeliveryMode)) { + jmsBinding.setOperationJMSDeliveryMode(opName, false); + } else { + warning("InvalidOPJMSDeliveryMode", jmsBinding, jmsDeliveryMode); + } + } + + String jmsTimeToLive = reader.getAttributeValue(null, "JMSTimeToLive"); + if (jmsTimeToLive != null && jmsTimeToLive.length() > 0) { + jmsBinding.setOperationJMSTimeToLive(opName, Long.parseLong(jmsTimeToLive)); + } + + String jmsPriority = reader.getAttributeValue(null, "JMSPriority"); + if (jmsPriority != null && jmsPriority.length() > 0) { + int p = Integer.parseInt(jmsPriority); + if (p >= 0 && p <= 9) { + jmsBinding.setOperationJMSPriority(opName, p); + } else { + warning("InvalidOPJMSPriority", jmsBinding, jmsPriority); + } + } + + while (true) { + switch (reader.next()) { + case START_ELEMENT: + if (reader.getName().getLocalPart().equals("property")) { + parseOperationPropertyProperties(reader, jmsBinding, opName); + } + break; + case END_ELEMENT: + QName x = reader.getName(); + if (x.getLocalPart().equals("headers")) { + return; + } else { + error("UnexpectedResponseElement", reader, x.toString()); + } + } + } + } + + private void parseOperationPropertyProperties(XMLStreamReader reader, JMSBinding jmsBinding, String opName) throws XMLStreamException { + String propName = reader.getAttributeValue(null, "name"); + String type = reader.getAttributeValue(null, "type"); + if (propName != null && propName.length() > 0) { + Object value = reader.getElementText(); + if ("boolean".equalsIgnoreCase(type)) { + value = Boolean.parseBoolean((String)value); + } else if ("byte".equalsIgnoreCase(type)) { + value = Byte.parseByte(((String)value)); + } else if ("short".equalsIgnoreCase(type)) { + value = Short.parseShort((String)value); + } else if ("int".equalsIgnoreCase(type)) { + value = Integer.parseInt((String)value); + } else if ("long".equalsIgnoreCase(type)) { + value = Long.parseLong((String)value); + } else if ("float".equalsIgnoreCase(type)) { + value = Float.parseFloat((String)value); + } else if ("double".equalsIgnoreCase(type)) { + value = Double.parseDouble((String)value); + } else if ("String".equalsIgnoreCase(type)) { + // its already a string + } + jmsBinding.setOperationProperty(opName, propName, value); + } + } + + private void parseSubscriptionHeaders(XMLStreamReader reader, JMSBinding jmsBinding) { + String jmsSelector = reader.getAttributeValue(null, "JMSSelector"); + if (jmsSelector != null && jmsSelector.length() > 0) { + jmsBinding.setJMSSelector(jmsSelector); + } + } + + /** + * The validation rules for the JMS model are relatively complicated to they all live together here + */ + public void validate() throws JMSBindingException { + /* + * first fix up anything now the model has been read + */ + + /* + * Now some cross field validation + */ + + // connection factory doesn't contradict destination type + // connection factory and activation Specification are mutually exclusive + // TODO check Specification for all validations + } + +} diff --git a/branches/sca-equinox/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.jms.JMSBindingFactory b/branches/sca-equinox/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.jms.JMSBindingFactory new file mode 100644 index 0000000000..f2d2c4bce1 --- /dev/null +++ b/branches/sca-equinox/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.jms.JMSBindingFactory @@ -0,0 +1,17 @@ +# 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. +org.apache.tuscany.sca.binding.jms.impl.JMSBindingFactoryImpl \ No newline at end of file diff --git a/branches/sca-equinox/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/branches/sca-equinox/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor index ac37a0f26b..97f1cc50be 100644 --- a/branches/sca-equinox/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor +++ b/branches/sca-equinox/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -16,4 +16,4 @@ # under the License. # Implementation class for the artifact processor extension -org.apache.tuscany.sca.binding.jms.impl.JMSBindingProcessor;qname=http://www.osoa.org/xmlns/sca/1.0#binding.jms,model=org.apache.tuscany.sca.binding.jms.impl.JMSBinding +org.apache.tuscany.sca.binding.jms.xml.JMSBindingProcessor;qname=http://www.osoa.org/xmlns/sca/1.0#binding.jms,model=org.apache.tuscany.sca.binding.jms.JMSBinding diff --git a/branches/sca-equinox/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorTestCase.java b/branches/sca-equinox/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorTestCase.java index 82fd6a5149..6d59e41534 100644 --- a/branches/sca-equinox/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorTestCase.java +++ b/branches/sca-equinox/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorTestCase.java @@ -148,7 +148,7 @@ public class JMSBindingProcessorTestCase extends TestCase { XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE)); Composite composite = (Composite)staxProcessor.read(reader); - JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0); + JMSBindingImpl binding = (JMSBindingImpl) composite.getComponents().get(0).getServices().get(0).getBindings().get(0); assertNotNull(binding); assertEquals("testQueue", binding.getDestinationName()); @@ -158,7 +158,7 @@ public class JMSBindingProcessorTestCase extends TestCase { XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(HEADERS1)); Composite composite = (Composite)staxProcessor.read(reader); - JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0); + JMSBindingImpl binding = (JMSBindingImpl) composite.getComponents().get(0).getServices().get(0).getBindings().get(0); assertNotNull(binding); assertEquals("myType", binding.getJMSType()); @@ -172,7 +172,7 @@ public class JMSBindingProcessorTestCase extends TestCase { XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(PROPERTIES1)); Composite composite = (Composite)staxProcessor.read(reader); - JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0); + JMSBindingImpl binding = (JMSBindingImpl) composite.getComponents().get(0).getServices().get(0).getBindings().get(0); assertNotNull(binding); assertEquals("bla", binding.getProperty("p1")); @@ -183,7 +183,7 @@ public class JMSBindingProcessorTestCase extends TestCase { XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(OP_PROPERTIES1)); Composite composite = (Composite)staxProcessor.read(reader); - JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0); + JMSBindingImpl binding = (JMSBindingImpl) composite.getComponents().get(0).getServices().get(0).getBindings().get(0); assertNotNull(binding); @@ -202,7 +202,7 @@ public class JMSBindingProcessorTestCase extends TestCase { XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(SELECTOR)); Composite composite = (Composite)staxProcessor.read(reader); - JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0); + JMSBindingImpl binding = (JMSBindingImpl) composite.getComponents().get(0).getServices().get(0).getBindings().get(0); assertNotNull(binding); -- cgit v1.2.3