Save This Page
Home » JBoss-5.1.0 » org » jboss » mq » [javadoc | source]
org.jboss.mq
abstract public class: Connection [javadoc | source]
java.lang.Object
   org.jboss.mq.Connection

All Implemented Interfaces:
    java$io$Serializable, javax.jms.Connection

Direct Known Subclasses:
    SpyConnection, SpyXAConnection

This class implements javax.jms.Connection.

It is also the gateway through wich all calls to the JMS server is done. To do its work it needs a ServerIL to invoke (@see org.jboss.mq.server.ServerIL).

The (new from february 2002) logic for clientID is the following: if logging in with a user and passwork a preconfigured clientID may be automatically delivered from the server.

If the client wants to set it's own clientID it must do so on a connection wich does not have a prefonfigured clientID and it must do so before it calls any other methods on the connection (even getClientID()). It is not allowable to use a clientID that either looks like JBossMQ internal one (beginning with ID) or a clientID that is allready in use by someone, or a clientID that is already preconfigured in the server.

If a preconfigured ID is not get, or a valid one is not set, the server will set an internal ID. This ID is NEVER possible to use for durable subscriptions. If a prefconfigured ID or one manually set is possible to use to create a durable subscriptions is governed by the security configuration of JBossMQ. In the default setup, only preconfigured clientID's are possible to use. If using a SecurityManager, permissions to create a surable subscriptions is * the resiult of a combination of the following:

- The clientID is not one of JBossMQ's internal.

- The user is authenticated and has a role that has create set to true in the security config of the destination.

Notes for JBossMQ developers: All calls, except close(), that is possible to do on a connection must call checkClientID()

Nested Class Summary:
class  Connection.PingTask  The ping task 
class  Connection.ExceptionListenerRunnable  The Exception listener runnable 
Field Summary
static  Logger log    The log 
static  boolean trace    Whether trace is enabled 
protected static  ClockDaemon clockDaemon    Manages the thread that pings the connection to see if it is 'alive' 
public  HashMap destinationSubscriptions    Maps a destination to a LinkedList of Subscriptions 
public  HashMap subscriptions    Maps a subscription id to a Subscription 
public  boolean modeStop    Is the connection stopped ? 
protected  ServerIL serverIL    This is our connection to the JMS server 
protected  String clientID    This is the clientID 
protected  ConnectionToken connectionToken    The connection token is used to identify our connection to the server. 
protected  ClientILService clientILService    The object that sets up the client IL 
protected  long pingPeriod    How often to ping the connection 
protected  boolean ponged    This field is reset when a ping is sent, set when ponged. 
 Semaphore pingTaskSemaphore    This is used to know when the PingTask is running 
 Object pingTaskId    Identifies the PinkTask in the ClockDaemon 
 HashSet createdSessions    LinkedList of all created sessions by this connection 
 int subscriptionCounter    Numbers subscriptions 
 Object subCountLock    The lock for subscriptionCounter 
 SpyXAResourceManager spyXAResourceManager    Used to control tranactions 
 GenericConnectionFactory genericConnectionFactory    The class that created this connection 
 String sessionId    The next session id 
protected  HashSet temps    Temporary destinations created by this connection 
Constructor:
 Connection(GenericConnectionFactory genericConnectionFactory) throws JMSException 
    Create a new Connection
    Parameters:
    genericConnectionFactory - the constructing class
    Throws:
    JMSException - for any error
 Connection(String userName,
    String password,
    GenericConnectionFactory genericConnectionFactory) throws JMSException 
    Create a new Connection
    Parameters:
    userName - the username
    password - the password
    genericConnectionFactory - the constructing class
    Throws:
    JMSException - for any error
Method from org.jboss.mq.Connection Summary:
addConsumer,   askForAnID,   askForAnID,   asynchClose,   asynchDeleteTemporaryDestination,   asynchDeliver,   asynchFailure,   asynchPong,   authenticate,   browse,   checkClientID,   checkClosed,   checkTemporary,   close,   deleteTemporaryDestination,   doStop,   getClientID,   getExceptionListener,   getMetaData,   getNewMessageID,   getServerIL,   getThreadGroup,   pingServer,   receive,   recover,   removeConsumer,   send,   send,   sendToServer,   sessionClosing,   setClientID,   setExceptionListener,   start,   startILService,   stop,   stopILService,   toString,   unsubscribe
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.jboss.mq.Connection Detail:
  void addConsumer(SpyConsumer consumer) throws JMSException 
    A new Consumer has been created.

    We have to handle security issues, a consumer may actually not be allowed to be created

 protected  void askForAnID() throws JMSException 
    Ask the server for an id
 protected  void askForAnID(String userName,
    String password) throws JMSException 
    Ask the server for an id
 public  void asynchClose() 
    Notification from the server that the connection is closed
 public  void asynchDeleteTemporaryDestination(SpyDestination dest) 
    Called by a TemporaryDestination which is going to be deleted()
 public  void asynchDeliver(ReceiveRequest[] requests) 
    Gets the first consumer that is listening to a destination.
 public  void asynchFailure(String reason,
    Throwable t) 
    Notification of a failure on this connection
 public  void asynchPong(long serverTime) 
    Invoked when the server pong us
 protected  void authenticate(String userName,
    String password) throws JMSException 
    Authenticate a user
 SpyMessage[] browse(Queue queue,
    String selector) throws JMSException 
    Browse a queue
 protected synchronized  void checkClientID() throws JMSException 
    Check that a clientID exists. If not get one from server. Also sets the setClientIdAllowed to false. Check clientId, must be called by all public methods on the jacax.jmx.Connection interface and its children.
 protected  void checkClosed() throws IllegalStateException 
    Check whether we are closed
  void checkTemporary(Destination destination) throws JMSException 
    Check a tempoary destination
 public synchronized  void close() throws JMSException 
 public  void deleteTemporaryDestination(SpyDestination dest) throws JMSException 
    Called by a TemporaryDestination which is going to be deleted
 public  void doStop() throws JMSException 
    Stop delivery
 public String getClientID() throws JMSException 
 public ExceptionListener getExceptionListener() throws JMSException 
 public ConnectionMetaData getMetaData() throws JMSException 
 String getNewMessageID() throws JMSException 
    Get the next message id

    All longs are less than 22 digits long

    Note that in this routine we assume that System.currentTimeMillis() is non-negative always be non-negative (so don't set lastMessageID to a positive for a start).

 public ServerIL getServerIL() 
    Gets the ServerIL attribute of the Connection object
 public static ThreadGroup getThreadGroup() 
  void pingServer(long clientTime) throws JMSException 
    Ping the server
 SpyMessage receive(Subscription sub,
    long wait) throws JMSException 
    Receive a message
 protected Xid[] recover(int flags) throws JMSException 
    Recover
  void removeConsumer(SpyConsumer consumer) throws JMSException 
    Remove a consumer
 protected  void send(AcknowledgementRequest item) throws JMSException 
    Acknowledge/Nack a message
 protected  void send(TransactionRequest transaction) throws JMSException 
    Commit/rollback
  void sendToServer(SpyMessage mes) throws JMSException 
    Send a message to the server
  void sessionClosing(SpySession who) 
    Closing a session
 public  void setClientID(String cID) throws JMSException 
 public  void setExceptionListener(ExceptionListener listener) throws JMSException 
 public  void start() throws JMSException 
 protected  void startILService() throws JMSException 
    Start the il
 public  void stop() throws JMSException 
 protected  void stopILService() throws JMSException 
    Stop the il
 public String toString() 
  void unsubscribe(DurableSubscriptionID id) throws JMSException