Browse Source

Consistent removal of JMS 1.0.2 references

pull/599/head
Juergen Hoeller 12 years ago
parent
commit
3be190df6a
  1. 6
      spring-jms/src/main/java/org/springframework/jms/connection/JmsTransactionManager.java
  2. 4
      spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java
  3. 5
      spring-jms/src/main/java/org/springframework/jms/core/JmsOperations.java
  4. 12
      spring-jms/src/main/java/org/springframework/jms/core/JmsTemplate.java
  5. 7
      spring-jms/src/main/java/org/springframework/jms/core/ProducerCallback.java
  6. 48
      spring-jms/src/main/java/org/springframework/jms/remoting/JmsInvokerClientInterceptor.java
  7. 13
      spring-jms/src/main/java/org/springframework/jms/support/JmsAccessor.java
  8. 29
      spring-jms/src/main/java/org/springframework/jms/support/destination/DynamicDestinationResolver.java
  9. 8
      spring-jms/src/main/java/org/springframework/jms/support/destination/JmsDestinationAccessor.java

6
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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. * Create a JMS Connection via this template's ConnectionFactory.
* <p>This implementation uses JMS 1.1 API. * <p>This implementation uses JMS 1.1 API.

4
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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, * 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 con the JMS Connection to operate on
* @param mode the Session acknowledgement mode * @param mode the Session acknowledgement mode
* ({@code Session.TRANSACTED} or one of the common modes) * ({@code Session.TRANSACTED} or one of the common modes)

5
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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. * Execute the action specified by the given action object within a JMS Session.
* <p>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 * @param action callback object that exposes the session
* @return the result object from working with the session * @return the result object from working with the session
* @throws JmsException if there is any problem * @throws JmsException if there is any problem

12
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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. * Set whether to inhibit the delivery of messages published by its own connection.
* Default is "false". * 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) { public void setPubSubNoLocal(boolean pubSubNoLocal) {
this.pubSubNoLocal = 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. * Fetch an appropriate Connection from the given JmsResourceHolder.
* <p>This implementation accepts any JMS 1.1 Connection. * <p>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, * Create a JMS MessageProducer for the given Session and Destination,
* configuring it to disable message ids and/or timestamps (if necessary). * configuring it to disable message ids and/or timestamps (if necessary).
* <p>Delegates to {@link #doCreateProducer} for creation of the raw * <p>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 session the JMS Session to create a MessageProducer for
* @param destination the JMS Destination to create a MessageProducer for * @param destination the JMS Destination to create a MessageProducer for
* @return the new JMS MessageProducer * @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, * Create a JMS MessageProducer for the given Session and Destination,
* configuring it to disable message ids and/or timestamps (if necessary). * configuring it to disable message ids and/or timestamps (if necessary).
* <p>Delegates to {@link #doCreateProducer} for creation of the raw * <p>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 session the JMS Session to create a QueueBrowser for
* @param queue the JMS Queue 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}) * @param messageSelector the message selector for this consumer (can be {@code null})

7
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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. * argument, often implemented as an anonymous inner class.
* *
* <p>The typical implementation will perform multiple operations on the * <p>The typical implementation will perform multiple operations on the
* supplied JMS {@link Session} and {@link MessageProducer}. When used with * supplied JMS {@link Session} and {@link MessageProducer}.
* 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.
* *
* @author Mark Pollack * @author Mark Pollack
* @since 1.1 * @since 1.1

48
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.MessageFormatException;
import javax.jms.MessageProducer; import javax.jms.MessageProducer;
import javax.jms.Queue; 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.Session;
import javax.jms.TemporaryQueue; 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.RemoteInvocation;
import org.springframework.remoting.support.RemoteInvocationFactory; import org.springframework.remoting.support.RemoteInvocationFactory;
import org.springframework.remoting.support.RemoteInvocationResult; import org.springframework.remoting.support.RemoteInvocationResult;
import org.springframework.util.ClassUtils;
/** /**
* {@link org.aopalliance.intercept.MethodInterceptor} for accessing a * {@link org.aopalliance.intercept.MethodInterceptor} for accessing a
@ -75,8 +70,6 @@ import org.springframework.util.ClassUtils;
*/ */
public class JmsInvokerClientInterceptor implements MethodInterceptor, InitializingBean { public class JmsInvokerClientInterceptor implements MethodInterceptor, InitializingBean {
private static final boolean jms11Available = ClassUtils.hasMethod(ConnectionFactory.class, "createConnection");
private ConnectionFactory connectionFactory; private ConnectionFactory connectionFactory;
private Object queue; private Object queue;
@ -263,25 +256,14 @@ public class JmsInvokerClientInterceptor implements MethodInterceptor, Initializ
* Create a new JMS Connection for this JMS invoker. * Create a new JMS Connection for this JMS invoker.
*/ */
protected Connection createConnection() throws JMSException { protected Connection createConnection() throws JMSException {
ConnectionFactory cf = getConnectionFactory(); return getConnectionFactory().createConnection();
if (jms11Available) {
return cf.createConnection();
}
else {
return ((QueueConnectionFactory) cf).createQueueConnection();
}
} }
/** /**
* Create a new JMS Session for this JMS invoker. * Create a new JMS Session for this JMS invoker.
*/ */
protected Session createSession(Connection con) throws JMSException { protected Session createSession(Connection con) throws JMSException {
if (jms11Available) { return con.createSession(false, Session.AUTO_ACKNOWLEDGE);
return con.createSession(false, Session.AUTO_ACKNOWLEDGE);
}
else {
return ((QueueConnection) con).createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
}
} }
/** /**
@ -345,25 +327,11 @@ public class JmsInvokerClientInterceptor implements MethodInterceptor, Initializ
MessageProducer producer = null; MessageProducer producer = null;
MessageConsumer consumer = null; MessageConsumer consumer = null;
try { try {
if (jms11Available) { responseQueue = session.createTemporaryQueue();
// Standard JMS 1.1 API usage... producer = session.createProducer(queue);
responseQueue = session.createTemporaryQueue(); consumer = session.createConsumer(responseQueue);
producer = session.createProducer(queue); requestMessage.setJMSReplyTo(responseQueue);
consumer = session.createConsumer(responseQueue); producer.send(requestMessage);
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);
}
long timeout = getReceiveTimeout(); long timeout = getReceiveTimeout();
return (timeout > 0 ? consumer.receive(timeout) : consumer.receive()); return (timeout > 0 ? consumer.receive(timeout) : consumer.receive());
} }

13
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * Set the JMS acknowledgement mode by the name of the corresponding constant
* in the JMS {@link Session} interface, e.g. "CLIENT_ACKNOWLEDGE". * in the JMS {@link Session} interface, e.g. "CLIENT_ACKNOWLEDGE".
* <p>If you want to use vendor-specific extensions to the acknowledgment mode, * <p>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 * @param constantName the name of the {@link Session} acknowledge mode constant
* @see javax.jms.Session#AUTO_ACKNOWLEDGE * @see javax.jms.Session#AUTO_ACKNOWLEDGE
* @see javax.jms.Session#CLIENT_ACKNOWLEDGE * @see javax.jms.Session#CLIENT_ACKNOWLEDGE
@ -125,8 +125,8 @@ public abstract class JmsAccessor implements InitializingBean {
* {@link Session} to send a message. * {@link Session} to send a message.
* <p>Default is {@link Session#AUTO_ACKNOWLEDGE}. * <p>Default is {@link Session#AUTO_ACKNOWLEDGE}.
* <p>Vendor-specific extensions to the acknowledgment mode can be set here as well. * <p>Vendor-specific extensions to the acknowledgment mode can be set here as well.
* <p>Note that that inside an EJB the parameters to * <p>Note that that inside an EJB, the parameters to the
* create(Queue/Topic)Session(boolean transacted, int acknowledgeMode) method * {@code create(Queue/Topic)Session(boolean transacted, int acknowledgeMode)} method
* are not taken into account. Depending on the transaction context in the EJB, * 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 * the container makes its own decisions on these values. See section 17.3.5
* of the EJB spec. * of the EJB spec.
@ -169,11 +169,6 @@ public abstract class JmsAccessor implements InitializingBean {
return JmsUtils.convertJmsAccessException(ex); 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. * Create a JMS Connection via this template's ConnectionFactory.
* <p>This implementation uses JMS 1.1 API. * <p>This implementation uses JMS 1.1 API.

29
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.Destination;
import javax.jms.JMSException; import javax.jms.JMSException;
import javax.jms.Queue; import javax.jms.Queue;
import javax.jms.QueueSession;
import javax.jms.Session; import javax.jms.Session;
import javax.jms.Topic; import javax.jms.Topic;
import javax.jms.TopicSession;
import org.springframework.util.Assert; import org.springframework.util.Assert;
@ -30,15 +28,8 @@ import org.springframework.util.Assert;
* Simple {@link DestinationResolver} implementation resolving destination names * Simple {@link DestinationResolver} implementation resolving destination names
* as dynamic destinations. * as dynamic destinations.
* *
* <p>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 * @author Juergen Hoeller
* @since 1.1 * @since 1.1
* @see javax.jms.QueueSession#createQueue
* @see javax.jms.TopicSession#createTopic
* @see javax.jms.Session#createQueue * @see javax.jms.Session#createQueue
* @see javax.jms.Session#createTopic * @see javax.jms.Session#createTopic
*/ */
@ -78,14 +69,7 @@ public class DynamicDestinationResolver implements DestinationResolver {
* @see Session#createTopic(String) * @see Session#createTopic(String)
*/ */
protected Topic resolveTopic(Session session, String topicName) throws JMSException { protected Topic resolveTopic(Session session, String topicName) throws JMSException {
if (session instanceof TopicSession) { return session.createTopic(topicName);
// 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);
}
} }
/** /**
@ -97,14 +81,7 @@ public class DynamicDestinationResolver implements DestinationResolver {
* @see Session#createQueue(String) * @see Session#createQueue(String)
*/ */
protected Queue resolveQueue(Session session, String queueName) throws JMSException { protected Queue resolveQueue(Session session, String queueName) throws JMSException {
if (session instanceof QueueSession) { return session.createQueue(queueName);
// 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);
}
} }
} }

8
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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. * Configure the destination accessor with knowledge of the JMS domain used.
* Default is Point-to-Point (Queues). * Default is Point-to-Point (Queues).
* <p>For JMS 1.0.2 based accessors, this tells the JMS provider which class hierarchy * <p>This setting primarily indicates what type of destination to resolve
* to use in the implementation of its operations. For JMS 1.1 based accessors, this * if dynamic destinations are enabled.
* 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.
* @param pubSubDomain "true" for the Publish/Subscribe domain ({@link javax.jms.Topic Topics}), * @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}) * "false" for the Point-to-Point domain ({@link javax.jms.Queue Queues})
* @see #setDestinationResolver * @see #setDestinationResolver

Loading…
Cancel
Save