Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.activemq.advisories
Class ConnectionAdvisor  view ConnectionAdvisor download ConnectionAdvisor.java

java.lang.Object
  extended byorg.activemq.advisories.ConnectionAdvisor
All Implemented Interfaces:
javax.jms.MessageListener

public class ConnectionAdvisor
extends java.lang.Object
implements javax.jms.MessageListener

A helper class for listening for MessageConnection advisories *

Version:
$Revision: 1.1.1.1 $

Field Summary
private  java.util.Map activeConnections
           
private  javax.jms.Connection connection
           
private  java.util.List listeners
           
private  java.lang.Object lock
           
private static org.apache.commons.logging.Log log
           
private  javax.jms.Session session
           
private  SynchronizedBoolean started
           
 
Constructor Summary
ConnectionAdvisor(javax.jms.Connection connection)
          Construct a ConnectionAdvisor
 
Method Summary
 void addListener(ConnectionAdvisoryEventListener l)
          Add a listener
private  void fireEvent(ConnectionAdvisoryEvent event)
           
 java.util.Set getConnections()
          Retrive all current Connections
 boolean isActive(java.lang.String clientId)
          returns true if the connection is active
 int numberOfActiveConnections()
          return the current number of active connections
 void onMessage(javax.jms.Message msg)
          OnMessage() implementation
 void removeListener(ConnectionAdvisoryEventListener l)
          Remove a listener
 void start()
          start listening for advisories
 void stop()
          stop listening for advisories
 int waitForActiveConnections(int number, long timeout)
          Waits until the number of active connections is equivalent to the number supplied, or the timeout is exceeded
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final org.apache.commons.logging.Log log

connection

private javax.jms.Connection connection

session

private javax.jms.Session session

listeners

private java.util.List listeners

activeConnections

private java.util.Map activeConnections

started

private SynchronizedBoolean started

lock

private java.lang.Object lock
Constructor Detail

ConnectionAdvisor

public ConnectionAdvisor(javax.jms.Connection connection)
                  throws javax.jms.JMSException
Construct a ConnectionAdvisor

Method Detail

start

public void start()
           throws javax.jms.JMSException
start listening for advisories


stop

public void stop()
          throws javax.jms.JMSException
stop listening for advisories


addListener

public void addListener(ConnectionAdvisoryEventListener l)
Add a listener


removeListener

public void removeListener(ConnectionAdvisoryEventListener l)
Remove a listener


isActive

public boolean isActive(java.lang.String clientId)
returns true if the connection is active


getConnections

public java.util.Set getConnections()
Retrive all current Connections


waitForActiveConnections

public int waitForActiveConnections(int number,
                                    long timeout)
Waits until the number of active connections is equivalent to the number supplied, or the timeout is exceeded


numberOfActiveConnections

public int numberOfActiveConnections()
return the current number of active connections


onMessage

public void onMessage(javax.jms.Message msg)
OnMessage() implementation

Specified by:
onMessage in interface javax.jms.MessageListener

fireEvent

private void fireEvent(ConnectionAdvisoryEvent event)