diff --git a/spring-jms/src/main/java/org/springframework/jms/connection/JmsTransactionManager.java b/spring-jms/src/main/java/org/springframework/jms/connection/JmsTransactionManager.java index ebd78180183..656500c5c12 100644 --- a/spring-jms/src/main/java/org/springframework/jms/connection/JmsTransactionManager.java +++ b/spring-jms/src/main/java/org/springframework/jms/connection/JmsTransactionManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 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. @@ -270,10 +270,6 @@ public class JmsTransactionManager extends AbstractPlatformTransactionManager } - //------------------------------------------------------------------------- - // JMS 1.1 factory methods, potentially overridden for JMS 1.0.2 - //------------------------------------------------------------------------- - /** * Create a JMS Connection via this template's ConnectionFactory. *
This implementation uses JMS 1.1 API. diff --git a/spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java b/spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java index 21e8af20c73..5d37c668c0c 100644 --- a/spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java +++ b/spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 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. @@ -393,7 +393,7 @@ public class SingleConnectionFactory /** * Create a default Session for this ConnectionFactory, - * adaptign to JMS 1.0.2 style queue/topic mode if necessary. + * adapting to JMS 1.0.2 style queue/topic mode if necessary. * @param con the JMS Connection to operate on * @param mode the Session acknowledgement mode * ({@code Session.TRANSACTED} or one of the common modes) diff --git a/spring-jms/src/main/java/org/springframework/jms/core/JmsOperations.java b/spring-jms/src/main/java/org/springframework/jms/core/JmsOperations.java index 152617ee020..3fb1eb3e1b6 100644 --- a/spring-jms/src/main/java/org/springframework/jms/core/JmsOperations.java +++ b/spring-jms/src/main/java/org/springframework/jms/core/JmsOperations.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 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. @@ -45,9 +45,6 @@ public interface JmsOperations { /** * Execute the action specified by the given action object within a JMS Session. - *
When used with a 1.0.2 provider, you may need to downcast - * to the appropriate domain implementation, either QueueSession or - * TopicSession in the action objects doInJms callback method. * @param action callback object that exposes the session * @return the result object from working with the session * @throws JmsException if there is any problem diff --git a/spring-jms/src/main/java/org/springframework/jms/core/JmsTemplate.java b/spring-jms/src/main/java/org/springframework/jms/core/JmsTemplate.java index ede604b68a3..8ed0cb266a8 100644 --- a/spring-jms/src/main/java/org/springframework/jms/core/JmsTemplate.java +++ b/spring-jms/src/main/java/org/springframework/jms/core/JmsTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 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. @@ -295,7 +295,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations /** * Set whether to inhibit the delivery of messages published by its own connection. * Default is "false". - * @see javax.jms.TopicSession#createSubscriber(javax.jms.Topic, String, boolean) + * @see javax.jms.Session#createConsumer(javax.jms.Destination, String, boolean) */ public void setPubSubNoLocal(boolean pubSubNoLocal) { this.pubSubNoLocal = pubSubNoLocal; @@ -966,10 +966,6 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations } - //------------------------------------------------------------------------- - // JMS 1.1 factory methods, potentially overridden for JMS 1.0.2 - //------------------------------------------------------------------------- - /** * Fetch an appropriate Connection from the given JmsResourceHolder. *
This implementation accepts any JMS 1.1 Connection. @@ -1013,7 +1009,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations * Create a JMS MessageProducer for the given Session and Destination, * configuring it to disable message ids and/or timestamps (if necessary). *
Delegates to {@link #doCreateProducer} for creation of the raw - * JMS MessageProducer, which needs to be specific to JMS 1.1 or 1.0.2. + * JMS MessageProducer. * @param session the JMS Session to create a MessageProducer for * @param destination the JMS Destination to create a MessageProducer for * @return the new JMS MessageProducer @@ -1071,7 +1067,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations * Create a JMS MessageProducer for the given Session and Destination, * configuring it to disable message ids and/or timestamps (if necessary). *
Delegates to {@link #doCreateProducer} for creation of the raw - * JMS MessageProducer, which needs to be specific to JMS 1.1 or 1.0.2. + * JMS MessageProducer. * @param session the JMS Session to create a QueueBrowser for * @param queue the JMS Queue to create a QueueBrowser for * @param messageSelector the message selector for this consumer (can be {@code null}) diff --git a/spring-jms/src/main/java/org/springframework/jms/core/ProducerCallback.java b/spring-jms/src/main/java/org/springframework/jms/core/ProducerCallback.java index 6541f116a06..6297b67983e 100644 --- a/spring-jms/src/main/java/org/springframework/jms/core/ProducerCallback.java +++ b/spring-jms/src/main/java/org/springframework/jms/core/ProducerCallback.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 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. @@ -27,10 +27,7 @@ import javax.jms.Session; * argument, often implemented as an anonymous inner class. * *
The typical implementation will perform multiple operations on the - * supplied JMS {@link Session} and {@link MessageProducer}. When used with - * a 1.0.2 provider, you need to downcast to the appropriate domain - * implementation, either {@link javax.jms.QueueSender} or - * {@link javax.jms.TopicPublisher}, to actually send a message. + * supplied JMS {@link Session} and {@link MessageProducer}. * * @author Mark Pollack * @since 1.1 diff --git a/spring-jms/src/main/java/org/springframework/jms/remoting/JmsInvokerClientInterceptor.java b/spring-jms/src/main/java/org/springframework/jms/remoting/JmsInvokerClientInterceptor.java index 66c1d794902..1de257e1094 100644 --- a/spring-jms/src/main/java/org/springframework/jms/remoting/JmsInvokerClientInterceptor.java +++ b/spring-jms/src/main/java/org/springframework/jms/remoting/JmsInvokerClientInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 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. @@ -24,10 +24,6 @@ import javax.jms.MessageConsumer; import javax.jms.MessageFormatException; import javax.jms.MessageProducer; import javax.jms.Queue; -import javax.jms.QueueConnection; -import javax.jms.QueueConnectionFactory; -import javax.jms.QueueSender; -import javax.jms.QueueSession; import javax.jms.Session; import javax.jms.TemporaryQueue; @@ -48,7 +44,6 @@ import org.springframework.remoting.support.DefaultRemoteInvocationFactory; import org.springframework.remoting.support.RemoteInvocation; import org.springframework.remoting.support.RemoteInvocationFactory; import org.springframework.remoting.support.RemoteInvocationResult; -import org.springframework.util.ClassUtils; /** * {@link org.aopalliance.intercept.MethodInterceptor} for accessing a @@ -75,8 +70,6 @@ import org.springframework.util.ClassUtils; */ public class JmsInvokerClientInterceptor implements MethodInterceptor, InitializingBean { - private static final boolean jms11Available = ClassUtils.hasMethod(ConnectionFactory.class, "createConnection"); - private ConnectionFactory connectionFactory; private Object queue; @@ -263,25 +256,14 @@ public class JmsInvokerClientInterceptor implements MethodInterceptor, Initializ * Create a new JMS Connection for this JMS invoker. */ protected Connection createConnection() throws JMSException { - ConnectionFactory cf = getConnectionFactory(); - if (jms11Available) { - return cf.createConnection(); - } - else { - return ((QueueConnectionFactory) cf).createQueueConnection(); - } + return getConnectionFactory().createConnection(); } /** * Create a new JMS Session for this JMS invoker. */ protected Session createSession(Connection con) throws JMSException { - if (jms11Available) { - return con.createSession(false, Session.AUTO_ACKNOWLEDGE); - } - else { - return ((QueueConnection) con).createQueueSession(false, Session.AUTO_ACKNOWLEDGE); - } + return con.createSession(false, Session.AUTO_ACKNOWLEDGE); } /** @@ -345,25 +327,11 @@ public class JmsInvokerClientInterceptor implements MethodInterceptor, Initializ MessageProducer producer = null; MessageConsumer consumer = null; try { - if (jms11Available) { - // Standard JMS 1.1 API usage... - responseQueue = session.createTemporaryQueue(); - producer = session.createProducer(queue); - consumer = session.createConsumer(responseQueue); - requestMessage.setJMSReplyTo(responseQueue); - producer.send(requestMessage); - } - else { - // Perform all calls on QueueSession reference for JMS 1.0.2 compatibility... - // DEPRECATED but kept around with the deprecated JmsTemplate102 etc classes for the time being. - QueueSession queueSession = (QueueSession) session; - responseQueue = queueSession.createTemporaryQueue(); - QueueSender sender = queueSession.createSender(queue); - producer = sender; - consumer = queueSession.createReceiver(responseQueue); - requestMessage.setJMSReplyTo(responseQueue); - sender.send(requestMessage); - } + responseQueue = session.createTemporaryQueue(); + producer = session.createProducer(queue); + consumer = session.createConsumer(responseQueue); + requestMessage.setJMSReplyTo(responseQueue); + producer.send(requestMessage); long timeout = getReceiveTimeout(); return (timeout > 0 ? consumer.receive(timeout) : consumer.receive()); } diff --git a/spring-jms/src/main/java/org/springframework/jms/support/JmsAccessor.java b/spring-jms/src/main/java/org/springframework/jms/support/JmsAccessor.java index d5ab2143053..8b8c507f0c8 100644 --- a/spring-jms/src/main/java/org/springframework/jms/support/JmsAccessor.java +++ b/spring-jms/src/main/java/org/springframework/jms/support/JmsAccessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 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. @@ -109,7 +109,7 @@ public abstract class JmsAccessor implements InitializingBean { * Set the JMS acknowledgement mode by the name of the corresponding constant * in the JMS {@link Session} interface, e.g. "CLIENT_ACKNOWLEDGE". *
If you want to use vendor-specific extensions to the acknowledgment mode, - * use {@link #setSessionAcknowledgeModeName(String)} instead. + * use {@link #setSessionAcknowledgeMode(int)} instead. * @param constantName the name of the {@link Session} acknowledge mode constant * @see javax.jms.Session#AUTO_ACKNOWLEDGE * @see javax.jms.Session#CLIENT_ACKNOWLEDGE @@ -125,8 +125,8 @@ public abstract class JmsAccessor implements InitializingBean { * {@link Session} to send a message. *
Default is {@link Session#AUTO_ACKNOWLEDGE}. *
Vendor-specific extensions to the acknowledgment mode can be set here as well. - *
Note that that inside an EJB the parameters to - * create(Queue/Topic)Session(boolean transacted, int acknowledgeMode) method + *
Note that that inside an EJB, the parameters to the + * {@code create(Queue/Topic)Session(boolean transacted, int acknowledgeMode)} method * are not taken into account. Depending on the transaction context in the EJB, * the container makes its own decisions on these values. See section 17.3.5 * of the EJB spec. @@ -169,11 +169,6 @@ public abstract class JmsAccessor implements InitializingBean { return JmsUtils.convertJmsAccessException(ex); } - - //------------------------------------------------------------------------- - // JMS 1.1 factory methods, potentially overridden for JMS 1.0.2 - //------------------------------------------------------------------------- - /** * Create a JMS Connection via this template's ConnectionFactory. *
This implementation uses JMS 1.1 API. diff --git a/spring-jms/src/main/java/org/springframework/jms/support/destination/DynamicDestinationResolver.java b/spring-jms/src/main/java/org/springframework/jms/support/destination/DynamicDestinationResolver.java index 7f6450fffe5..7efbf9c6c76 100644 --- a/spring-jms/src/main/java/org/springframework/jms/support/destination/DynamicDestinationResolver.java +++ b/spring-jms/src/main/java/org/springframework/jms/support/destination/DynamicDestinationResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 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. @@ -19,10 +19,8 @@ package org.springframework.jms.support.destination; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.Queue; -import javax.jms.QueueSession; import javax.jms.Session; import javax.jms.Topic; -import javax.jms.TopicSession; import org.springframework.util.Assert; @@ -30,15 +28,8 @@ import org.springframework.util.Assert; * Simple {@link DestinationResolver} implementation resolving destination names * as dynamic destinations. * - *
This implementation will work on both JMS 1.1 and JMS 1.0.2, - * because it uses the {@link javax.jms.QueueSession} or {@link javax.jms.TopicSession} - * methods if possible, falling back to JMS 1.1's generic {@link javax.jms.Session} - * methods. - * * @author Juergen Hoeller * @since 1.1 - * @see javax.jms.QueueSession#createQueue - * @see javax.jms.TopicSession#createTopic * @see javax.jms.Session#createQueue * @see javax.jms.Session#createTopic */ @@ -78,14 +69,7 @@ public class DynamicDestinationResolver implements DestinationResolver { * @see Session#createTopic(String) */ protected Topic resolveTopic(Session session, String topicName) throws JMSException { - if (session instanceof TopicSession) { - // Cast to TopicSession: will work on both JMS 1.1 and 1.0.2 - return ((TopicSession) session).createTopic(topicName); - } - else { - // Fall back to generic JMS Session: will only work on JMS 1.1 - return session.createTopic(topicName); - } + return session.createTopic(topicName); } /** @@ -97,14 +81,7 @@ public class DynamicDestinationResolver implements DestinationResolver { * @see Session#createQueue(String) */ protected Queue resolveQueue(Session session, String queueName) throws JMSException { - if (session instanceof QueueSession) { - // Cast to QueueSession: will work on both JMS 1.1 and 1.0.2 - return ((QueueSession) session).createQueue(queueName); - } - else { - // Fall back to generic JMS Session: will only work on JMS 1.1 - return session.createQueue(queueName); - } + return session.createQueue(queueName); } } diff --git a/spring-jms/src/main/java/org/springframework/jms/support/destination/JmsDestinationAccessor.java b/spring-jms/src/main/java/org/springframework/jms/support/destination/JmsDestinationAccessor.java index c93c2cd06f7..46c0bd4cdb2 100644 --- a/spring-jms/src/main/java/org/springframework/jms/support/destination/JmsDestinationAccessor.java +++ b/spring-jms/src/main/java/org/springframework/jms/support/destination/JmsDestinationAccessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 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. @@ -66,10 +66,8 @@ public abstract class JmsDestinationAccessor extends JmsAccessor { /** * Configure the destination accessor with knowledge of the JMS domain used. * Default is Point-to-Point (Queues). - *
For JMS 1.0.2 based accessors, this tells the JMS provider which class hierarchy - * to use in the implementation of its operations. For JMS 1.1 based accessors, this - * setting does usually not affect operations. However, for both JMS versions, this - * setting tells what type of destination to resolve if dynamic destinations are enabled. + *
This setting primarily indicates what type of destination to resolve + * if dynamic destinations are enabled. * @param pubSubDomain "true" for the Publish/Subscribe domain ({@link javax.jms.Topic Topics}), * "false" for the Point-to-Point domain ({@link javax.jms.Queue Queues}) * @see #setDestinationResolver