com.j_spaces.jms
Class GSSessionImpl

java.lang.Object
  extended by com.j_spaces.jms.GSSessionImpl
All Implemented Interfaces:
Runnable, Session
Direct Known Subclasses:
GSQueueSessionImpl, GSTopicSessionImpl

public abstract class GSSessionImpl
extends Object
implements Session, Runnable

GigaSpaces implementation of the javax.jms.Session interface.


Field Summary
static long ackLeaseTime
           
static HashSet invalidSelectorIdentifiers
           
static Object[][] JMSX_CLIENT_NAMES
          Recognized provider property names that may be set by clients, and their expected types
 String m_sessionID
           
static HashSet<String> reservedSelectorIdentifiers
           
static long txLeaseTime
           
 
Fields inherited from interface javax.jms.Session
AUTO_ACKNOWLEDGE, CLIENT_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE, SESSION_TRANSACTED
 
Constructor Summary
GSSessionImpl(com.j_spaces.jms.GSConnectionImpl conn, boolean isTransacted, int acknowledgeMode, Transaction transaction)
          Creates a session.
 
Method Summary
 void acknowledge()
          Note that the acknowledge method of Message acknowledges all messages received on that messages session.
 boolean cancel(Transaction tx)
           
 void close()
           
 void commit()
          API method for m_tx commit.
 QueueBrowser createBrowser(Queue arg0)
           
 QueueBrowser createBrowser(Queue arg0, String arg1)
           
 BytesMessage createBytesMessage()
          Creates a GSBytesMessageImpl object.
 BytesMessage createBytesMessage(byte[] bytesArrayBody)
          Creates a GSBytesMessageImpl object.
 MessageConsumer createConsumer(Destination destination)
           
 MessageConsumer createConsumer(Destination destination, String messageSelector)
           
 MessageConsumer createConsumer(Destination destination, String messageSelector, boolean NoLocal)
           
 TopicSubscriber createDurableSubscriber(Topic arg0, String arg1)
           
 TopicSubscriber createDurableSubscriber(Topic arg0, String arg1, String arg2, boolean arg3)
           
 MapMessage createMapMessage()
          Creates a GSMapMessageImpl object.
 MapMessage createMapMessage(HashMap jmsHashMapBody)
          Creates a GSMapMessageImpl object.
 Message createMessage()
           
 ObjectMessage createObjectMessage()
          Creates a GSObjectMessageImpl object.
 ObjectMessage createObjectMessage(Serializable object)
          Creates a GSObjectMessageImpl object.
 MessageProducer createProducer(Destination destination)
           
 Queue createQueue(String arg0)
           
 StreamMessage createStreamMessage()
          Creates a StreamMessage object.
 TemporaryQueue createTemporaryQueue()
           
 TemporaryTopic createTemporaryTopic()
           
 TextMessage createTextMessage()
          Creates an initialized TextMessage object.
 TextMessage createTextMessage(String text)
          Creates an initialized TextMessage object.
 Topic createTopic(String arg0)
           
 int getAcknowledgeMode()
          JMS 1.1 API
 int getConsumersC()
           
 String getJMSProviderName()
           
 MessageListener getMessageListener()
           
 int getMessagesC()
           
 int getNumOfConsumedMsg()
           
 int getNumOfProducedMsg()
           
 int getProducersC()
           
 String getSessionID()
           
 boolean getTransacted()
           
 boolean isLocalConsumer(String consKey)
           
 boolean isLocalProducer(String prodKey)
          returns true if the prodKey is a Producer key which is part of the current session's Producer's vector, otherwise it is considered as a Producer which belongs to other session and returns false;
 void recover()
           
 void removeExternalEntryFromSpace(ExternalEntry extEntryToClear)
          Removing the ExternalMessage, using space.clear(), from the space.
 void removeJMSAckDataEntryFromSpace(com.j_spaces.jms.JMSAckDataEntry ackDataEntry)
          Removing/clear() the JMSAckDataEntry from the space usually called after successful Ack to the producer or while cancel().
 void rollback()
          API method for m_tx rollback Calling the space LocalTransactionManager m_tx.abort()
 void run()
           
 void setConsumersC(int i)
           
 void setMessageListener(MessageListener listener)
           
 void setMessagesC(int i)
           
 void setProducersC(int i)
           
 void setSessionID(String string)
           
 String toString()
           
 void unsubscribe(String arg0)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_sessionID

public String m_sessionID

txLeaseTime

public static final long txLeaseTime
See Also:
Constant Field Values

ackLeaseTime

public static final long ackLeaseTime
See Also:
Constant Field Values

reservedSelectorIdentifiers

public static final HashSet<String> reservedSelectorIdentifiers

invalidSelectorIdentifiers

public static final HashSet invalidSelectorIdentifiers

JMSX_CLIENT_NAMES

public static final Object[][] JMSX_CLIENT_NAMES
Recognized provider property names that may be set by clients, and their expected types

Constructor Detail

GSSessionImpl

public GSSessionImpl(com.j_spaces.jms.GSConnectionImpl conn,
                     boolean isTransacted,
                     int acknowledgeMode,
                     Transaction transaction)
              throws JMSException
Creates a session.

Parameters:
conn - The connection the session belongs to.
isTransacted - true for a m_isTransacted session.
acknowledgeMode - 1 (auto), 2 (client) or 3 (dups ok).
transaction - session transaction
Throws:
JMSException - In case of an invalid acknowledge mode.
Method Detail

getJMSProviderName

public String getJMSProviderName()

createBytesMessage

public BytesMessage createBytesMessage()
                                throws JMSException
Creates a GSBytesMessageImpl object. A BytesMessage object is used to send a message containing a stream of uninterpreted bytes.

Specified by:
createBytesMessage in interface Session
Throws:
JMSException - if the JMS provider fails to create this message due to some internal error.
IllegalStateException - If the session is closed.
See Also:
Session.createBytesMessage()

createBytesMessage

public BytesMessage createBytesMessage(byte[] bytesArrayBody)
                                throws JMSException
Creates a GSBytesMessageImpl object. A BytesMessage object is used to send a message containing a stream of uninterpreted bytes. This method is used in MessageConsumer.recieve() when the JMSMessageID is known already.

Parameters:
bytesArrayBody -
Throws:
JMSException - if the JMS provider fails to create this message due to some internal error.
IllegalStateException - If the session is closed.
See Also:
Session.createBytesMessage()

createMapMessage

public MapMessage createMapMessage()
                            throws JMSException
Creates a GSMapMessageImpl object. A GSMapMessageImpl object is used to send a self-defining set of name-value pairs, where names are String objects and values are primitive values in the Java programming language.

Specified by:
createMapMessage in interface Session
Throws:
JMSException - if the JMS provider fails to create this message due to some internal error.
IllegalStateException - If the session is closed.
See Also:
Session.createMapMessage()

createMapMessage

public MapMessage createMapMessage(HashMap jmsHashMapBody)
                            throws JMSException
Creates a GSMapMessageImpl object. A GSMapMessageImpl object is used to send a self-defining set of name-value pairs, where names are String objects and values are primitive values in the Java programming language.

Parameters:
jmsHashMapBody -
Throws:
JMSException - if the JMS provider fails to create this message due to some internal error.
IllegalStateException - If the session is closed.
See Also:
Session.createMapMessage()

createMessage

public Message createMessage()
                      throws JMSException
Specified by:
createMessage in interface Session
Throws:
IllegalStateException - If the session is closed.
JMSException
See Also:
Session.createMessage()

createObjectMessage

public ObjectMessage createObjectMessage()
                                  throws JMSException
Creates a GSObjectMessageImpl object. A GSObjectMessageImpl object is used to send a Serializable java object.

Specified by:
createObjectMessage in interface Session
Throws:
IllegalStateException - If the session is closed.
JMSException
See Also:
Session.createObjectMessage()

createObjectMessage

public ObjectMessage createObjectMessage(Serializable object)
                                  throws JMSException
Creates a GSObjectMessageImpl object. A GSObjectMessageImpl object is used to send a Serializable java object.

Specified by:
createObjectMessage in interface Session
Parameters:
object -
Throws:
IllegalStateException - If the session is closed.
JMSException
See Also:
Session.createObjectMessage(java.io.Serializable)

createStreamMessage

public StreamMessage createStreamMessage()
                                  throws JMSException
Creates a StreamMessage object. A StreamMessage object is used to send a self-defining stream of primitive values in the Java programming language.

Specified by:
createStreamMessage in interface Session
Throws:
IllegalStateException - If the session is closed.
JMSException
See Also:
Session.createStreamMessage()

createTextMessage

public TextMessage createTextMessage()
                              throws JMSException
Creates an initialized TextMessage object. A TextMessage object is used to send a message containing a String.

Specified by:
createTextMessage in interface Session
Throws:
JMSException - if the JMS provider fails to create this message due to some internal error.
IllegalStateException - If the session is closed.
See Also:
Session.createTextMessage()

createTextMessage

public TextMessage createTextMessage(String text)
                              throws JMSException
Creates an initialized TextMessage object. A TextMessage object is used to send a message containing a String.

Specified by:
createTextMessage in interface Session
Parameters:
text - the string used to initialize this message
Throws:
JMSException - if the JMS provider fails to create this message due to some internal error.
IllegalStateException - If the session is closed.
See Also:
Session.createTextMessage(java.lang.String)

getTransacted

public boolean getTransacted()
                      throws JMSException
Specified by:
getTransacted in interface Session
Returns:
m_isTransacted true if tx
Throws:
JMSException
See Also:
Session.getTransacted()

getAcknowledgeMode

public int getAcknowledgeMode()
                       throws IllegalStateException
JMS 1.1 API

Specified by:
getAcknowledgeMode in interface Session
Returns:
m_acknowledgeMode
Throws:
IllegalStateException
See Also:
Session.getAcknowledgeMode()

acknowledge

public void acknowledge()
                 throws JMSException
Note that the acknowledge method of Message acknowledges all messages received on that messages session. Message.acknowledge() method: Clarify that the method applies to all consumed messages of the session. Rationale for this change: A possible misinterpretation of the existing Java API documentation for Message.acknowledge assumed that only messages received prior to ?this? message should be acknowledged. The updated Java API documentation statement emphasizes that message acknowledgment is really a session-level activity and that this message is only being used to identify the session in order to acknowledge all messages consumed by the session. The acknowledge method was placed in the message object only to enable easy access to acknowledgment capability within a message listener?s onMessage method. This change aligns the specification and Java API documentation to define Message.acknowledge in the same manner. Method acknowledging the received messages. We iterate over all the Destination names (the m_deliveries hash) and then on each MessageAcks vec we perform the actual write of JMSAckDataEntry to the space, using the info inside each Ack obj. The Ack obj, is an inner class wrapper that holds all the required information for a successful acknowledge.

Throws:
IllegalStateException - If the connection is broken.
JMSException

commit

public void commit()
            throws JMSException
API method for m_tx commit. Calling the space LocalTransactionManager m_tx.commit() after performing the actual write to space of each JMS message which include an ExternalEntry.

Specified by:
commit in interface Session
Throws:
IllegalStateException - If the session is m_closed or it is NOT transacted
JMSException
See Also:
Session.commit()

rollback

public void rollback()
              throws JMSException
API method for m_tx rollback Calling the space LocalTransactionManager m_tx.abort()

Specified by:
rollback in interface Session
Throws:
IllegalStateException - If the session is closed.
JMSException
See Also:
Session.rollback()

cancel

public boolean cancel(Transaction tx)
               throws IllegalStateException
Parameters:
tx -
Returns:
true if not prepared yet
Throws:
IllegalStateException

close

public void close()
           throws JMSException
Specified by:
close in interface Session
Throws:
JMSException

recover

public void recover()
             throws IllegalStateException
Specified by:
recover in interface Session
Throws:
IllegalStateException

getMessageListener

public MessageListener getMessageListener()
                                   throws JMSException
Specified by:
getMessageListener in interface Session
Throws:
JMSException

setMessageListener

public void setMessageListener(MessageListener listener)
                        throws JMSException
Specified by:
setMessageListener in interface Session
Throws:
JMSException

run

public void run()
Specified by:
run in interface Runnable
Specified by:
run in interface Session

createProducer

public MessageProducer createProducer(Destination destination)
                               throws JMSException
Specified by:
createProducer in interface Session
Throws:
JMSException

createConsumer

public MessageConsumer createConsumer(Destination destination)
                               throws JMSException
Specified by:
createConsumer in interface Session
Throws:
JMSException

createConsumer

public MessageConsumer createConsumer(Destination destination,
                                      String messageSelector)
                               throws JMSException
Specified by:
createConsumer in interface Session
Throws:
JMSException

createConsumer

public MessageConsumer createConsumer(Destination destination,
                                      String messageSelector,
                                      boolean NoLocal)
                               throws JMSException
Specified by:
createConsumer in interface Session
Throws:
JMSException

getSessionID

public String getSessionID()
Returns:
String m_sessionID

setSessionID

public void setSessionID(String string)
Parameters:
string -

removeExternalEntryFromSpace

public void removeExternalEntryFromSpace(ExternalEntry extEntryToClear)
                                  throws JMSException
Removing the ExternalMessage, using space.clear(), from the space.

Parameters:
extEntryToClear -
Throws:
JMSMessage
JMSException

removeJMSAckDataEntryFromSpace

public void removeJMSAckDataEntryFromSpace(com.j_spaces.jms.JMSAckDataEntry ackDataEntry)
                                    throws JMSException
Removing/clear() the JMSAckDataEntry from the space usually called after successful Ack to the producer or while cancel().

Parameters:
ackDataEntry -
Throws:
JMSException

isLocalProducer

public boolean isLocalProducer(String prodKey)
returns true if the prodKey is a Producer key which is part of the current session's Producer's vector, otherwise it is considered as a Producer which belongs to other session and returns false;

Parameters:
prodKey -

isLocalConsumer

public boolean isLocalConsumer(String consKey)

getConsumersC

public int getConsumersC()

getMessagesC

public int getMessagesC()

getProducersC

public int getProducersC()

setConsumersC

public void setConsumersC(int i)

setMessagesC

public void setMessagesC(int i)

setProducersC

public void setProducersC(int i)

toString

public String toString()
Overrides:
toString in class Object

getNumOfConsumedMsg

public int getNumOfConsumedMsg()
Returns:
m_numOfConsumedMsg

getNumOfProducedMsg

public int getNumOfProducedMsg()
Returns:
m_numOfProducedMsg

createQueue

public Queue createQueue(String arg0)
                  throws JMSException
Specified by:
createQueue in interface Session
Throws:
JMSException

createTopic

public Topic createTopic(String arg0)
                  throws JMSException
Specified by:
createTopic in interface Session
Throws:
JMSException

createDurableSubscriber

public TopicSubscriber createDurableSubscriber(Topic arg0,
                                               String arg1)
                                        throws JMSException
Specified by:
createDurableSubscriber in interface Session
Throws:
JMSException

createDurableSubscriber

public TopicSubscriber createDurableSubscriber(Topic arg0,
                                               String arg1,
                                               String arg2,
                                               boolean arg3)
                                        throws JMSException
Specified by:
createDurableSubscriber in interface Session
Throws:
JMSException

createBrowser

public QueueBrowser createBrowser(Queue arg0)
                           throws JMSException
Specified by:
createBrowser in interface Session
Throws:
JMSException

createBrowser

public QueueBrowser createBrowser(Queue arg0,
                                  String arg1)
                           throws JMSException
Specified by:
createBrowser in interface Session
Throws:
JMSException

createTemporaryQueue

public TemporaryQueue createTemporaryQueue()
                                    throws JMSException
Specified by:
createTemporaryQueue in interface Session
Throws:
JMSException

createTemporaryTopic

public TemporaryTopic createTemporaryTopic()
                                    throws JMSException
Specified by:
createTemporaryTopic in interface Session
Throws:
JMSException

unsubscribe

public void unsubscribe(String arg0)
                 throws JMSException
Specified by:
unsubscribe in interface Session
Throws:
JMSException