Package com.rabbitmq.client.impl
Class ShutdownNotifierComponent
- java.lang.Object
-
- com.rabbitmq.client.impl.ShutdownNotifierComponent
-
- All Implemented Interfaces:
ShutdownNotifier
- Direct Known Subclasses:
AMQChannel,AMQConnection
public class ShutdownNotifierComponent extends Object implements ShutdownNotifier
A class that managesShutdownListeners and remembers the reason for a shutdown. BothChannels andConnections have shutdown listeners.
-
-
Constructor Summary
Constructors Constructor Description ShutdownNotifierComponent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddShutdownListener(ShutdownListener listener)Add shutdown listener.ShutdownSignalExceptiongetCloseReason()Get the shutdown reason objectbooleanisOpen()Determine whether the component is currently open.voidnotifyListeners()Protected API - notify the listeners attached to the componentvoidremoveShutdownListener(ShutdownListener listener)Remove shutdown listener for the component.booleansetShutdownCauseIfOpen(ShutdownSignalException sse)Internal: this is the means of registering shutdown.
-
-
-
Method Detail
-
addShutdownListener
public void addShutdownListener(ShutdownListener listener)
Description copied from interface:ShutdownNotifierAdd shutdown listener. If the component is already closed, handler is fired immediately- Specified by:
addShutdownListenerin interfaceShutdownNotifier- Parameters:
listener-ShutdownListenerto the component
-
getCloseReason
public ShutdownSignalException getCloseReason()
Description copied from interface:ShutdownNotifierGet the shutdown reason object- Specified by:
getCloseReasonin interfaceShutdownNotifier- Returns:
- ShutdownSignalException if component is closed, null otherwise
-
notifyListeners
public void notifyListeners()
Description copied from interface:ShutdownNotifierProtected API - notify the listeners attached to the component- Specified by:
notifyListenersin interfaceShutdownNotifier- See Also:
ShutdownListener
-
removeShutdownListener
public void removeShutdownListener(ShutdownListener listener)
Description copied from interface:ShutdownNotifierRemove shutdown listener for the component.- Specified by:
removeShutdownListenerin interfaceShutdownNotifier- Parameters:
listener-ShutdownListenerto be removed
-
isOpen
public boolean isOpen()
Description copied from interface:ShutdownNotifierDetermine 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:
isOpenin interfaceShutdownNotifier- 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:
trueif the component is open;falseotherwise.
-
-