org.springframework.jms.core
Class JmsTemplate102

java.lang.Object
  extended byorg.springframework.jms.core.JmsTemplate
      extended byorg.springframework.jms.core.JmsTemplate102
All Implemented Interfaces:
InitializingBean, JmsOperations

public class JmsTemplate102
extends JmsTemplate

A subclass of JmsTemplate that uses the JMS 1.0.2 specification, rather than the JMS 1.1 methods used by JmsTemplate itself. This class can be used for JMS 1.0.2 providers, offering the same API as JmsTemplate does for JMS 1.1 providers.

You must specify the domain or style of messaging to be either Point-to-Point (Queues) or Publish/Subscribe (Topics), using the "pubSubDomain" property. Point-to-Point (Queues) is the default domain.

The "pubSubDomain" property is an important setting due to the use of similar but seperate class hierarchies in the JMS 1.0.2 API. JMS 1.1 provides a new domain-independent API that allows for easy mix-and-match use of Point-to-Point and Publish/Subscribe domain.

This template uses a DynamicDestinationResolver and a SimpleMessageConverter102 as default strategies for resolving a destination name or converting a message, respectively.

Since:
1.1
Author:
Mark Pollack, Juergen Hoeller
See Also:
JmsTemplate.setConnectionFactory(javax.jms.ConnectionFactory), JmsTemplate.setPubSubDomain(boolean), JmsTemplate, DynamicDestinationResolver, SimpleMessageConverter102, Queue, Topic, QueueSession, TopicSession, QueueSender, TopicPublisher, QueueReceiver, TopicSubscriber

Field Summary
 
Fields inherited from class org.springframework.jms.core.JmsTemplate
DEFAULT_RECEIVE_TIMEOUT, logger
 
Constructor Summary
JmsTemplate102()
          Create a new JmsTemplate102 for bean-style usage.
JmsTemplate102(ConnectionFactory connectionFactory, boolean pubSubDomain)
          Create a new JmsTemplate102, given a ConnectionFactory.
 
Method Summary
 void afterPropertiesSet()
          In addition to checking if the connection factory is set, make sure that the supplied connection factory is of the appropriate type for the specified destination type: QueueConnectionFactory for queues, and TopicConnectionFactory for topics.
protected  Connection createConnection()
          This implementation overrides the superclass method to use JMS 1.0.2 API.
protected  MessageConsumer createConsumer(Session session, Destination destination)
          This implementation overrides the superclass method to use JMS 1.0.2 API.
protected  MessageConsumer createConsumer(Session session, Destination destination, String messageSelector)
          This implementation overrides the superclass method to use JMS 1.0.2 API.
protected  Session createSession(Connection con)
          This implementation overrides the superclass method to use JMS 1.0.2 API.
protected  MessageProducer doCreateProducer(Session session, Destination destination)
          This implementation overrides the superclass method to use JMS 1.0.2 API.
protected  void doSend(MessageProducer producer, Message message)
          This implementation overrides the superclass method to use JMS 1.0.2 API.
protected  void initDefaultStrategies()
          Initialize the default implementations for the template's strategies: DynamicDestinationResolver and SimpleMessageConverter102.
protected  boolean isClientAcknowledge(Session session)
          This implementation overrides the superclass method to avoid using JMS 1.1's Session getAcknowledgeMode method.
 
Methods inherited from class org.springframework.jms.core.JmsTemplate
convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertJmsAccessException, createProducer, doConvertFromMessage, doReceive, doReceive, doReceiveSelected, doSend, execute, execute, execute, getConnectionFactory, getDefaultDestination, getDeliveryMode, getDestinationResolver, getMessageConverter, getPriority, getReceiveTimeout, getSessionAcknowledgeMode, getTimeToLive, isExplicitQosEnabled, isMessageIdEnabled, isMessageTimestampEnabled, isPubSubDomain, isPubSubNoLocal, isSessionTransacted, receive, receive, receive, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveSelected, receiveSelected, receiveSelected, receiveSelectedAndConvert, receiveSelectedAndConvert, receiveSelectedAndConvert, resolveDestinationName, send, send, send, setConnectionFactory, setDefaultDestination, setDeliveryMode, setDestinationResolver, setExplicitQosEnabled, setMessageConverter, setMessageIdEnabled, setMessageTimestampEnabled, setPriority, setPubSubDomain, setPubSubNoLocal, setReceiveTimeout, setSessionAcknowledgeMode, setSessionAcknowledgeModeName, setSessionTransacted, setTimeToLive
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JmsTemplate102

public JmsTemplate102()
Create a new JmsTemplate102 for bean-style usage.

Note: The ConnectionFactory has to be set before using the instance. This constructor can be used to prepare a JmsTemplate via a BeanFactory, typically setting the ConnectionFactory via setConnectionFactory.

See Also:
JmsTemplate.setConnectionFactory(javax.jms.ConnectionFactory)

JmsTemplate102

public JmsTemplate102(ConnectionFactory connectionFactory,
                      boolean pubSubDomain)
Create a new JmsTemplate102, given a ConnectionFactory.

Parameters:
connectionFactory - the ConnectionFactory to obtain connections from
pubSubDomain - whether the Publish/Subscribe domain (Topics) or Point-to-Point domain (Queues) should be used
See Also:
JmsTemplate.setPubSubDomain(boolean)
Method Detail

initDefaultStrategies

protected void initDefaultStrategies()
Initialize the default implementations for the template's strategies: DynamicDestinationResolver and SimpleMessageConverter102.

Overrides:
initDefaultStrategies in class JmsTemplate
See Also:
JmsTemplate.setDestinationResolver(org.springframework.jms.support.destination.DestinationResolver), JmsTemplate.setMessageConverter(org.springframework.jms.support.converter.MessageConverter), DynamicDestinationResolver, SimpleMessageConverter102

afterPropertiesSet

public void afterPropertiesSet()
In addition to checking if the connection factory is set, make sure that the supplied connection factory is of the appropriate type for the specified destination type: QueueConnectionFactory for queues, and TopicConnectionFactory for topics.

Specified by:
afterPropertiesSet in interface InitializingBean
Overrides:
afterPropertiesSet in class JmsTemplate

createConnection

protected Connection createConnection()
                               throws JMSException
This implementation overrides the superclass method to use JMS 1.0.2 API.

Overrides:
createConnection in class JmsTemplate
Returns:
the new JMS Connection
Throws:
JMSException - if thrown by JMS API methods

createSession

protected Session createSession(Connection con)
                         throws JMSException
This implementation overrides the superclass method to use JMS 1.0.2 API.

Overrides:
createSession in class JmsTemplate
Parameters:
con - the JMS Connection to create a Session for
Returns:
the new JMS Session
Throws:
JMSException - if thrown by JMS API methods

doCreateProducer

protected MessageProducer doCreateProducer(Session session,
                                           Destination destination)
                                    throws JMSException
This implementation overrides the superclass method to use JMS 1.0.2 API.

Overrides:
doCreateProducer in class JmsTemplate
Parameters:
session - the JMS Session to create a MessageProducer for
destination - the JMS Destination to create a MessageProducer for
Returns:
the new JMS MessageProducer
Throws:
JMSException - if thrown by JMS API methods

createConsumer

protected MessageConsumer createConsumer(Session session,
                                         Destination destination)
                                  throws JMSException
This implementation overrides the superclass method to use JMS 1.0.2 API.

Overrides:
createConsumer in class JmsTemplate
Parameters:
session - the JMS Session to create a MessageConsumer for
destination - the JMS Destination to create a MessageConsumer for
Returns:
the new JMS MessageConsumer
Throws:
JMSException - if thrown by JMS API methods

createConsumer

protected MessageConsumer createConsumer(Session session,
                                         Destination destination,
                                         String messageSelector)
                                  throws JMSException
This implementation overrides the superclass method to use JMS 1.0.2 API.

Overrides:
createConsumer in class JmsTemplate
Parameters:
session - the JMS Session to create a MessageConsumer for
destination - the JMS Destination to create a MessageConsumer for
Returns:
the new JMS MessageConsumer
Throws:
JMSException - if thrown by JMS API methods

doSend

protected void doSend(MessageProducer producer,
                      Message message)
               throws JMSException
This implementation overrides the superclass method to use JMS 1.0.2 API.

Overrides:
doSend in class JmsTemplate
Throws:
JMSException

isClientAcknowledge

protected boolean isClientAcknowledge(Session session)
                               throws JMSException
This implementation overrides the superclass method to avoid using JMS 1.1's Session getAcknowledgeMode method. The best we can do here is to check the setting on the template.

Overrides:
isClientAcknowledge in class JmsTemplate
Throws:
JMSException


Copyright (C) 2003-2004 The Spring Framework Project.