com.rabbitmq.client.impl
Class ShutdownNotifierComponent

java.lang.Object
  extended by com.rabbitmq.client.impl.ShutdownNotifierComponent
All Implemented Interfaces:
ShutdownNotifier
Direct Known Subclasses:
AMQChannel, AMQConnection

public class ShutdownNotifierComponent
extends java.lang.Object
implements ShutdownNotifier

A class that manages ShutdownListeners and remembers the reason for a shutdown. Both Channels and Connections have shutdown listeners.


Constructor Summary
ShutdownNotifierComponent()
           
 
Method Summary
 void addShutdownListener(ShutdownListener listener)
          Add shutdown listener.
 ShutdownSignalException getCloseReason()
          Get the shutdown reason object
 boolean isOpen()
          Determine whether the component is currently open.
 void notifyListeners()
          Protected API - notify the listeners attached to the component
 void removeShutdownListener(ShutdownListener listener)
          Remove shutdown listener for the component.
 boolean setShutdownCauseIfOpen(ShutdownSignalException sse)
          Internal: this is the means of registering shutdown.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShutdownNotifierComponent

public ShutdownNotifierComponent()
Method Detail

addShutdownListener

public void addShutdownListener(ShutdownListener listener)
Description copied from interface: ShutdownNotifier
Add shutdown listener. If the component is already closed, handler is fired immediately

Specified by:
addShutdownListener in interface ShutdownNotifier
Parameters:
listener - ShutdownListener to the component

getCloseReason

public ShutdownSignalException getCloseReason()
Description copied from interface: ShutdownNotifier
Get the shutdown reason object

Specified by:
getCloseReason in interface ShutdownNotifier
Returns:
ShutdownSignalException if component is closed, null otherwise

notifyListeners

public void notifyListeners()
Description copied from interface: ShutdownNotifier
Protected API - notify the listeners attached to the component

Specified by:
notifyListeners in interface ShutdownNotifier
See Also:
ShutdownListener

removeShutdownListener

public void removeShutdownListener(ShutdownListener listener)
Description copied from interface: ShutdownNotifier
Remove shutdown listener for the component.

Specified by:
removeShutdownListener in interface ShutdownNotifier
Parameters:
listener - ShutdownListener to be removed

isOpen

public boolean isOpen()
Description copied from interface: ShutdownNotifier
Determine whether the component is currently open. Will return false if we are currently closing. Checking this method should be only for information, because of the race conditions - state can change after the call. Instead just execute and try to catch ShutdownSignalException and IOException

Specified by:
isOpen in interface ShutdownNotifier
Returns:
true when component is open, false otherwise

setShutdownCauseIfOpen

public boolean setShutdownCauseIfOpen(ShutdownSignalException sse)
Internal: this is the means of registering shutdown.

Parameters:
sse - the reason for the shutdown
Returns:
true if the component is open; false otherwise.