Skip to content

Commit 0b4e7cc

Browse files
committed
deprecated support for JMS 1.0.2 providers
1 parent 11e7ad2 commit 0b4e7cc

18 files changed

+70
-80
lines changed

org.springframework.jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2008 the original author or authors.
2+
* Copyright 2002-2009 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -201,7 +201,7 @@ public void resetConnection() {
201201
* Checks for a cached Session for the given mode.
202202
*/
203203
protected Session getSession(Connection con, Integer mode) throws JMSException {
204-
LinkedList<Session> sessionList = null;
204+
LinkedList<Session> sessionList;
205205
synchronized (this.cachedSessions) {
206206
sessionList = this.cachedSessions.get(mode);
207207
if (sessionList == null) {
@@ -429,7 +429,7 @@ private void physicalClose() throws JMSException {
429429

430430
/**
431431
* Simple wrapper class around a Destination and other consumer attributes.
432-
* Used as the key when caching consumers.
432+
* Used as the cache key when caching MessageConsumer objects.
433433
*/
434434
private static class ConsumerCacheKey {
435435

org.springframework.jms/src/main/java/org/springframework/jms/connection/JmsTransactionManager.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@
4040
* Connection/Session pair from the specified ConnectionFactory to the thread,
4141
* potentially allowing for one thread-bound Session per ConnectionFactory.
4242
*
43-
* <p><b>NOTE:</b> This class requires a JMS 1.1+ provider because it builds on
44-
* the domain-independent API. <b>Use the {@link JmsTransactionManager102} subclass
45-
* for a JMS 1.0.2 provider, e.g. when running on a J2EE 1.3 server.</b>
46-
*
4743
* <p>This local strategy is an alternative to executing JMS operations within
4844
* JTA transactions. Its advantage is that it is able to work in any environment,
4945
* for example a standalone application or a test suite, with any message broker

org.springframework.jms/src/main/java/org/springframework/jms/connection/JmsTransactionManager102.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2007 the original author or authors.
2+
* Copyright 2002-2009 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,7 +39,9 @@
3939
* @since 1.1
4040
* @see #setConnectionFactory
4141
* @see #setPubSubDomain
42+
* @deprecated as of Spring 3.0, in favor of the JMS 1.1 based {@link JmsTransactionManager}
4243
*/
44+
@Deprecated
4345
public class JmsTransactionManager102 extends JmsTransactionManager {
4446

4547
private boolean pubSubDomain = false;

org.springframework.jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2008 the original author or authors.
2+
* Copyright 2002-2009 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@
2222
import java.lang.reflect.Proxy;
2323
import java.util.ArrayList;
2424
import java.util.List;
25-
2625
import javax.jms.Connection;
2726
import javax.jms.ConnectionFactory;
2827
import javax.jms.ExceptionListener;
@@ -49,8 +48,7 @@
4948
*
5049
* <p>You can either pass in a specific JMS Connection directly or let this
5150
* factory lazily create a Connection via a given target ConnectionFactory.
52-
* This factory generally works with JMS 1.1 as well as JMS 1.0.2; use
53-
* {@link SingleConnectionFactory102} for strict JMS 1.0.2 only usage.
51+
* This factory generally works with JMS 1.1 as well as the JMS 1.0.2 API.
5452
*
5553
* <p>Note that when using the JMS 1.0.2 API, this ConnectionFactory will switch
5654
* into queue/topic mode according to the JMS API methods used at runtime:

org.springframework.jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory102.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2007 the original author or authors.
2+
* Copyright 2002-2009 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,7 +36,9 @@
3636
* @since 1.1
3737
* @see #setTargetConnectionFactory
3838
* @see #setPubSubDomain
39+
* @deprecated as of Spring 3.0, in favor of the JMS 1.1 based {@link SingleConnectionFactory}
3940
*/
41+
@Deprecated
4042
public class SingleConnectionFactory102 extends SingleConnectionFactory {
4143

4244
private boolean pubSubDomain = false;

org.springframework.jms/src/main/java/org/springframework/jms/core/JmsTemplate.java

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2008 the original author or authors.
2+
* Copyright 2002-2009 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -41,14 +41,10 @@
4141
/**
4242
* Helper class that simplifies synchronous JMS access code.
4343
*
44-
* <p><b>NOTE:</b> This class requires a JMS 1.1+ provider because it builds
45-
* on the domain-independent API. <b>Use the {@link JmsTemplate102} subclass
46-
* for a JMS 1.0.2 provider, e.g. when running on a J2EE 1.3 server.</b>
47-
*
4844
* <p>If you want to use dynamic destination creation, you must specify
4945
* the type of JMS destination to create, using the "pubSubDomain" property.
5046
* For other operations, this is not necessary, in contrast to when working
51-
* with JmsTemplate102. Point-to-Point (Queues) is the default domain.
47+
* with {@link JmsTemplate102}. Point-to-Point (Queues) is the default domain.
5248
*
5349
* <p>Default settings for JMS Sessions are "not transacted" and "auto-acknowledge".
5450
* As defined by the J2EE specification, the transaction and acknowledgement
@@ -83,7 +79,6 @@
8379
* @see #setPubSubDomain
8480
* @see #setDestinationResolver
8581
* @see #setMessageConverter
86-
* @see JmsTemplate102
8782
* @see javax.jms.MessageProducer
8883
* @see javax.jms.MessageConsumer
8984
*/
@@ -536,7 +531,7 @@ public void send(MessageCreator messageCreator) throws JmsException {
536531
}
537532

538533
public void send(final Destination destination, final MessageCreator messageCreator) throws JmsException {
539-
execute(new SessionCallback() {
534+
execute(new SessionCallback<Object>() {
540535
public Object doInJms(Session session) throws JMSException {
541536
doSend(session, destination, messageCreator);
542537
return null;
@@ -545,7 +540,7 @@ public Object doInJms(Session session) throws JMSException {
545540
}
546541

547542
public void send(final String destinationName, final MessageCreator messageCreator) throws JmsException {
548-
execute(new SessionCallback() {
543+
execute(new SessionCallback<Object>() {
549544
public Object doInJms(Session session) throws JMSException {
550545
Destination destination = resolveDestinationName(session, destinationName);
551546
doSend(session, destination, messageCreator);
@@ -697,16 +692,16 @@ public Message receiveSelected(String messageSelector) throws JmsException {
697692
}
698693

699694
public Message receiveSelected(final Destination destination, final String messageSelector) throws JmsException {
700-
return (Message) execute(new SessionCallback() {
701-
public Object doInJms(Session session) throws JMSException {
695+
return execute(new SessionCallback<Message>() {
696+
public Message doInJms(Session session) throws JMSException {
702697
return doReceive(session, destination, messageSelector);
703698
}
704699
}, true);
705700
}
706701

707702
public Message receiveSelected(final String destinationName, final String messageSelector) throws JmsException {
708-
return (Message) execute(new SessionCallback() {
709-
public Object doInJms(Session session) throws JMSException {
703+
return execute(new SessionCallback<Message>() {
704+
public Message doInJms(Session session) throws JMSException {
710705
Destination destination = resolveDestinationName(session, destinationName);
711706
return doReceive(session, destination, messageSelector);
712707
}
@@ -730,7 +725,7 @@ protected Message doReceive(Session session, Destination destination, String mes
730725
/**
731726
* Actually receive a JMS message.
732727
* @param session the JMS Session to operate on
733-
* @param consumer the JMS MessageConsumer to send with
728+
* @param consumer the JMS MessageConsumer to receive with
734729
* @return the JMS Message received, or <code>null</code> if none
735730
* @throws JMSException if thrown by JMS API methods
736731
*/
@@ -743,18 +738,7 @@ protected Message doReceive(Session session, MessageConsumer consumer) throws JM
743738
if (resourceHolder != null && resourceHolder.hasTimeout()) {
744739
timeout = resourceHolder.getTimeToLiveInMillis();
745740
}
746-
747-
Message message = null;
748-
if (timeout == RECEIVE_TIMEOUT_NO_WAIT) {
749-
message = consumer.receiveNoWait();
750-
}
751-
else if (timeout > 0) {
752-
message = consumer.receive(timeout);
753-
}
754-
else {
755-
message = consumer.receive();
756-
}
757-
741+
Message message = doReceive(consumer, timeout);
758742
if (session.getTransacted()) {
759743
// Commit necessary - but avoid commit call within a JTA transaction.
760744
if (isSessionLocallyTransacted(session)) {
@@ -775,6 +759,25 @@ else if (isClientAcknowledge(session)) {
775759
}
776760
}
777761

762+
/**
763+
* Actually receive a message from the given consumer.
764+
* @param consumer the JMS MessageConsumer to receive with
765+
* @param timeout the receive timeout
766+
* @return the JMS Message received, or <code>null</code> if none
767+
* @throws JMSException if thrown by JMS API methods
768+
*/
769+
private Message doReceive(MessageConsumer consumer, long timeout) throws JMSException {
770+
if (timeout == RECEIVE_TIMEOUT_NO_WAIT) {
771+
return consumer.receiveNoWait();
772+
}
773+
else if (timeout > 0) {
774+
return consumer.receive(timeout);
775+
}
776+
else {
777+
return consumer.receive();
778+
}
779+
}
780+
778781

779782
//-------------------------------------------------------------------------
780783
// Convenience methods for receiving auto-converted messages

org.springframework.jms/src/main/java/org/springframework/jms/core/JmsTemplate102.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2008 the original author or authors.
2+
* Copyright 2002-2009 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -73,7 +73,9 @@
7373
* @see javax.jms.TopicPublisher
7474
* @see javax.jms.QueueReceiver
7575
* @see javax.jms.TopicSubscriber
76+
* @deprecated as of Spring 3.0, in favor of the JMS 1.1 based {@link JmsTemplate}
7677
*/
78+
@Deprecated
7779
public class JmsTemplate102 extends JmsTemplate {
7880

7981
/**

org.springframework.jms/src/main/java/org/springframework/jms/core/support/JmsGatewaySupport.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*
2-
* Copyright 2002-2005 the original author or authors.
3-
*
2+
* Copyright 2002-2009 the original author or authors.
3+
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
7-
*
7+
*
88
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
9+
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,8 +31,8 @@
3131
* <p>Requires a ConnectionFactory or a JmsTemplate instance to be set.
3232
* It will create its own JmsTemplate if a ConnectionFactory is passed in.
3333
* A custom JmsTemplate instance can be created for a given ConnectionFactory
34-
* through overriding the <code>createJmsTemplate</code> method.
35-
*
34+
* through overriding the {@link #createJmsTemplate} method.
35+
*
3636
* @author Mark Pollack
3737
* @since 1.1.1
3838
* @see #setConnectionFactory
@@ -42,6 +42,7 @@
4242
*/
4343
public abstract class JmsGatewaySupport implements InitializingBean {
4444

45+
/** Logger available to subclasses */
4546
protected final Log logger = LogFactory.getLog(getClass());
4647

4748
private JmsTemplate jmsTemplate;
@@ -92,12 +93,12 @@ public final void setJmsTemplate(JmsTemplate jmsTemplate) {
9293
* Return the JmsTemplate for the gateway.
9394
*/
9495
public final JmsTemplate getJmsTemplate() {
95-
return jmsTemplate;
96+
return this.jmsTemplate;
9697
}
9798

9899
public final void afterPropertiesSet() throws IllegalArgumentException, BeanInitializationException {
99100
if (this.jmsTemplate == null) {
100-
throw new IllegalArgumentException("connectionFactory or jmsTemplate is required");
101+
throw new IllegalArgumentException("'connectionFactory' or 'jmsTemplate' is required");
101102
}
102103
try {
103104
initGateway();

org.springframework.jms/src/main/java/org/springframework/jms/core/support/package.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<html>
22
<body>
33

4-
Classes supporting the org.springframework.jms.core package.
4+
Classes supporting the <code>org.springframework.jms.core</code> package.
55
Contains a base class for JmsTemplate usage.
66

77
</body>

org.springframework.jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@
4343
* Designed to work in a native JMS environment as well as in a J2EE environment,
4444
* with only minimal differences in configuration.
4545
*
46-
* <p><b>NOTE:</b> This class requires a JMS 1.1+ provider, because it builds on
47-
* the domain-independent API. <b>Use the {@link DefaultMessageListenerContainer102}
48-
* subclass for a JMS 1.0.2 provider, e.g. when running on a J2EE 1.3 server.</b>
49-
*
5046
* <p>This is a simple but nevertheless powerful form of message listener container.
5147
* On startup, it obtains a fixed number of JMS Sessions to invoke the listener,
5248
* and optionally allows for dynamic adaptation at runtime (up until a maximum number).

0 commit comments

Comments
 (0)