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


Field Summary
 ShutdownSignalException _shutdownCause
          When this value is null, the component is in an "open" state.
 java.util.List<ShutdownListener> listeners
          List of all shutdown listeners associated with the component
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listeners

public java.util.List<ShutdownListener> listeners
List of all shutdown listeners associated with the component


_shutdownCause

public volatile ShutdownSignalException _shutdownCause
When this value is null, the component is in an "open" state. When non-null, the component is in "closed" state, and this value indicates the circumstances of the shutdown.

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