com.atomikos.jms.extra
Class AbstractJmsSenderTemplate

java.lang.Object
  extended by com.atomikos.jms.extra.AbstractJmsSenderTemplate
Direct Known Subclasses:
ConcurrentJmsSenderTemplate, SingleThreadedJmsSenderTemplate

public abstract class AbstractJmsSenderTemplate
extends Object

Common functionality for the sender templates.


Field Summary
protected  AtomikosConnectionFactoryBean connectionFactoryBean
           
protected  javax.jms.Destination destination
           
protected  boolean inited
           
protected  String password
           
 
Constructor Summary
protected AbstractJmsSenderTemplate()
           
 
Method Summary
protected abstract  void afterUseWithoutErrors(javax.jms.Connection c, javax.jms.Session s)
           
 void close()
          Closes all resources.
protected abstract  void destroy(javax.jms.Connection c, javax.jms.Session s)
           
 void executeCallback(JmsSenderTemplateCallback callback)
          Executes an application-level call-back within the managed session.
protected  void executeCallbackInternal(JmsSenderTemplateCallback callback)
           
 AtomikosConnectionFactoryBean getAtomikosConnectionFactoryBean()
           
 int getDeliveryMode()
           
 javax.jms.Destination getDestination()
           
protected  String getDestinationName()
           
protected abstract  javax.jms.Session getOrRefreshSession(javax.jms.Connection c)
           
protected abstract  javax.jms.Connection getOrReuseConnection()
           
 int getPriority()
           
 javax.jms.Destination getReplyToDestination()
          Gets the replyToDestination.
protected  String getReplyToDestinationName()
           
 long getTimeToLive()
           
 String getUser()
           
 void init()
          Initializes the session for sending.
protected  javax.jms.Connection refreshConnection()
           
 void sendBytesMessage(byte[] content)
          Sends a ByteMessage.
 void sendMapMessage(Map content)
          Sends a MapMessage.
 void sendObjectMessage(Serializable content)
          Sends an ObjectMessage.
 void sendTextMessage(String content)
          Sends a TextMessage.
 void setAtomikosConnectionFactoryBean(AtomikosConnectionFactoryBean connectionFactory)
          Sets the connection factory to use.
 void setDeliveryMode(int i)
          Set the deliverymode for messages sent in this session (optional).
 void setDestination(javax.jms.Destination destination)
          Sets the destination to send to.
 void setDestinationName(String destinationName)
          Sets the (provider-specific) destination name in order to lookup the destination (rather than providing one directly).
 void setPassword(String password)
          Set the password for explicit authentication (optional).
 void setPriority(int i)
          Set the priority for messages sent in this session (optional).
 void setReplyToDestination(javax.jms.Destination destination)
          If this session is used for sending request/reply messages, then this property indicates the destination where the replies are to be sent (optional).
 void setReplyToDestinationName(String replyToDestinationName)
          Sets the provider-specific replyToDestinationName.
 void setTimeToLive(long l)
          Set the time to live for messages sent in this session (optional).
 void setUser(String user)
          Set the user to use for explicit authentication (optional).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connectionFactoryBean

protected AtomikosConnectionFactoryBean connectionFactoryBean

password

protected String password

destination

protected javax.jms.Destination destination

inited

protected boolean inited
Constructor Detail

AbstractJmsSenderTemplate

protected AbstractJmsSenderTemplate()
Method Detail

getOrRefreshSession

protected abstract javax.jms.Session getOrRefreshSession(javax.jms.Connection c)
                                                  throws javax.jms.JMSException
Throws:
javax.jms.JMSException

getOrReuseConnection

protected abstract javax.jms.Connection getOrReuseConnection()
                                                      throws javax.jms.JMSException
Throws:
javax.jms.JMSException

afterUseWithoutErrors

protected abstract void afterUseWithoutErrors(javax.jms.Connection c,
                                              javax.jms.Session s)
                                       throws javax.jms.JMSException
Throws:
javax.jms.JMSException

destroy

protected abstract void destroy(javax.jms.Connection c,
                                javax.jms.Session s)
                         throws javax.jms.JMSException
Throws:
javax.jms.JMSException

refreshConnection

protected javax.jms.Connection refreshConnection()
                                          throws javax.jms.JMSException
Throws:
javax.jms.JMSException

init

public void init()
          throws javax.jms.JMSException
Initializes the session for sending. Call this method first.

Throws:
javax.jms.JMSException

setAtomikosConnectionFactoryBean

public void setAtomikosConnectionFactoryBean(AtomikosConnectionFactoryBean connectionFactory)
Sets the connection factory to use. Required.

Parameters:
connectionFactory -

getAtomikosConnectionFactoryBean

public AtomikosConnectionFactoryBean getAtomikosConnectionFactoryBean()

getDestination

public javax.jms.Destination getDestination()

setDestinationName

public void setDestinationName(String destinationName)
Sets the (provider-specific) destination name in order to lookup the destination (rather than providing one directly). Required, unless you set the destination directly.

Parameters:
destinationName -

setDestination

public void setDestination(javax.jms.Destination destination)
Sets the destination to send to. Required, unless you set the destinationName instead.

Parameters:
destination -

getDestinationName

protected String getDestinationName()

getReplyToDestinationName

protected String getReplyToDestinationName()

getUser

public String getUser()
Returns:
The user to connect with, or null if no explicit authentication is to be used.

setReplyToDestination

public void setReplyToDestination(javax.jms.Destination destination)
If this session is used for sending request/reply messages, then this property indicates the destination where the replies are to be sent (optional). The session uses this to set the JMSReplyTo header accordingly. This property can be omitted if no reply is needed.

The replyToDestination should be in the same JMS vendor domain as the send queue. To cross domains, configure a bridge for both the request and the reply channels.


setReplyToDestinationName

public void setReplyToDestinationName(String replyToDestinationName)
Sets the provider-specific replyToDestinationName. Optional.

Parameters:
replyToDestinationName -

getReplyToDestination

public javax.jms.Destination getReplyToDestination()
Gets the replyToDestination.

Returns:

setPassword

public void setPassword(String password)
Set the password for explicit authentication (optional). This is only required if the user has also been set.

Parameters:
password - The password.

setUser

public void setUser(String user)
Set the user to use for explicit authentication (optional). If no explicit authentication is required then this method should not be called.

Parameters:
user -

executeCallbackInternal

protected void executeCallbackInternal(JmsSenderTemplateCallback callback)
                                throws javax.jms.JMSException
Throws:
javax.jms.JMSException

executeCallback

public void executeCallback(JmsSenderTemplateCallback callback)
                     throws javax.jms.JMSException
Executes an application-level call-back within the managed session.

Parameters:
callback -
Throws:
javax.jms.JMSException

getDeliveryMode

public int getDeliveryMode()
Returns:
The deliverymode for messages sent in this session.

getPriority

public int getPriority()
Returns:
The priority for messages sent in this session.

getTimeToLive

public long getTimeToLive()
Returns:
The timeToLive for messages sent in this session.

setDeliveryMode

public void setDeliveryMode(int i)
Set the deliverymode for messages sent in this session (optional). Defaults to persistent.

Parameters:
-

setPriority

public void setPriority(int i)
Set the priority for messages sent in this session (optional). Defaults to 4.

Parameters:
-

setTimeToLive

public void setTimeToLive(long l)
Set the time to live for messages sent in this session (optional). Defaults to 0.

Parameters:
-

sendTextMessage

public void sendTextMessage(String content)
                     throws javax.jms.JMSException
Sends a TextMessage.

Parameters:
content - The text as a string.
Throws:
javax.jms.JMSException

sendMapMessage

public void sendMapMessage(Map content)
                    throws javax.jms.JMSException
Sends a MapMessage.

Parameters:
content - The Map to get the content from.
Throws:
javax.jms.JMSException

sendObjectMessage

public void sendObjectMessage(Serializable content)
                       throws javax.jms.JMSException
Sends an ObjectMessage.

Parameters:
content - The serializable object content.
Throws:
javax.jms.JMSException

sendBytesMessage

public void sendBytesMessage(byte[] content)
                      throws javax.jms.JMSException
Sends a ByteMessage.

Parameters:
content - The content as a byte array.
Throws:
javax.jms.JMSException

close

public void close()
Closes all resources.



Copyright © 2011. All Rights Reserved.