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 managesShutdownListener
s and remembers the reason for a shutdown. BothChannel
s andConnection
s have shutdown listeners.
-
-
Constructor Summary
Constructors Constructor Description ShutdownNotifierComponent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addShutdownListener(ShutdownListener listener)
Add shutdown listener.ShutdownSignalException
getCloseReason()
Get the shutdown reason objectboolean
isOpen()
Determine whether the component is currently open.void
notifyListeners()
Protected API - notify the listeners attached to the componentvoid
removeShutdownListener(ShutdownListener listener)
Remove shutdown listener for the component.boolean
setShutdownCauseIfOpen(ShutdownSignalException sse)
Internal: this is the means of registering shutdown.
-
-
-
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 interfaceShutdownNotifier
- Parameters:
listener
-ShutdownListener
to the component
-
getCloseReason
public ShutdownSignalException getCloseReason()
Description copied from interface:ShutdownNotifier
Get the shutdown reason object- Specified by:
getCloseReason
in interfaceShutdownNotifier
- 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 interfaceShutdownNotifier
- See Also:
ShutdownListener
-
removeShutdownListener
public void removeShutdownListener(ShutdownListener listener)
Description copied from interface:ShutdownNotifier
Remove shutdown listener for the component.- Specified by:
removeShutdownListener
in interfaceShutdownNotifier
- 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 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:
true
if the component is open;false
otherwise.
-
-