|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Server<K extends Server<K,T>,T extends ServerConfig<T>>
Server Contract for generic Server implementations
Field Summary | |
---|---|
static String |
START_NOTIFICATION_TYPE
The JMX notification event type sent on end of server startup |
static String |
STOP_NOTIFICATION_TYPE
The JMX notification event type sent on begin of the server shutdown |
Method Summary | |
---|---|
void |
addBootstrap(Bootstrap<K,T> bootstrap)
Adds the specified bootstrap to those to be run on start() |
ConfigurationInitializer<T> |
getConfigInitializer()
Returns the initializer for the underlying ServerConfig |
T |
getConfiguration()
Returns the underlying server configuration. |
ServerInitializer<K,T> |
getServerInitializer()
Returns the initializer to be used in initialization, or null if none is defined |
LifecycleState |
getState()
Returns the current state of the Server lifecycle |
ConfigurationValidator<T> |
getValidator()
Returns the (possibly null) validator to be used in asserting the validity of a supplied configuration |
void |
initialize()
Prepares the server for startup. |
void |
registerEventHandler(LifecycleEventHandler handler,
EnumSet<LifecycleState> states)
Registers the specified handler to fire when the server's state enters one of the the specified states |
void |
registerEventHandler(LifecycleEventHandler handler,
LifecycleState... states)
Registers the specified handler to fire when the server's state enters one of the the specified states |
void |
registerEventHandler(LifecycleState state,
LifecycleEventHandler handler)
Registers the specified handler to fire when the server's state enters that of the specified state. |
void |
registerEventHandlers(LifecycleState state,
LifecycleEventHandler... handlers)
Registers the specified handlers to fire when the server's state enters that of the specified state. |
void |
removeBootstrap(Bootstrap<K,T> bootstrap)
Removes the specified bootstrap from those to be run on start() |
void |
setConfigInitializer(ConfigurationInitializer<T> configInitializer)
Sets the initializer to be used upon the configuration. |
void |
setConfiguration(T config)
Sets the configuration |
void |
setServerInitializer(ServerInitializer<K,T> serverInitializer)
Initializer to use in server initialization. |
void |
setValidator(ConfigurationValidator<T> validator)
Sets the specified validator to be used in asserting the validity of a supplied configuration. |
void |
shutdown()
Stop lifecycle of the Server. |
void |
start()
Start lifecycle of the Server, optionally invoking upon initialize() if the state is LifecycleState.PRE_INIT . |
boolean |
unregisterEventHandler(LifecycleEventHandler handler,
LifecycleState state)
Unregisters the specified event handler from firing when the server state changes to the specified state. |
Field Detail |
---|
static final String START_NOTIFICATION_TYPE
static final String STOP_NOTIFICATION_TYPE
Method Detail |
---|
void initialize() throws IllegalStateException, InvalidConfigurationException, LifecycleEventException
getServerInitializer()
is not
null, will invoke ServerInitializer.initialize(Server)
.
Freezes the configuration from further
mutable actions by invoking ServerConfig.freeze()
. Finally
sets the current state to LifecycleState.IDLE
IllegalStateException
- If the server is not in state LifecycleState.PRE_INIT
,
or if the configuration has not been defined
InvalidConfigurationException
LifecycleEventException
- If an error was encountered in the lifecycle handlers for this eventServerInitializer<K,T> getServerInitializer()
void setServerInitializer(ServerInitializer<K,T> serverInitializer) throws IllegalStateException
serverInitializer
-
IllegalStateException
- If the server state is anything aside from
LifecycleState.PRE_INIT
ConfigurationInitializer<T> getConfigInitializer()
ServerConfig
void setConfigInitializer(ConfigurationInitializer<T> configInitializer) throws IllegalStateException
null
to remove the initializer.
configInitializer
-
IllegalStateException
- If the server state is anything aside from
LifecycleState.PRE_INIT
void start() throws IllegalStateException, Exception
initialize()
if the state is LifecycleState.PRE_INIT
.
During execution the state will be LifecycleState.STARTING
, and upon
successful completion will be LifecycleState.STARTED
.
IllegalStateException
- If the Server is already started or starting
Exception
void shutdown() throws IllegalStateException, Exception
LifecycleState.STOPPING
, and upon
successful completion will be LifecycleState.IDLE
. If a
server initialzer is defined then ServerInitializer.cleanup(Server)
will be invoked during this call.
IllegalStateException
- If the Server is not started
Exception
LifecycleState getState()
LifecycleState
void registerEventHandler(LifecycleState state, LifecycleEventHandler handler) throws IllegalArgumentException
state
- handler
-
IllegalArgumentException
- If either the state or the handler are unspecifiedvoid registerEventHandler(LifecycleEventHandler handler, EnumSet<LifecycleState> states) throws IllegalArgumentException
handler
- states
-
IllegalArgumentException
- If either the states or the handler are unspecifiedvoid registerEventHandler(LifecycleEventHandler handler, LifecycleState... states) throws IllegalArgumentException
handler
- states
-
IllegalArgumentException
- If either the states or the handler are unspecifiedvoid registerEventHandlers(LifecycleState state, LifecycleEventHandler... handlers) throws IllegalArgumentException
state
- handlers
-
IllegalArgumentException
- If either the state or the handlers are unspecifiedboolean unregisterEventHandler(LifecycleEventHandler handler, LifecycleState state) throws IllegalArgumentException
state
- handler
-
IllegalArgumentException
- If either the state or handler are unspecifiedT getConfiguration()
LifecycleState.PRE_INIT
, the configuration
will be immutable / frozen.
void setConfiguration(T config)
config
- ConfigurationValidator<T> getValidator()
void setValidator(ConfigurationValidator<T> validator) throws IllegalStateException
validator
-
IllegalStateException
- If the server state is anything aside from
LifecycleState.PRE_INIT
void addBootstrap(Bootstrap<K,T> bootstrap) throws IllegalArgumentException
start()
bootstrap
-
IllegalArgumentException
- If the specified bootstrap is nullvoid removeBootstrap(Bootstrap<K,T> bootstrap) throws IllegalArgumentException
start()
bootstrap
-
IllegalArgumentException
- If the specified bootstrap is not currently
designated as to be run
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |