org.jboss.resource.adapter.jms
Class JmsSessionFactoryImpl

java.lang.Object
  extended byorg.jboss.resource.adapter.jms.JmsSessionFactoryImpl
All Implemented Interfaces:
Connection (src) , JmsSessionFactory (src) , QueueConnection (src) , javax.naming.Referenceable, Referenceable (src) , TopicConnection (src)

public class JmsSessionFactoryImpl
extends java.lang.Object
implements JmsSessionFactory (src) , Referenceable (src)

Implements the JMS Connection API and produces JmsSession (src) objects.

Created: Thu Mar 29 15:36:51 2001


Field Summary
 
Fields inherited from interface org.jboss.resource.adapter.jms.JmsSessionFactory (src)
ISE
 
Constructor Summary
JmsSessionFactoryImpl(ManagedConnectionFactory (src)  mcf, ConnectionManager (src)  cm, int type)
           
 
Method Summary
 void addTemporaryQueue(TemporaryQueue (src)  temp)
          Add a temporary queue
 void addTemporaryTopic(TemporaryTopic (src)  temp)
          Add a temporary topic
protected  JmsSession (src) allocateConnection(boolean transacted, int acknowledgeMode, int sessionType)
           
protected  void checkClosed()
           
 void close()
          Closes the connection.
 void closeSession(JmsSession (src)  session)
          Notification that a session is closed
 ConnectionConsumer (src) createConnectionConsumer(Destination (src)  destination, ServerSessionPool (src)  pool, int maxMessages)
           
 ConnectionConsumer (src) createConnectionConsumer(Destination (src)  destination, java.lang.String name, ServerSessionPool (src)  pool, int maxMessages)
          Creates a connection consumer for this connection (optional operation).
 ConnectionConsumer (src) createConnectionConsumer(Queue (src)  queue, java.lang.String messageSelector, ServerSessionPool (src)  sessionPool, int maxMessages)
          Creates a connection consumer for this connection (optional operation).
 ConnectionConsumer (src) createConnectionConsumer(Topic (src)  topic, java.lang.String messageSelector, ServerSessionPool (src)  sessionPool, int maxMessages)
          Creates a connection consumer for this connection (optional operation).
 ConnectionConsumer (src) createDurableConnectionConsumer(Topic (src)  topic, java.lang.String subscriptionName, java.lang.String messageSelector, ServerSessionPool (src)  sessionPool, int maxMessages)
          Create a durable connection consumer for this connection (optional operation).
 QueueSession (src) createQueueSession(boolean transacted, int acknowledgeMode)
          Creates a QueueSession object.
 Session (src) createSession(boolean transacted, int acknowledgeMode)
          Creates a Session object.
 TopicSession (src) createTopicSession(boolean transacted, int acknowledgeMode)
          Creates a TopicSession object.
 java.lang.String getClientID()
          Gets the client identifier for this connection.
 ExceptionListener (src) getExceptionListener()
          Gets the ExceptionListener object for this connection.
 ConnectionMetaData (src) getMetaData()
          Gets the metadata for this connection.
 javax.naming.Reference getReference()
           
 void setClientID(java.lang.String cID)
          Sets the client identifier for this connection.
 void setExceptionListener(ExceptionListener (src)  listener)
          Sets an exception listener for this connection.
 void setPassword(java.lang.String password)
           
 void setReference(javax.naming.Reference reference)
          Sets the reference instance
 void setUserName(java.lang.String name)
           
 void start()
          Starts (or restarts) a connection's delivery of incoming messages.
 void stop()
          Temporarily stops a connection's delivery of incoming messages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JmsSessionFactoryImpl

public JmsSessionFactoryImpl(ManagedConnectionFactory (src)  mcf,
                             ConnectionManager (src)  cm,
                             int type)
Method Detail

setReference

public void setReference(javax.naming.Reference reference)
Description copied from interface: Referenceable (src)
Sets the reference instance

Specified by:
setReference in interface Referenceable (src)
Parameters:
reference - the reference

getReference

public javax.naming.Reference getReference()
Specified by:
getReference in interface javax.naming.Referenceable

setUserName

public void setUserName(java.lang.String name)

setPassword

public void setPassword(java.lang.String password)

createQueueSession

public QueueSession (src)  createQueueSession(boolean transacted,
                                       int acknowledgeMode)
                                throws JMSException (src) 
Description copied from interface: QueueConnection (src)
Creates a QueueSession object.

Specified by:
createQueueSession in interface QueueConnection (src)
Parameters:
transacted - indicates whether the session is transacted
acknowledgeMode - indicates whether the consumer or the client will acknowledge any messages it receives; ignored if the session is transacted. Legal values are Session.AUTO_ACKNOWLEDGE, Session.CLIENT_ACKNOWLEDGE, and Session.DUPS_OK_ACKNOWLEDGE.
Returns:
a newly created queue session
Throws:
JMSException (src) - if the QueueConnection object fails to create a session due to some internal error or lack of support for the specific transaction and acknowledgement mode.
See Also:
Session.AUTO_ACKNOWLEDGE, Session.CLIENT_ACKNOWLEDGE, Session.DUPS_OK_ACKNOWLEDGE

createConnectionConsumer

public ConnectionConsumer (src)  createConnectionConsumer(Queue (src)  queue,
                                                   java.lang.String messageSelector,
                                                   ServerSessionPool (src)  sessionPool,
                                                   int maxMessages)
                                            throws JMSException (src) 
Description copied from interface: QueueConnection (src)
Creates a connection consumer for this connection (optional operation). This is an expert facility not used by regular JMS clients.

Specified by:
createConnectionConsumer in interface QueueConnection (src)
Parameters:
queue - the queue to access
messageSelector - only messages with properties matching the message selector expression are delivered. A value of null or an empty string indicates that there is no message selector for the message consumer.
sessionPool - the server session pool to associate with this connection consumer
maxMessages - the maximum number of messages that can be assigned to a server session at one time
Returns:
the connection consumer
Throws:
JMSException (src) - if the QueueConnection object fails to create a connection consumer due to some internal error or invalid arguments for sessionPool and messageSelector.
See Also:
ConnectionConsumer (src)

createTopicSession

public TopicSession (src)  createTopicSession(boolean transacted,
                                       int acknowledgeMode)
                                throws JMSException (src) 
Description copied from interface: TopicConnection (src)
Creates a TopicSession object.

Specified by:
createTopicSession in interface TopicConnection (src)
Parameters:
transacted - indicates whether the session is transacted
acknowledgeMode - indicates whether the consumer or the client will acknowledge any messages it receives; ignored if the session is transacted. Legal values are Session.AUTO_ACKNOWLEDGE, Session.CLIENT_ACKNOWLEDGE, and Session.DUPS_OK_ACKNOWLEDGE.
Returns:
a newly created topic session
Throws:
JMSException (src) - if the TopicConnection object fails to create a session due to some internal error or lack of support for the specific transaction and acknowledgement mode.
See Also:
Session.AUTO_ACKNOWLEDGE, Session.CLIENT_ACKNOWLEDGE, Session.DUPS_OK_ACKNOWLEDGE

createConnectionConsumer

public ConnectionConsumer (src)  createConnectionConsumer(Topic (src)  topic,
                                                   java.lang.String messageSelector,
                                                   ServerSessionPool (src)  sessionPool,
                                                   int maxMessages)
                                            throws JMSException (src) 
Description copied from interface: TopicConnection (src)
Creates a connection consumer for this connection (optional operation). This is an expert facility not used by regular JMS clients.

Specified by:
createConnectionConsumer in interface TopicConnection (src)
Parameters:
topic - the topic to access
messageSelector - only messages with properties matching the message selector expression are delivered. A value of null or an empty string indicates that there is no message selector for the message consumer.
sessionPool - the server session pool to associate with this connection consumer
maxMessages - the maximum number of messages that can be assigned to a server session at one time
Returns:
the connection consumer
Throws:
JMSException (src) - if the TopicConnection object fails to create a connection consumer due to some internal error or invalid arguments for sessionPool and messageSelector.
See Also:
ConnectionConsumer (src)

createDurableConnectionConsumer

public ConnectionConsumer (src)  createDurableConnectionConsumer(Topic (src)  topic,
                                                          java.lang.String subscriptionName,
                                                          java.lang.String messageSelector,
                                                          ServerSessionPool (src)  sessionPool,
                                                          int maxMessages)
                                                   throws JMSException (src) 
Description copied from interface: Connection (src)
Create a durable connection consumer for this connection (optional operation). This is an expert facility not used by regular JMS clients.

Specified by:
createDurableConnectionConsumer in interface Connection (src)
Parameters:
topic - topic to access
subscriptionName - durable subscription name
messageSelector - only messages with properties matching the message selector expression are delivered. A value of null or an empty string indicates that there is no message selector for the message consumer.
sessionPool - the server session pool to associate with this durable connection consumer
maxMessages - the maximum number of messages that can be assigned to a server session at one time
Returns:
the durable connection consumer
Throws:
JMSException (src) - if the Connection object fails to create a connection consumer due to some internal error or invalid arguments for sessionPool and messageSelector.
See Also:
ConnectionConsumer (src)

getClientID

public java.lang.String getClientID()
                             throws JMSException (src) 
Description copied from interface: Connection (src)
Gets the client identifier for this connection.

This value is specific to the JMS provider. It is either preconfigured by an administrator in a ConnectionFactory object or assigned dynamically by the application by calling the setClientID method.

Specified by:
getClientID in interface Connection (src)
Returns:
the unique client identifier
Throws:
JMSException (src) - if the JMS provider fails to return the client ID for this connection due to some internal error.

setClientID

public void setClientID(java.lang.String cID)
                 throws JMSException (src) 
Description copied from interface: Connection (src)
Sets the client identifier for this connection.

The preferred way to assign a JMS client's client identifier is for it to be configured in a client-specific ConnectionFactory object and transparently assigned to the Connection object it creates.

Alternatively, a client can set a connection's client identifier using a provider-specific value. The facility to set a connection's client identifier explicitly is not a mechanism for overriding the identifier that has been administratively configured. It is provided for the case where no administratively specified identifier exists. If one does exist, an attempt to change it by setting it must throw an IllegalStateException. If a client sets the client identifier explicitly, it must do so immediately after it creates the connection and before any other action on the connection is taken. After this point, setting the client identifier is a programming error that should throw an IllegalStateException.

The purpose of the client identifier is to associate a connection and its objects with a state maintained on behalf of the client by a provider. The only such state identified by the JMS API is that required to support durable subscriptions.

If another connection with the same clientID is already running when this method is called, the JMS provider should detect the duplicate ID and throw an InvalidClientIDException.

Specified by:
setClientID in interface Connection (src)
Parameters:
cID - the unique client identifier
Throws:
JMSException (src) - if the JMS provider fails to set the client ID for this connection due to some internal error.

getMetaData

public ConnectionMetaData (src)  getMetaData()
                               throws JMSException (src) 
Description copied from interface: Connection (src)
Gets the metadata for this connection.

Specified by:
getMetaData in interface Connection (src)
Returns:
the connection metadata
Throws:
JMSException (src) - if the JMS provider fails to get the connection metadata for this connection.
See Also:
ConnectionMetaData (src)

getExceptionListener

public ExceptionListener (src)  getExceptionListener()
                                       throws JMSException (src) 
Description copied from interface: Connection (src)
Gets the ExceptionListener object for this connection. Not every Connection has an ExceptionListener associated with it.

Specified by:
getExceptionListener in interface Connection (src)
Returns:
the ExceptionListener for this connection, or null. if no ExceptionListener is associated with this connection.
Throws:
JMSException (src) - if the JMS provider fails to get the ExceptionListener for this connection.
See Also:
Connection.setExceptionListener(javax.jms.ExceptionListener)

setExceptionListener

public void setExceptionListener(ExceptionListener (src)  listener)
                          throws JMSException (src) 
Description copied from interface: Connection (src)
Sets an exception listener for this connection.

If a JMS provider detects a serious problem with a connection, it informs the connection's ExceptionListener, if one has been registered. It does this by calling the listener's onException method, passing it a JMSException object describing the problem.

An exception listener allows a client to be notified of a problem asynchronously. Some connections only consume messages, so they would have no other way to learn their connection has failed.

A connection serializes execution of its ExceptionListener.

A JMS provider should attempt to resolve connection problems itself before it notifies the client of them.

Specified by:
setExceptionListener in interface Connection (src)
Parameters:
listener - the exception listener
Throws:
JMSException (src) - if the JMS provider fails to set the exception listener for this connection.

start

public void start()
           throws JMSException (src) 
Description copied from interface: Connection (src)
Starts (or restarts) a connection's delivery of incoming messages. A call to start on a connection that has already been started is ignored.

Specified by:
start in interface Connection (src)
Throws:
JMSException (src) - if the JMS provider fails to start message delivery due to some internal error.
See Also:
Connection.stop()

stop

public void stop()
          throws JMSException (src) 
Description copied from interface: Connection (src)
Temporarily stops a connection's delivery of incoming messages. Delivery can be restarted using the connection's start method. When the connection is stopped, delivery to all the connection's message consumers is inhibited: synchronous receives block, and messages are not delivered to message listeners.

This call blocks until receives and/or message listeners in progress have completed.

Stopping a connection has no effect on its ability to send messages. A call to stop on a connection that has already been stopped is ignored.

A call to stop must not return until delivery of messages has paused. This means that a client can rely on the fact that none of its message listeners will be called and that all threads of control waiting for receive calls to return will not return with a message until the connection is restarted. The receive timers for a stopped connection continue to advance, so receives may time out while the connection is stopped.

If message listeners are running when stop is invoked, the stop call must wait until all of them have returned before it may return. While these message listeners are completing, they must have the full services of the connection available to them.

Specified by:
stop in interface Connection (src)
Throws:
JMSException (src) - if the JMS provider fails to stop message delivery due to some internal error.
See Also:
Connection.start()

close

public void close()
           throws JMSException (src) 
Description copied from interface: Connection (src)
Closes the connection.

Since a provider typically allocates significant resources outside the JVM on behalf of a connection, clients should close these resources when they are not needed. Relying on garbage collection to eventually reclaim these resources may not be timely enough.

There is no need to close the sessions, producers, and consumers of a closed connection.

Closing a connection causes all temporary destinations to be deleted.

When this method is invoked, it should not return until message processing has been shut down in an orderly fashion. This means that all message listeners that may have been running have returned, and that all pending receives have returned. A close terminates all pending message receives on the connection's sessions' consumers. The receives may return with a message or with null, depending on whether there was a message available at the time of the close. If one or more of the connection's sessions' message listeners is processing a message at the time when connection close is invoked, all the facilities of the connection and its sessions must remain available to those listeners until they return control to the JMS provider.

Closing a connection causes any of its sessions' transactions in progress to be rolled back. In the case where a session's work is coordinated by an external transaction manager, a session's commit and rollback methods are not used and the result of a closed session's work is determined later by the transaction manager. Closing a connection does NOT force an acknowledgment of client-acknowledged sessions.

Invoking the acknowledge method of a received message from a closed connection's session must throw an IllegalStateException. Closing a closed connection must NOT throw an exception.

Specified by:
close in interface Connection (src)
Throws:
JMSException (src) - if the JMS provider fails to close the connection due to some internal error. For example, a failure to release resources or to close a socket connection can cause this exception to be thrown.

closeSession

public void closeSession(JmsSession (src)  session)
                  throws JMSException (src) 
Description copied from interface: JmsSessionFactory (src)
Notification that a session is closed

Specified by:
closeSession in interface JmsSessionFactory (src)
Throws:
JMSException (src) - for any error

addTemporaryQueue

public void addTemporaryQueue(TemporaryQueue (src)  temp)
Description copied from interface: JmsSessionFactory (src)
Add a temporary queue

Specified by:
addTemporaryQueue in interface JmsSessionFactory (src)
Parameters:
temp - the temporary queue

addTemporaryTopic

public void addTemporaryTopic(TemporaryTopic (src)  temp)
Description copied from interface: JmsSessionFactory (src)
Add a temporary topic

Specified by:
addTemporaryTopic in interface JmsSessionFactory (src)
Parameters:
temp - the temporary topic

createConnectionConsumer

public ConnectionConsumer (src)  createConnectionConsumer(Destination (src)  destination,
                                                   ServerSessionPool (src)  pool,
                                                   int maxMessages)
                                            throws JMSException (src) 
Throws:
JMSException (src)

createConnectionConsumer

public ConnectionConsumer (src)  createConnectionConsumer(Destination (src)  destination,
                                                   java.lang.String name,
                                                   ServerSessionPool (src)  pool,
                                                   int maxMessages)
                                            throws JMSException (src) 
Description copied from interface: Connection (src)
Creates a connection consumer for this connection (optional operation). This is an expert facility not used by regular JMS clients.

Specified by:
createConnectionConsumer in interface Connection (src)
Parameters:
destination - the destination to access
name - only messages with properties matching the message selector expression are delivered. A value of null or an empty string indicates that there is no message selector for the message consumer.
pool - the server session pool to associate with this connection consumer
maxMessages - the maximum number of messages that can be assigned to a server session at one time
Returns:
the connection consumer
Throws:
JMSException (src) - if the Connection object fails to create a connection consumer due to some internal error or invalid arguments for sessionPool and messageSelector.
See Also:
ConnectionConsumer (src)

createSession

public Session (src)  createSession(boolean transacted,
                             int acknowledgeMode)
                      throws JMSException (src) 
Description copied from interface: Connection (src)
Creates a Session object.

Specified by:
createSession in interface Connection (src)
Parameters:
transacted - indicates whether the session is transacted
acknowledgeMode - indicates whether the consumer or the client will acknowledge any messages it receives; ignored if the session is transacted. Legal values are Session.AUTO_ACKNOWLEDGE, Session.CLIENT_ACKNOWLEDGE, and Session.DUPS_OK_ACKNOWLEDGE.
Returns:
a newly created session
Throws:
JMSException (src) - if the Connection object fails to create a session due to some internal error or lack of support for the specific transaction and acknowledgement mode.
See Also:
Session.AUTO_ACKNOWLEDGE, Session.CLIENT_ACKNOWLEDGE, Session.DUPS_OK_ACKNOWLEDGE

allocateConnection

protected JmsSession (src)  allocateConnection(boolean transacted,
                                        int acknowledgeMode,
                                        int sessionType)
                                 throws JMSException (src) 
Throws:
JMSException (src)

checkClosed

protected void checkClosed()
                    throws IllegalStateException (src) 
Throws:
IllegalStateException (src)