deprecated support for JMS 1.0.2 providers

This commit is contained in:
Juergen Hoeller 2009-02-24 00:26:37 +00:00
parent 11e7ad21b0
commit 0b4e7cc5ed
18 changed files with 70 additions and 80 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -201,7 +201,7 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
* Checks for a cached Session for the given mode.
*/
protected Session getSession(Connection con, Integer mode) throws JMSException {
LinkedList<Session> sessionList = null;
LinkedList<Session> sessionList;
synchronized (this.cachedSessions) {
sessionList = this.cachedSessions.get(mode);
if (sessionList == null) {
@ -429,7 +429,7 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
/**
* Simple wrapper class around a Destination and other consumer attributes.
* Used as the key when caching consumers.
* Used as the cache key when caching MessageConsumer objects.
*/
private static class ConsumerCacheKey {

View File

@ -40,10 +40,6 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
* Connection/Session pair from the specified ConnectionFactory to the thread,
* potentially allowing for one thread-bound Session per ConnectionFactory.
*
* <p><b>NOTE:</b> This class requires a JMS 1.1+ provider because it builds on
* the domain-independent API. <b>Use the {@link JmsTransactionManager102} subclass
* for a JMS 1.0.2 provider, e.g. when running on a J2EE 1.3 server.</b>
*
* <p>This local strategy is an alternative to executing JMS operations within
* JTA transactions. Its advantage is that it is able to work in any environment,
* for example a standalone application or a test suite, with any message broker

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -39,7 +39,9 @@ import javax.jms.TopicConnectionFactory;
* @since 1.1
* @see #setConnectionFactory
* @see #setPubSubDomain
* @deprecated as of Spring 3.0, in favor of the JMS 1.1 based {@link JmsTransactionManager}
*/
@Deprecated
public class JmsTransactionManager102 extends JmsTransactionManager {
private boolean pubSubDomain = false;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,7 +22,6 @@ import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.List;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.ExceptionListener;
@ -49,8 +48,7 @@ import org.springframework.util.Assert;
*
* <p>You can either pass in a specific JMS Connection directly or let this
* factory lazily create a Connection via a given target ConnectionFactory.
* This factory generally works with JMS 1.1 as well as JMS 1.0.2; use
* {@link SingleConnectionFactory102} for strict JMS 1.0.2 only usage.
* This factory generally works with JMS 1.1 as well as the JMS 1.0.2 API.
*
* <p>Note that when using the JMS 1.0.2 API, this ConnectionFactory will switch
* into queue/topic mode according to the JMS API methods used at runtime:

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -36,7 +36,9 @@ import javax.jms.TopicConnectionFactory;
* @since 1.1
* @see #setTargetConnectionFactory
* @see #setPubSubDomain
* @deprecated as of Spring 3.0, in favor of the JMS 1.1 based {@link SingleConnectionFactory}
*/
@Deprecated
public class SingleConnectionFactory102 extends SingleConnectionFactory {
private boolean pubSubDomain = false;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -41,14 +41,10 @@ import org.springframework.util.Assert;
/**
* Helper class that simplifies synchronous JMS access code.
*
* <p><b>NOTE:</b> This class requires a JMS 1.1+ provider because it builds
* on the domain-independent API. <b>Use the {@link JmsTemplate102} subclass
* for a JMS 1.0.2 provider, e.g. when running on a J2EE 1.3 server.</b>
*
* <p>If you want to use dynamic destination creation, you must specify
* the type of JMS destination to create, using the "pubSubDomain" property.
* For other operations, this is not necessary, in contrast to when working
* with JmsTemplate102. Point-to-Point (Queues) is the default domain.
* with {@link JmsTemplate102}. Point-to-Point (Queues) is the default domain.
*
* <p>Default settings for JMS Sessions are "not transacted" and "auto-acknowledge".
* As defined by the J2EE specification, the transaction and acknowledgement
@ -83,7 +79,6 @@ import org.springframework.util.Assert;
* @see #setPubSubDomain
* @see #setDestinationResolver
* @see #setMessageConverter
* @see JmsTemplate102
* @see javax.jms.MessageProducer
* @see javax.jms.MessageConsumer
*/
@ -536,7 +531,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
}
public void send(final Destination destination, final MessageCreator messageCreator) throws JmsException {
execute(new SessionCallback() {
execute(new SessionCallback<Object>() {
public Object doInJms(Session session) throws JMSException {
doSend(session, destination, messageCreator);
return null;
@ -545,7 +540,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
}
public void send(final String destinationName, final MessageCreator messageCreator) throws JmsException {
execute(new SessionCallback() {
execute(new SessionCallback<Object>() {
public Object doInJms(Session session) throws JMSException {
Destination destination = resolveDestinationName(session, destinationName);
doSend(session, destination, messageCreator);
@ -697,16 +692,16 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
}
public Message receiveSelected(final Destination destination, final String messageSelector) throws JmsException {
return (Message) execute(new SessionCallback() {
public Object doInJms(Session session) throws JMSException {
return execute(new SessionCallback<Message>() {
public Message doInJms(Session session) throws JMSException {
return doReceive(session, destination, messageSelector);
}
}, true);
}
public Message receiveSelected(final String destinationName, final String messageSelector) throws JmsException {
return (Message) execute(new SessionCallback() {
public Object doInJms(Session session) throws JMSException {
return execute(new SessionCallback<Message>() {
public Message doInJms(Session session) throws JMSException {
Destination destination = resolveDestinationName(session, destinationName);
return doReceive(session, destination, messageSelector);
}
@ -730,7 +725,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
/**
* Actually receive a JMS message.
* @param session the JMS Session to operate on
* @param consumer the JMS MessageConsumer to send with
* @param consumer the JMS MessageConsumer to receive with
* @return the JMS Message received, or <code>null</code> if none
* @throws JMSException if thrown by JMS API methods
*/
@ -743,18 +738,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
if (resourceHolder != null && resourceHolder.hasTimeout()) {
timeout = resourceHolder.getTimeToLiveInMillis();
}
Message message = null;
if (timeout == RECEIVE_TIMEOUT_NO_WAIT) {
message = consumer.receiveNoWait();
}
else if (timeout > 0) {
message = consumer.receive(timeout);
}
else {
message = consumer.receive();
}
Message message = doReceive(consumer, timeout);
if (session.getTransacted()) {
// Commit necessary - but avoid commit call within a JTA transaction.
if (isSessionLocallyTransacted(session)) {
@ -775,6 +759,25 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
}
}
/**
* Actually receive a message from the given consumer.
* @param consumer the JMS MessageConsumer to receive with
* @param timeout the receive timeout
* @return the JMS Message received, or <code>null</code> if none
* @throws JMSException if thrown by JMS API methods
*/
private Message doReceive(MessageConsumer consumer, long timeout) throws JMSException {
if (timeout == RECEIVE_TIMEOUT_NO_WAIT) {
return consumer.receiveNoWait();
}
else if (timeout > 0) {
return consumer.receive(timeout);
}
else {
return consumer.receive();
}
}
//-------------------------------------------------------------------------
// Convenience methods for receiving auto-converted messages

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -73,7 +73,9 @@ import org.springframework.jms.support.converter.SimpleMessageConverter102;
* @see javax.jms.TopicPublisher
* @see javax.jms.QueueReceiver
* @see javax.jms.TopicSubscriber
* @deprecated as of Spring 3.0, in favor of the JMS 1.1 based {@link JmsTemplate}
*/
@Deprecated
public class JmsTemplate102 extends JmsTemplate {
/**

View File

@ -1,12 +1,12 @@
/*
* Copyright 2002-2005 the original author or authors.
*
* Copyright 2002-2009 the original author or authors.
*
* Licensed 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.
@ -31,8 +31,8 @@ import org.springframework.jms.core.JmsTemplate;
* <p>Requires a ConnectionFactory or a JmsTemplate instance to be set.
* It will create its own JmsTemplate if a ConnectionFactory is passed in.
* A custom JmsTemplate instance can be created for a given ConnectionFactory
* through overriding the <code>createJmsTemplate</code> method.
*
* through overriding the {@link #createJmsTemplate} method.
*
* @author Mark Pollack
* @since 1.1.1
* @see #setConnectionFactory
@ -42,6 +42,7 @@ import org.springframework.jms.core.JmsTemplate;
*/
public abstract class JmsGatewaySupport implements InitializingBean {
/** Logger available to subclasses */
protected final Log logger = LogFactory.getLog(getClass());
private JmsTemplate jmsTemplate;
@ -92,12 +93,12 @@ public abstract class JmsGatewaySupport implements InitializingBean {
* Return the JmsTemplate for the gateway.
*/
public final JmsTemplate getJmsTemplate() {
return jmsTemplate;
return this.jmsTemplate;
}
public final void afterPropertiesSet() throws IllegalArgumentException, BeanInitializationException {
if (this.jmsTemplate == null) {
throw new IllegalArgumentException("connectionFactory or jmsTemplate is required");
throw new IllegalArgumentException("'connectionFactory' or 'jmsTemplate' is required");
}
try {
initGateway();

View File

@ -1,7 +1,7 @@
<html>
<body>
Classes supporting the org.springframework.jms.core package.
Classes supporting the <code>org.springframework.jms.core</code> package.
Contains a base class for JmsTemplate usage.
</body>

View File

@ -43,10 +43,6 @@ import org.springframework.util.ClassUtils;
* Designed to work in a native JMS environment as well as in a J2EE environment,
* with only minimal differences in configuration.
*
* <p><b>NOTE:</b> This class requires a JMS 1.1+ provider, because it builds on
* the domain-independent API. <b>Use the {@link DefaultMessageListenerContainer102}
* subclass for a JMS 1.0.2 provider, e.g. when running on a J2EE 1.3 server.</b>
*
* <p>This is a simple but nevertheless powerful form of message listener container.
* On startup, it obtains a fixed number of JMS Sessions to invoke the listener,
* and optionally allows for dynamic adaptation at runtime (up until a maximum number).

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -41,7 +41,9 @@ import org.springframework.jms.connection.JmsResourceHolder;
*
* @author Juergen Hoeller
* @since 2.0
* @deprecated as of Spring 3.0, in favor of the JMS 1.1 based {@link DefaultMessageListenerContainer}
*/
@Deprecated
public class DefaultMessageListenerContainer102 extends DefaultMessageListenerContainer {
/**
@ -49,7 +51,7 @@ public class DefaultMessageListenerContainer102 extends DefaultMessageListenerCo
* a QueueConnection or a TopicConnection, depending on the domain.
*/
protected Connection getConnection(JmsResourceHolder holder) {
return holder.getConnection(isPubSubDomain() ? (Class) TopicConnection.class : QueueConnection.class);
return holder.getConnection(isPubSubDomain() ? TopicConnection.class : QueueConnection.class);
}
/**
@ -57,7 +59,7 @@ public class DefaultMessageListenerContainer102 extends DefaultMessageListenerCo
* a QueueSession or a TopicSession, depending on the domain.
*/
protected Session getSession(JmsResourceHolder holder) {
return holder.getSession(isPubSubDomain() ? (Class) TopicSession.class : QueueSession.class);
return holder.getSession(isPubSubDomain() ? TopicSession.class : QueueSession.class);
}
/**

View File

@ -38,10 +38,6 @@ import org.springframework.util.Assert;
* <code>MessageConsumer.setMessageListener()</code> method to
* create concurrent MessageConsumers for the specified listeners.
*
* <p><b>NOTE:</b> This class requires a JMS 1.1+ provider, because it builds on
* the domain-independent API. <b>Use the {@link SimpleMessageListenerContainer102}
* subclass for a JMS 1.0.2 provider, e.g. when running on a J2EE 1.3 server.</b>
*
* <p>This is the simplest form of a message listener container.
* It creates a fixed number of JMS Sessions to invoke the listener,
* not allowing for dynamic adaptation to runtime demands. Its main

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -39,7 +39,9 @@ import javax.jms.TopicSession;
*
* @author Juergen Hoeller
* @since 2.0
* @deprecated as of Spring 3.0, in favor of the JMS 1.1 based {@link SimpleMessageListenerContainer}
*/
@Deprecated
public class SimpleMessageListenerContainer102 extends SimpleMessageListenerContainer {
/**

View File

@ -46,16 +46,11 @@ import org.springframework.util.ObjectUtils;
* Allows listener methods to operate on message content types, completely
* independent from the JMS API.
*
* <p><b>NOTE:</b> This class requires a JMS 1.1+ provider, because it builds
* on the domain-independent API. <b>Use the {@link MessageListenerAdapter102
* MessageListenerAdapter102} subclass for JMS 1.0.2 providers.</b>
*
* <p>By default, the content of incoming JMS messages gets extracted before
* being passed into the target listener method, to let the target method
* operate on message content types such as String or byte array instead of
* the raw {@link Message}. Message type conversion is delegated to a Spring
* JMS {@link MessageConverter}. By default, a {@link SimpleMessageConverter}
* {@link org.springframework.jms.support.converter.SimpleMessageConverter102 (102)}
* will be used. (If you do not want such automatic message conversion taking
* place, then be sure to set the {@link #setMessageConverter MessageConverter}
* to <code>null</code>.)

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -41,18 +41,20 @@ import org.springframework.jms.support.converter.SimpleMessageConverter102;
* @author Juergen Hoeller
* @author Rick Evans
* @since 2.0
* @deprecated as of Spring 3.0, in favor of the JMS 1.1 based {@link MessageListenerAdapter}
*/
@Deprecated
public class MessageListenerAdapter102 extends MessageListenerAdapter {
/**
* Create a new instance of the {@link MessageListenerAdapter102} class
* Create a new instance of the MessageListenerAdapter102 class
* with the default settings.
*/
public MessageListenerAdapter102() {
}
/**
* Create a new instance of the {@link MessageListenerAdapter102} class
* Create a new instance of the MessageListenerAdapter102 class
* for the given delegate.
* @param delegate the target object to delegate message listening to
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -40,12 +40,6 @@ import org.springframework.util.ObjectUtils;
* {@link javax.jms.BytesMessage}, a Map to a {@link javax.jms.MapMessage}, and
* a Serializable object to a {@link javax.jms.ObjectMessage} (or vice versa).
*
* <p>This converter implementation works for both JMS 1.1 and JMS 1.0.2,
* except when extracting a byte array from a BytesMessage. So for converting
* BytesMessages with a JMS 1.0.2 provider, use {@link SimpleMessageConverter102}.
* (As you would expect, {@link org.springframework.jms.core.JmsTemplate102}
* uses SimpleMessageConverter102 as default.)
*
* @author Juergen Hoeller
* @since 1.1
* @see org.springframework.jms.core.JmsTemplate#convertAndSend

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -35,7 +35,9 @@ import javax.jms.JMSException;
* @author Juergen Hoeller
* @since 1.1.1
* @see javax.jms.BytesMessage#getBodyLength()
* @deprecated as of Spring 3.0, in favor of the JMS 1.1 based {@link SimpleMessageConverter}
*/
@Deprecated
public class SimpleMessageConverter102 extends SimpleMessageConverter {
public static final int BUFFER_SIZE = 4096;

View File

@ -39,15 +39,12 @@
<xsd:documentation><![CDATA[
The type of this listener container: "default" or "simple", choosing
between DefaultMessageListenerContainer and SimpleMessageListenerContainer.
The "102" suffix adapts to a JMS provider that implements JMS 1.0.2 only.
]]></xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:NMTOKEN">
<xsd:enumeration value="default"/>
<xsd:enumeration value="default102"/>
<xsd:enumeration value="simple"/>
<xsd:enumeration value="simple102"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>