public abstract class ServerHook
extends java.lang.Object
ServerHook
class can be implemented to "hook" into
the Manager's event processing mechanism. Hooks are added and
managed in the Gridserver Administration Tool using the Hook
Admin page. The class definition for the hook must be
contained in a JAR file in the appropriate hook directory
(WEB-INF/hooks/Broker
or
WEB-INF/hooks/Director
).
A hook may have bean
properties (such as set[Property] and get[Property] methods) which
allow for setting of properties in the hooks.xml
file.
The hook will receive any defined event as it occurs.
Depending on if it is registered as a Broker or Director hook, it
will receive a different subset of the available Server Events.
See ServerEvent
for a complete list of Events and if
they are Broker- or Director-specific.
The ServerHookManager posts predefined events to all hooks, in order using a single thread. The thread is independent of the Manager, so that hooks do not interfere with the Manager. A maximum amount of events is set in the Manager, to handle the case in which the hook event processing is slower than event posting on the Manager. In this case, an error is logged and the event is discarded.
Constructor and Description |
---|
ServerHook() |
Modifier and Type | Method and Description |
---|---|
abstract void |
destroy()
Called when the hook is removed or changed.
|
protected void |
enabledSet(boolean enabled)
This method is called whenever the
Enabled property is set, including at startup. |
java.lang.String |
getDescription()
Gets the description of this hook.
|
boolean |
getEnabled()
Gets whether the hook is enabled.
|
java.lang.String |
getName()
Gets the name of this hook.
|
abstract void |
handleEvent(ServerEvent ev)
User-implemented event handler.
|
abstract void |
init()
Called when the hook is added (when the Manager starts, or if added or changed from the Hook Editor).
|
void |
setDescription(java.lang.String description)
Sets the description of this hook.
|
void |
setEnabled(boolean enabled)
Sets whether the hook is enabled.
|
void |
setName(java.lang.String name)
Sets the name of this hook.
|
public abstract void init()
public abstract void destroy()
public abstract void handleEvent(ServerEvent ev)
ev
- the event that was receivedprotected void enabledSet(boolean enabled)
Enabled
property is set, including at startup.
You can override this method to change the Hook behavior when the propery is changed, that is,
to implement your own enable/disable procedures.
Note that you must use the enabled
parameter rather than getEnabled()
,
as this method will be called prior to setting the enabled value for this hook.
This is in case your method throws an unchecked Exception
or Error
,
in which case the enabled value will not change.enabled
- The enabled property value.public java.lang.String getName()
public void setName(java.lang.String name)
name
- the name which will be shown on the Hook Admin pagepublic java.lang.String getDescription()
public void setDescription(java.lang.String description)
description
- the description which will be shown on the Hook Admin pagepublic final void setEnabled(boolean enabled)
enabled
- Whether the hook is enabled, true by defaultpublic final boolean getEnabled()
Copyright © 2014 TIBCO Software, Inc. All Rights Reserved.