org.activemq.advisories
Class ConnectionAdvisor

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 $

Constructor Summary
ConnectionAdvisor(javax.jms.Connection connection)
          Construct a ConnectionAdvisor
 
Method Summary
 void addListener(ConnectionAdvisoryEventListener l)
          Add a listener
 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
 

Constructor Detail

ConnectionAdvisor

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

Parameters:
connection -
Throws:
javax.jms.JMSException
Method Detail

start

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

Throws:
javax.jms.JMSException

stop

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

Throws:
javax.jms.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(java.lang.String clientId)
returns true if the connection is active

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

getConnections

public java.util.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(javax.jms.Message msg)
OnMessage() implementation

Specified by:
onMessage in interface javax.jms.MessageListener
Parameters:
msg -


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