Skip to content
Permalink
Browse files
CXF-5543 Make jms independent of spring. First part
git-svn-id: https://svn.apache.org/repos/asf/cxf/trunk@1564952 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
cschneider committed Feb 5, 2014
1 parent 5c21f5a commit 35aa26c8b8a2f8cc5899c6a5616a113ba1e9900d
Show file tree
Hide file tree
Showing 41 changed files with 2,404 additions and 2,499 deletions.
@@ -72,7 +72,7 @@
<cxf.osgi.javax.xml.ws.version>[0.0,3)</cxf.osgi.javax.xml.ws.version>
<!-- please maintain alphabetical order here -->
<cxf.abdera.version>1.1.3</cxf.abdera.version>
<cxf.activemq.version>5.8.0</cxf.activemq.version>
<cxf.activemq.version>5.9.0</cxf.activemq.version>
<cxf.axiom.version>1.2.14</cxf.axiom.version>
<cxf.bcprov.version>1.50</cxf.bcprov.version>
<cxf.cglib.bundle.version>2.2_2</cxf.cglib.bundle.version>
@@ -0,0 +1,89 @@
/**
* 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.cxf.transport.jms;

import java.io.IOException;
import java.util.logging.Logger;

import javax.jms.TextMessage;

import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.message.Exchange;
import org.apache.cxf.message.Message;
import org.apache.cxf.transport.AbstractConduit;
import org.apache.cxf.transport.MessageObserver;
import org.apache.cxf.ws.addressing.EndpointReferenceType;

/**
* Conduit for sending the reply back to the client
*/
class BackChannelConduit extends AbstractConduit {
private static final Logger LOG = LogUtils.getL7dLogger(JMSDestination.class);
protected Message inMessage;
private JMSExchangeSender sender;

BackChannelConduit(JMSExchangeSender sender, EndpointReferenceType ref, Message message) {
super(ref);
inMessage = message;
this.sender = sender;
}
@Override
public void close(Message msg) throws IOException {
MessageStreamUtil.closeStreams(msg);
super.close(msg);
}

/**
* Register a message observer for incoming messages.
*
* @param observer the observer to notify on receipt of incoming
*/
public void setMessageObserver(MessageObserver observer) {
// shouldn't be called for a back channel conduit
}

/**
* Send an outbound message, assumed to contain all the name-value mappings of the corresponding input
* message (if any).
*
* @param message the message to be sent.
*/
public void prepare(final Message message) throws IOException {
// setup the message to be sent back
javax.jms.Message jmsMessage = (javax.jms.Message)inMessage
.get(JMSConstants.JMS_REQUEST_MESSAGE);
message.put(JMSConstants.JMS_REQUEST_MESSAGE, jmsMessage);

if (!message.containsKey(JMSConstants.JMS_SERVER_RESPONSE_HEADERS)
&& inMessage.containsKey(JMSConstants.JMS_SERVER_RESPONSE_HEADERS)) {
message.put(JMSConstants.JMS_SERVER_RESPONSE_HEADERS, inMessage
.get(JMSConstants.JMS_SERVER_RESPONSE_HEADERS));
}

final Exchange exchange = inMessage.getExchange();
exchange.setOutMessage(message);

boolean isTextMessage = (jmsMessage instanceof TextMessage) && !JMSMessageUtils.isMtomEnabled(message);
MessageStreamUtil.prepareStream(message, isTextMessage, sender);
}

protected Logger getLogger() {
return LOG;
}
}
@@ -31,21 +31,17 @@
import javax.resource.spi.endpoint.MessageEndpointFactory;
import javax.transaction.xa.XAResource;

import org.apache.cxf.service.model.EndpointInfo;
import org.springframework.jms.listener.DefaultMessageListenerContainer;
import org.springframework.jms.support.JmsUtils;

public class JCATransactionalMessageListenerContainer extends DefaultMessageListenerContainer {
static final ThreadLocal<Map<Class<?>, ?>> ENDPOINT_LOCAL = new ThreadLocal<Map<Class<?>, ?>>();
static final String MESSAGE_ENDPOINT_FACTORY = "MessageEndpointFactory";
static final String MDB_TRANSACTED_METHOD = "MDBTransactedMethod";
private MessageEndpointFactory factory;
private Method method;

public JCATransactionalMessageListenerContainer(EndpointInfo ei) {
factory = ei.getProperty(MESSAGE_ENDPOINT_FACTORY,
MessageEndpointFactory.class);
method = ei.getProperty(MDB_TRANSACTED_METHOD, Method.class);
public JCATransactionalMessageListenerContainer(MessageEndpointFactory factory, Method transactedMethod) {
this.factory = factory;
this.method = transactedMethod;
this.setCacheLevel(CACHE_CONNECTION);
}

@@ -68,7 +64,7 @@ protected boolean receiveAndExecute(Object invoker, Session session, MessageCons
mp.put(MessageEndpoint.class, ep);

ENDPOINT_LOCAL.set(mp);
ep.beforeDelivery(method);
ep.beforeDelivery(this.method);
messageReceived = doReceiveAndExecute(invoker, s, mc, null);
ep.afterDelivery();
} catch (Exception ex) {

0 comments on commit 35aa26c

Please sign in to comment.