summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-03-26 13:37:12 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-03-26 13:37:12 +0000
commite01c635e7679ffda1db49739993eccc406537a07 (patch)
treea6fd37d4c2a9b85b3f582bdd9f9fdeb2e5c5562c
parent5beb25c1e0965d5fa7877ae7107badff2e0b6035 (diff)
Remove these files as they are no longer required. Replaced by RRB... versions.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@758633 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultJMSBindingListener.java266
-rw-r--r--branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java472
-rw-r--r--branches/sca-java-1.x/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java5
3 files changed, 2 insertions, 741 deletions
diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultJMSBindingListener.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultJMSBindingListener.java
deleted file mode 100644
index f5c60e0bb5..0000000000
--- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultJMSBindingListener.java
+++ /dev/null
@@ -1,266 +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.provider;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-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.core.assembly.EndpointReferenceImpl;
-import org.apache.tuscany.sca.core.invocation.MessageImpl;
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.runtime.EndpointReference;
-import org.apache.tuscany.sca.runtime.ReferenceParameters;
-import org.apache.tuscany.sca.runtime.RuntimeComponentService;
-
-/**
- * Listener for the JMSBinding.
- *
- * @version $Rev$ $Date$
- */
-
-//NOTE - THIS BINDING LISTENER IS NOT LONGER ACTIVE. RRBBindingListener IS USED INSTEAD
-@Deprecated
-public class DefaultJMSBindingListener implements MessageListener {
-
- private static final Logger logger = Logger.getLogger(DefaultJMSBindingListener.class.getName());
-
- private static final String ON_MESSAGE_METHOD_NAME = "onMessage";
- private JMSBinding jmsBinding;
- private Binding targetBinding;
- private JMSResourceFactory jmsResourceFactory;
- private RuntimeComponentService service;
- private JMSMessageProcessor requestMessageProcessor;
- private JMSMessageProcessor responseMessageProcessor;
- private String correlationScheme;
- private List<Operation> serviceOperations;
- //protected JMSTokenAuthenticationPolicy jmsTokenAuthenticationPolicy = null;
-
- public DefaultJMSBindingListener(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeComponentService service, Binding targetBinding) throws NamingException {
- this.jmsBinding = jmsBinding;
- this.jmsResourceFactory = jmsResourceFactory;
- this.service = service;
- this.targetBinding = targetBinding;
- requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding);
- responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(jmsBinding);
- correlationScheme = jmsBinding.getCorrelationScheme();
- serviceOperations = service.getInterfaceContract().getInterface().getOperations();
-
- // find out which policies are active
-/*
- if (jmsBinding instanceof PolicySetAttachPoint) {
- List<PolicySet> policySets = ((PolicySetAttachPoint)jmsBinding).getApplicablePolicySets();
- for (PolicySet ps : policySets) {
- for (Object p : ps.getPolicies()) {
- if (JMSTokenAuthenticationPolicy.class.isInstance(p)) {
- jmsTokenAuthenticationPolicy = (JMSTokenAuthenticationPolicy)p;
- }else {
- // etc. check for other types of policy being present
- }
- }
- }
- }
- */
-
- }
-
- public void onMessage(Message requestJMSMsg) {
- logger.log(Level.FINE, "JMS service '" + service.getName() + "' received message " + requestJMSMsg);
- try {
- Object responsePayload = invokeService(requestJMSMsg);
- sendReply(requestJMSMsg, responsePayload, false);
- } catch (Throwable e) {
- logger.log(Level.SEVERE, "Exception invoking service '" + service.getName(), e);
- sendReply(requestJMSMsg, e, true);
- }
- }
-
- /**
- * Turn the JMS message back into a Tuscany message and invoke the target component
- *
- * @param requestJMSMsg
- * @return
- * @throws JMSException
- * @throws InvocationTargetException
- */
- protected Object invokeService(Message requestJMSMsg) throws JMSException, InvocationTargetException {
-
- String operationName = requestMessageProcessor.getOperationName(requestJMSMsg);
- Operation operation = getTargetOperation(operationName);
-
- MessageImpl tuscanyMsg = new MessageImpl();
- tuscanyMsg.setOperation(operation);
- if ("onMessage".equals(operation.getName())) {
- tuscanyMsg.setBody(new Object[]{requestJMSMsg});
- } else {
- Object requestPayload = requestMessageProcessor.extractPayloadFromJMSMessage(requestJMSMsg);
- tuscanyMsg.setBody(requestPayload);
- }
-
- setHeaderProperties(requestJMSMsg, tuscanyMsg, operation);
-
- return service.getRuntimeWire(targetBinding).invoke(operation, tuscanyMsg);
- }
-
- protected Operation getTargetOperation(String operationName) {
- Operation operation = null;
-
- if (serviceOperations.size() == 1) {
-
- // SCA JMS Binding Specification - Rule 1.5.1 line 203
- operation = serviceOperations.get(0);
-
- } else if (operationName != null) {
-
- // SCA JMS Binding Specification - Rule 1.5.1 line 205
- for (Operation op : serviceOperations) {
- if (op.getName().equals(operationName)) {
- operation = op;
- break;
- }
- }
-
- } else {
-
- // SCA JMS Binding Specification - Rule 1.5.1 line 207
- for (Operation op : serviceOperations) {
- if (op.getName().equals(ON_MESSAGE_METHOD_NAME)) {
- operation = op;
- break;
- }
- }
- }
-
- if (operation == null) {
- throw new JMSBindingException("Can't find operation " + (operationName != null ? operationName : ON_MESSAGE_METHOD_NAME));
- }
-
- return operation;
- }
-
- protected void setHeaderProperties(Message requestJMSMsg, MessageImpl tuscanyMsg, Operation operation) throws JMSException {
-
- EndpointReference from = new EndpointReferenceImpl(null);
- tuscanyMsg.setFrom(from);
- from.setCallbackEndpoint(new EndpointReferenceImpl("/")); // TODO: whats this for?
- ReferenceParameters parameters = from.getReferenceParameters();
-
- String conversationID = requestJMSMsg.getStringProperty(JMSBindingConstants.CONVERSATION_ID_PROPERTY);
- if (conversationID != null) {
- parameters.setConversationID(conversationID);
- }
-
- if (service.getInterfaceContract().getCallbackInterface() != null) {
-
- String callbackdestName = requestJMSMsg.getStringProperty(JMSBindingConstants.CALLBACK_Q_PROPERTY);
- if (callbackdestName == null && operation.isNonBlocking()) {
- // if the request has a replyTo but this service operation is oneway but the service uses callbacks
- // then use the replyTo as the callback destination
- Destination replyTo = requestJMSMsg.getJMSReplyTo();
- if (replyTo != null) {
- callbackdestName = (replyTo instanceof Queue) ? ((Queue)replyTo).getQueueName() : ((Topic)replyTo).getTopicName();
- }
- }
-
- if (callbackdestName != null) {
- // append "jms:" to make it an absolute uri so the invoker can determine it came in on the request
- // as otherwise the invoker should use the uri from the service callback binding
- parameters.setCallbackReference(new EndpointReferenceImpl("jms:" + callbackdestName));
- }
-
- String callbackID = requestJMSMsg.getStringProperty(JMSBindingConstants.CALLBACK_ID_PROPERTY);
- if (callbackID != null) {
- parameters.setCallbackID(callbackID);
- }
- }
-/*
- if (jmsTokenAuthenticationPolicy != null) {
- String token = requestJMSMsg.getStringProperty(jmsTokenAuthenticationPolicy.getTokenName().toString());
-
- Subject subject = SecurityUtil.getSubject(tuscanyMsg);
- TokenPrincipal principal = SecurityUtil.getPrincipal(subject, TokenPrincipal.class);
-
- if (principal == null){
- principal = new TokenPrincipal(token);
- subject.getPrincipals().add(principal);
- }
-
- }
-*/
- }
-
- protected void sendReply(Message requestJMSMsg, Object responsePayload, boolean isFault) {
- try {
-
- if (requestJMSMsg.getJMSReplyTo() == null) {
- // assume no reply is expected
- if (responsePayload != null) {
- logger.log(Level.FINE, "JMS service '" + service.getName() + "' dropped response as request has no replyTo");
- }
- return;
- }
-
- Session session = jmsResourceFactory.createSession();
- Message replyJMSMsg;
- if (isFault) {
- replyJMSMsg = responseMessageProcessor.createFaultMessage(session, (Throwable)responsePayload);
- } else {
- replyJMSMsg = responseMessageProcessor.insertPayloadIntoJMSMessage(session, responsePayload);
- }
-
- replyJMSMsg.setJMSDeliveryMode(requestJMSMsg.getJMSDeliveryMode());
- replyJMSMsg.setJMSPriority(requestJMSMsg.getJMSPriority());
-
- if (correlationScheme == null || JMSBindingConstants.CORRELATE_MSG_ID.equalsIgnoreCase(correlationScheme)) {
- replyJMSMsg.setJMSCorrelationID(requestJMSMsg.getJMSMessageID());
- } else if (JMSBindingConstants.CORRELATE_CORRELATION_ID.equalsIgnoreCase(correlationScheme)) {
- replyJMSMsg.setJMSCorrelationID(requestJMSMsg.getJMSCorrelationID());
- }
-
- Destination destination = requestJMSMsg.getJMSReplyTo();
- MessageProducer producer = session.createProducer(destination);
-
- producer.send(replyJMSMsg);
-
- producer.close();
- session.close();
-
- } catch (JMSException e) {
- throw new JMSBindingException(e);
- } catch (NamingException e) {
- throw new JMSBindingException(e);
- }
- }
-
-}
diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java
deleted file mode 100644
index 07e1380bba..0000000000
--- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java
+++ /dev/null
@@ -1,472 +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.provider;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-import java.util.Map;
-
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.naming.NamingException;
-import javax.security.auth.Subject;
-
-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.interfacedef.Operation;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
-import org.apache.tuscany.sca.invocation.DataExchangeSemantics;
-import org.apache.tuscany.sca.invocation.Invoker;
-import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
-import org.apache.tuscany.sca.runtime.ReferenceParameters;
-import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
-import org.apache.tuscany.sca.runtime.RuntimeComponentService;
-import org.osoa.sca.ServiceRuntimeException;
-
-/**
- * Invoker for the JMS binding.
- *
- *
- * @version $Rev$ $Date$
- */
-
-// NOTE - THIS BINDING INVOKER IS NOT LONGER ACTIVE. RRBBindingInvoker IS USED INSTEAD
-@Deprecated
-public class JMSBindingInvoker implements Invoker, DataExchangeSemantics {
-
- protected Operation operation;
- protected String operationName;
-
- protected JMSBinding jmsBinding;
- protected JMSResourceFactory jmsResourceFactory;
- protected JMSMessageProcessor requestMessageProcessor;
- protected JMSMessageProcessor responseMessageProcessor;
- protected Destination bindingRequestDest;
- protected Destination bindingReplyDest;
- protected RuntimeComponentReference reference;
- //protected JMSTokenAuthenticationPolicy jmsTokenAuthenticationPolicy = null;
- //protected JMSHeaderPolicy jmsHeaderPolicy = null;
-
- public JMSBindingInvoker(JMSBinding jmsBinding, Operation operation, JMSResourceFactory jmsResourceFactory, RuntimeComponentReference reference) {
-
- this.operation = operation;
- operationName = operation.getName();
-
- this.jmsBinding = jmsBinding;
- this.jmsResourceFactory = jmsResourceFactory;
- this.reference = reference;
- this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding);
- this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(jmsBinding);
-
- // find out which policies are active
-/*
- if (jmsBinding instanceof PolicySetAttachPoint) {
- List<PolicySet> policySets = ((PolicySetAttachPoint)jmsBinding).getApplicablePolicySets();
- for (PolicySet ps : policySets) {
- for (Object p : ps.getPolicies()) {
- if (JMSTokenAuthenticationPolicy.class.isInstance(p)) {
- jmsTokenAuthenticationPolicy = (JMSTokenAuthenticationPolicy)p;
- }else if (JMSTokenAuthenticationPolicy.class.isInstance(p)) {
- jmsHeaderPolicy = (JMSHeaderPolicy)p;
- } else {
- // etc. check for other types of policy being present
- }
- }
- }
- }
-*/
-
- try {
-
- bindingRequestDest = lookupDestination();
- bindingReplyDest = lookupResponseDestination();
-
- } catch (NamingException e) {
- throw new JMSBindingException(e);
- }
-
- }
-
- /**
- * Looks up the Destination Queue for the JMS Binding
- *
- * @return The Destination Queue
- * @throws NamingException Failed to lookup Destination Queue
- * @throws JMSBindingException Failed to lookup Destination Queue
- * @see #lookupDestinationQueue(boolean)
- */
- protected Destination lookupDestination() throws NamingException, JMSBindingException {
- return lookupDestinationQueue(false);
- }
-
- /**
- * Looks up the Destination Response Queue for the JMS Binding
- *
- * @return The Destination Response Queue
- * @throws NamingException Failed to lookup Destination Response Queue
- * @throws JMSBindingException Failed to lookup Destination Response Queue
- * @see #lookupDestinationQueue(boolean)
- */
- protected Destination lookupResponseDestination() throws NamingException, JMSBindingException {
- return lookupDestinationQueue(true);
- }
-
- /**
- * Looks up the Destination Queue for the JMS Binding.
- * <p>
- * What happens in the look up will depend on the create mode specified for the JMS Binding:
- * <ul>
- * <li>always - the JMS queue is always created. It is an error if the queue already exists
- * <li>ifnotexist - the JMS queue is created if it does not exist. It is not an error if the queue already exists
- * <li>never - the JMS queue is never created. It is an error if the queue does not exist
- * </ul>
- * See the SCA JMS Binding specification for more information.
- * <p>
- *
- * @param isReponseQueue <code>true</code> if we are creating a response queue.
- * <code>false</code> if we are creating a request queue
- * @return The Destination queue.
- * @throws NamingException Failed to lookup JMS queue
- * @throws JMSBindingException Failed to lookup JMS Queue. Probable cause is that
- * the JMS queue's current existence/non-existence is not compatible with
- * the create mode specified on the binding
- */
- protected Destination lookupDestinationQueue(boolean isReponseQueue) throws NamingException, JMSBindingException {
- String queueName;
- String queueType;
- String qCreateMode;
-
- if (isReponseQueue) {
- queueName = jmsBinding.getResponseDestinationName();
- queueType = "JMS Response Destination ";
- qCreateMode = jmsBinding.getResponseDestinationCreate();
- if (queueName == null) {
- return null;
- }
- } else {
- queueName = jmsBinding.getDestinationName();
- queueType = "JMS Destination ";
- qCreateMode = jmsBinding.getDestinationCreate();
- }
-
- Destination dest = jmsResourceFactory.lookupDestination(queueName);
-
- if (qCreateMode.equals(JMSBindingConstants.CREATE_ALWAYS)) {
- // In this mode, the queue must not already exist as we are creating it
- if (dest != null) {
- throw new JMSBindingException(queueType + queueName
- + " already exists but has create mode of \""
- + qCreateMode
- + "\" while registering binding "
- + jmsBinding.getName()
- + " invoker");
- }
- // Create the queue
- dest = jmsResourceFactory.createDestination(queueName);
-
- } else if (qCreateMode.equals(JMSBindingConstants.CREATE_IF_NOT_EXIST)) {
- // In this mode, the queue may nor may not exist. It will be created if it does not exist
- if (dest == null) {
- dest = jmsResourceFactory.createDestination(queueName);
- }
-
- } else if (qCreateMode.equals(JMSBindingConstants.CREATE_NEVER)) {
- // In this mode, the queue must have already been created.
- if (dest == null) {
- throw new JMSBindingException(queueType + queueName
- + " not found but create mode of \""
- + qCreateMode
- + "\" while registering binding "
- + jmsBinding.getName()
- + " invoker");
- }
- }
-
- // Make sure we ended up with a queue
- if (dest == null) {
- throw new JMSBindingException(queueType + queueName
- + " not found with create mode of \""
- + qCreateMode
- + "\" while registering binding "
- + jmsBinding.getName()
- + " invoker");
- }
-
- return dest;
- }
-
- public org.apache.tuscany.sca.invocation.Message invoke(org.apache.tuscany.sca.invocation.Message tuscanyMsg) {
- try {
-
- Object resp = invokeTarget(tuscanyMsg);
- tuscanyMsg.setBody(resp);
-
- } catch (InvocationTargetException e) {
- tuscanyMsg.setFaultBody(e.getCause());
- } catch (ServiceRuntimeException e) {
- if (e.getCause() instanceof InvocationTargetException) {
- if ((e.getCause().getCause() instanceof RuntimeException)) {
- tuscanyMsg.setFaultBody(e.getCause());
- } else {
- tuscanyMsg.setFaultBody(e.getCause().getCause());
- }
- } else {
- tuscanyMsg.setFaultBody(e);
- }
- } catch (Throwable e) {
- tuscanyMsg.setFaultBody(e);
- }
- return tuscanyMsg;
- }
-
- protected Object invokeTarget(org.apache.tuscany.sca.invocation.Message tuscanyMsg) throws InvocationTargetException {
- try {
- Session session = jmsResourceFactory.createSession();
- try {
-
- Destination replyToDest = getReplyToDestination(session);
-
- Message requestMsg = sendRequest(tuscanyMsg, session, replyToDest);
-
- if (replyToDest == null) {
- return null;
- } else {
- Message replyMsg = receiveReply(session, replyToDest, requestMsg.getJMSMessageID());
- Object[] response = (Object[])responseMessageProcessor.extractPayloadFromJMSMessage(replyMsg);
- return (response != null && response.length > 0) ? response[0] : null;
- }
-
- } finally {
- session.close();
- }
- } catch (JMSException e) {
- throw new InvocationTargetException(e);
- } catch (NamingException e) {
- throw new InvocationTargetException(e);
- }
- }
-
- protected Destination getReplyToDestination(Session session) throws JMSException, JMSBindingException, NamingException {
- Destination replyToDest;
- if (operation.isNonBlocking()) {
- replyToDest = null;
- } else {
- if (bindingReplyDest != null) {
- replyToDest = bindingReplyDest;
- } else {
- replyToDest = session.createTemporaryQueue();
- }
- }
- return replyToDest;
- }
-
- protected Message sendRequest(org.apache.tuscany.sca.invocation.Message tuscanyMsg, Session session, Destination replyToDest) throws JMSException, JMSBindingException,
- NamingException {
-
- Message requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, tuscanyMsg.getBody());
-
- setHeaders(tuscanyMsg, requestMsg);
-
- requestMsg.setJMSReplyTo(replyToDest);
-
- Destination requestDest = getRequestDestination(tuscanyMsg, session);
-
- MessageProducer producer = session.createProducer(requestDest);
-
- if (jmsBinding.getOperationJMSTimeToLive(operationName) != null) {
- producer.setTimeToLive(jmsBinding.getOperationJMSTimeToLive(operationName));
- }
-
- try {
- producer.send(requestMsg);
- } finally {
- producer.close();
- }
- return requestMsg;
- }
-
- protected Destination getRequestDestination(org.apache.tuscany.sca.invocation.Message tuscanyMsg, Session session) throws JMSBindingException, NamingException, JMSException {
- Destination requestDestination;
- if (reference.isCallback()) {
- String toURI = tuscanyMsg.getTo().getURI();
- if (toURI != null && toURI.startsWith("jms:")) {
- // the msg to uri contains the callback destination name
- // this is an jms physical name not a jndi name so need to use session.createQueue
- requestDestination = session.createQueue(toURI.substring(4));
- } else {
- requestDestination = lookupDestination();
- }
- } else {
- requestDestination = bindingRequestDest;
- }
-
- return requestDestination;
- }
-
- protected void setHeaders(org.apache.tuscany.sca.invocation.Message tuscanyMsg, Message jmsMsg) throws JMSException {
-
- requestMessageProcessor.setOperationName(jmsBinding.getNativeOperationName(operationName), jmsMsg);
-/*
- if ((jmsHeaderPolicy != null) &&
- (jmsHeaderPolicy.getDeliveryModePersistent() != null)) {
- if (jmsHeaderPolicy.getDeliveryModePersistent()) {
- jmsMsg.setJMSDeliveryMode(DeliveryMode.PERSISTENT);
- } else {
- jmsMsg.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
- }
-
- } else if (jmsBinding.getOperationJMSDeliveryMode(operationName) != null) {
- if (jmsBinding.getOperationJMSDeliveryMode(operationName)) {
- jmsMsg.setJMSDeliveryMode(DeliveryMode.PERSISTENT);
- } else {
- jmsMsg.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
- }
- }
-
- if ((jmsHeaderPolicy != null) &&
- (jmsHeaderPolicy.getJmsCorrelationId() != null)) {
- jmsMsg.setJMSCorrelationID(jmsHeaderPolicy.getJmsCorrelationId());
- } else if (jmsBinding.getOperationJMSCorrelationId(operationName) != null) {
- jmsMsg.setJMSCorrelationID(jmsBinding.getOperationJMSCorrelationId(operationName));
- }
-
- if ((jmsHeaderPolicy != null) &&
- (jmsHeaderPolicy.getJmsPriority() != null)) {
- jmsMsg.setJMSPriority(jmsHeaderPolicy.getJmsPriority());
- } else if (jmsBinding.getOperationJMSPriority(operationName) != null) {
- jmsMsg.setJMSPriority(jmsBinding.getOperationJMSPriority(operationName));
- }
-
- if ((jmsHeaderPolicy != null) &&
- (jmsHeaderPolicy.getJmsType() != null)) {
- jmsMsg.setJMSType(jmsHeaderPolicy.getJmsType());
- } else if (jmsBinding.getOperationJMSType(operationName) != null) {
- jmsMsg.setJMSType(jmsBinding.getOperationJMSType(operationName));
- }
-
- ReferenceParameters parameters = tuscanyMsg.getFrom().getReferenceParameters();
-
- Object conversationID = parameters.getConversationID();
- if (conversationID != null) {
- jmsMsg.setStringProperty(JMSBindingConstants.CONVERSATION_ID_PROPERTY, conversationID.toString());
- }
-
- if (hasCallback()) {
-
- if (parameters.getCallbackID() != null) {
- jmsMsg.setStringProperty(JMSBindingConstants.CALLBACK_ID_PROPERTY, parameters.getCallbackID().toString());
- }
-
- String callbackDestName = getCallbackDestinationName(reference);
- if (callbackDestName != null) {
- jmsMsg.setStringProperty(JMSBindingConstants.CALLBACK_Q_PROPERTY, callbackDestName);
- }
- }
-
-
- if (jmsHeaderPolicy != null){
- for (String propName : jmsHeaderPolicy.getProperties().keySet()) {
- jmsMsg.setObjectProperty(propName, jmsHeaderPolicy.getProperties().get(propName));
- }
- }
-*/
-
- for (String propName : jmsBinding.getPropertyNames()) {
- Object value = jmsBinding.getProperty(propName);
- jmsMsg.setObjectProperty(propName, value);
- }
-
- Map<String, Object> operationProperties = jmsBinding.getOperationProperties(operationName);
- if (operationProperties != null) {
- for (String propName : operationProperties.keySet()) {
- Object value = operationProperties.get(propName);
- jmsMsg.setObjectProperty(propName, value);
- }
- }
-/*
- if (jmsTokenAuthenticationPolicy != null) {
- Subject subject = SecurityUtil.getSubject(tuscanyMsg);
- TokenPrincipal principal = SecurityUtil.getPrincipal(subject, TokenPrincipal.class);
- if (principal != null){
- jmsMsg.setStringProperty(jmsTokenAuthenticationPolicy.getTokenName().toString(), principal.getName());
- }
- }
-*/
- }
-
- protected boolean hasCallback() {
- if (operation.getInterface() instanceof JavaInterface) {
- JavaInterface jiface = (JavaInterface)operation.getInterface();
- if (jiface.getCallbackClass() != null) {
- return true;
- }
- }
- return false;
- }
-
- protected Message receiveReply(Session session, Destination replyToDest, String requestMsgId) throws JMSException, NamingException {
- String msgSelector = "JMSCorrelationID = '" + requestMsgId + "'";
- MessageConsumer consumer = session.createConsumer(replyToDest, msgSelector);
-
- long receiveWait;
- /* if ((jmsHeaderPolicy != null) &&
- (jmsHeaderPolicy.getTimeToLive() != null)) {
- receiveWait = jmsHeaderPolicy.getTimeToLive();
- } else */if (jmsBinding.getOperationJMSTimeToLive(operationName) != null) {
- receiveWait = jmsBinding.getOperationJMSTimeToLive(operationName) * 2;
- } else {
- receiveWait = JMSBindingConstants.DEFAULT_TIME_TO_LIVE;
- }
-
- Message replyMsg;
- try {
- jmsResourceFactory.startConnection();
- replyMsg = consumer.receive(receiveWait);
- } finally {
- consumer.close();
- }
- if (replyMsg == null) {
- throw new JMSBindingException("No reply message received on " + replyToDest + " for message id " + requestMsgId);
- }
- return replyMsg;
- }
-
- protected String getCallbackDestinationName(RuntimeComponentReference reference) {
- RuntimeComponentService s = (RuntimeComponentService)reference.getCallbackService();
- JMSBinding b = s.getBinding(JMSBinding.class);
- if (b != null) {
- JMSBindingServiceBindingProvider bp = (JMSBindingServiceBindingProvider)s.getBindingProvider(b);
- return bp.getDestinationName();
- }
- return null;
- }
-
- public boolean allowsPassByReference() {
- // JMS always pass by value
- return true;
- }
-
-}
diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java
index 1cf8edb6a6..efd64361dd 100644
--- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java
+++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java
@@ -24,7 +24,6 @@ import java.util.List;
import javax.jms.TextMessage;
import org.apache.tuscany.sca.binding.jms.impl.JMSBinding;
-import org.apache.tuscany.sca.binding.jms.provider.DefaultJMSBindingListener;
import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
import org.apache.tuscany.sca.interfacedef.Interface;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
@@ -204,7 +203,7 @@ public class OperationSelectionTestCaseFIXME {
.andReturn(operationReturnValue);
// Create the JMS Binding Listener
- final DefaultJMSBindingListener bindingListener = new DefaultJMSBindingListener(jmsBinding, jmsResourceFactory, service, null);
+ // final DefaultJMSBindingListener bindingListener = new DefaultJMSBindingListener(jmsBinding, jmsResourceFactory, service, null);
// Simulate a message
final TextMessage requestJMSMsg = EasyMock.createStrictMock(TextMessage.class);
@@ -220,7 +219,7 @@ public class OperationSelectionTestCaseFIXME {
EasyMock.replay(runtimeWire);
// Do the test
- bindingListener.onMessage(requestJMSMsg);
+ // bindingListener.onMessage(requestJMSMsg);
// Verify our Mock objects
// EasyMock.verify(iface);