org.activemq.advisories
Class ConnectionAdvisor

java.lang.Object
  extended by org.activemq.advisories.ConnectionAdvisor
All Implemented Interfaces:
MessageListener

public class ConnectionAdvisor
extends Object
implements MessageListener

A helper class for listening for MessageConnection advisories *

Version:
$Revision: 1.1.1.1 $

Constructor Summary
ConnectionAdvisor(Connection connection)
          Construct a ConnectionAdvisor
 
Method Summary
 void addListener(ConnectionAdvisoryEventListener l)
          Add a listener
 Set getConnections()
          Retrive all current Connections
 boolean isActive(String clientId)
          returns true if the connection is active
 int numberOfActiveConnections()
          return the current number of active connections
 void onMessage(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
 

Constructor Detail

ConnectionAdvisor

public ConnectionAdvisor(Connection connection)
                  throws JMSException
Construct a ConnectionAdvisor

Parameters:
connection -
Throws:
JMSException
Method Detail

start

public void start()
           throws JMSException
start listening for advisories

Throws:
JMSException

stop

public void stop()
          throws JMSException
stop listening for advisories

Throws:
JMSException

addListener

public void addListener(ConnectionAdvisoryEventListener l)
Add a listener

Parameters:
l -

removeListener

public void removeListener(ConnectionAdvisoryEventListener l)
Remove a listener

Parameters:
l -

isActive

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

Parameters:
clientId - for the connection
Returns:
true if the connection is active

getConnections

public Set getConnections()
Retrive all current Connections

Returns:

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

Parameters:
number -
timeout -
Returns:
the number of activeConnections

numberOfActiveConnections

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

Returns:

onMessage

public void onMessage(Message msg)
OnMessage() implementation

Specified by:
onMessage in interface MessageListener
Parameters:
msg -


Copyright © 2004-2008 Protique, Ltd.. All Rights Reserved.