summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/branches/sca-equinox/modules/binding-jms/src/main/java
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-11-11 23:09:08 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-11-11 23:09:08 +0000
commitcde3d2629677a07aa09e3c7fbe117b680c0f5df7 (patch)
treec6d50048ffad8dfa8a1c0019e7afb207cb6b4fe2 /sca-java-2.x/branches/sca-equinox/modules/binding-jms/src/main/java
parent4ef0430519e276c2bdecea75f7a0f42f49f0cf30 (diff)
Moving 2.x branches
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835133 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/branches/sca-equinox/modules/binding-jms/src/main/java')
-rw-r--r--sca-java-2.x/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java241
-rw-r--r--sca-java-2.x/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingException.java45
-rw-r--r--sca-java-2.x/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingFactory.java31
-rw-r--r--sca-java-2.x/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingFactoryImpl.java34
-rw-r--r--sca-java-2.x/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingImpl.java573
-rw-r--r--sca-java-2.x/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/xml/JMSBindingConstants.java72
-rw-r--r--sca-java-2.x/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/xml/JMSBindingProcessor.java688
7 files changed, 1684 insertions, 0 deletions
diff --git a/sca-java-2.x/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java b/sca-java-2.x/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/sca-java-2.x/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<Object> 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<String> getPropertyNames();
+
+ public Object getProperty(String name);
+
+ public void setProperty(String name, Object value);
+
+ public Map<String, Object> 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/sca-java-2.x/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingException.java b/sca-java-2.x/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/sca-java-2.x/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/sca-java-2.x/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingFactory.java b/sca-java-2.x/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/sca-java-2.x/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/sca-java-2.x/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingFactoryImpl.java b/sca-java-2.x/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/sca-java-2.x/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/sca-java-2.x/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingImpl.java b/sca-java-2.x/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/sca-java-2.x/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<Object> extensions = new ArrayList<Object>();
+
+ // 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<String, Object> properties = new HashMap<String, Object>();
+ private Map<String, Map<String, Object>> operationProperties = new HashMap<String, Map<String,Object>>();
+ private Map<String, String> nativeOperationNames = new HashMap<String, String>();
+ private Map<String, String> operationJMSTypes = new HashMap<String, String>();
+ private Map<String, String> operationJMSCorrelationIds = new HashMap<String, String>();
+ private Map<String, Boolean> operationJMSDeliveryModes = new HashMap<String, Boolean>();
+ private Map<String, Long> operationJMSTimeToLives = new HashMap<String, Long>();
+ private Map<String, Integer> operationJMSPriorities = new HashMap<String, Integer>();
+ 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<Object> getExtensions() {
+ return extensions;
+ }
+
+ // Methods for getting/setting JMS binding model information
+ // as derived from the XML of the binding.jms element
+
+ public void setCorrelationScheme(String correlationScheme) {
+ this.correlationScheme = correlationScheme;
+ }
+
+ public String getCorrelationScheme() {
+ return correlationScheme;
+ }
+
+ public String getInitialContextFactoryName() {
+ return initialContextFactoryName;
+ }
+
+ public void setInitialContextFactoryName(String initialContextFactoryName) {
+ this.initialContextFactoryName = initialContextFactoryName;
+ }
+
+ public String getJndiURL() {
+ return this.jndiURL;
+ }
+
+ public void setJndiURL(String jndiURL) {
+ this.jndiURL = jndiURL;
+ }
+
+ public String getDestinationName() {
+ 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<String> 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<String, Object> getOperationProperties(String opName) {
+ return operationProperties.get(opName);
+ }
+
+ public void setOperationProperty(String opName, String propName, Object value) {
+ Map<String, Object> props = operationProperties.get(opName);
+ if (props == null) {
+ props = new HashMap<String, Object>();
+ 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/sca-java-2.x/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/xml/JMSBindingConstants.java b/sca-java-2.x/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/sca-java-2.x/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<String> 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<String> 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/sca-java-2.x/branches/sca-equinox/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/xml/JMSBindingProcessor.java b/sca-java-2.x/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/sca-java-2.x/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...
+ *
+ * <binding.jms correlationScheme="string"?
+ * initialContextFactory="xs:anyURI"?
+ * jndiURL="xs:anyURI"?
+ * requestConnection="QName"?
+ * responseConnection="QName"?
+ * operationProperties="QName"?
+ * ...>
+ *
+ * <destination name="xs:anyURI" type="string"? create="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * </destination>?
+ *
+ * <connectionFactory name="xs:anyURI" create="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * </connectionFactory>?
+ *
+ * <activationSpec name="xs:anyURI" create="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * </activationSpec>?
+ *
+ * <response>
+ * <destination name="xs:anyURI" type="string"? create="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * </destination>?
+ *
+ * <connectionFactory name="xs:anyURI" create="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * </connectionFactory>?
+ *
+ * <activationSpec name="xs:anyURI" create="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * </activationSpec>?
+ * </response>?
+ *
+ * <complexType name="SubscriptionHeaders">
+ * <attribute name="JMSSelector" type="string"/>
+ * </complexType>
+ *
+ * <resourceAdapter name="NMTOKEN">?
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * </resourceAdapter>?
+ *
+ * <headers JMSType="string"?
+ * JMSCorrelationId="string"?
+ * JMSDeliveryMode="string"?
+ * JMSTimeToLive="int"?
+ * JMSPriority="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * </headers>?
+ *
+ * <operationProperties name="string" nativeOperation="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * <headers JMSType="string"?
+ * JMSCorrelationId="string"?
+ * JMSDeliveryMode="string"?
+ * JMSTimeToLive="int"?
+ * JMSPriority="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * </headers>?
+ * </operationProperties>*
+ * </binding.jms>
+ *
+ * @version $Rev$ $Date$
+ */
+
+public class JMSBindingProcessor implements StAXArtifactProcessor<JMSBinding> {
+
+ 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<JMSBinding> 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 <binding.jms>
+ 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);
+ }
+
+ /**
+ * <headers JMSType=�string�?
+ * JMSCorrelationID=�string�?
+ * JMSDeliveryMode=�PERSISTENT or NON_PERSISTENT�?
+ * JMSTimeToLive=�long�?
+ * JMSPriority=�0 .. 9�?>
+ * <property name=�NMTOKEN� type=�NMTOKEN�?>*
+ * </headers>?
+ */
+ 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);
+ }
+ }
+
+ /**
+ * <operationProperties name=�string� nativeOperation=�string�?>
+ * <property name=�NMTOKEN� type=�NMTOKEN�?>*
+ * <headers JMSType=�string�?
+ * JMSCorrelationId=�string�?
+ * JMSDeliveryMode=�PERSISTENT or NON_PERSISTENT�?
+ * JMSTimeToLive=�long�?
+ * JMSPriority=�0 .. 9�?>
+ * <property name=�NMTOKEN� type=�NMTOKEN�?>*
+ * </headers>?
+ * </operationProperties>*
+ */
+ 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
+ }
+
+}