org.jboss.bootstrap.spi.server
Interface Server<K extends Server<K,T>,T extends ServerConfig<T>>


public interface Server<K extends Server<K,T>,T extends ServerConfig<T>>

Server Contract for generic Server implementations

Version:
$Revision: $
Author:
ALR

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

START_NOTIFICATION_TYPE

static final String START_NOTIFICATION_TYPE
The JMX notification event type sent on end of server startup

See Also:
Constant Field Values

STOP_NOTIFICATION_TYPE

static final String STOP_NOTIFICATION_TYPE
The JMX notification event type sent on begin of the server shutdown

See Also:
Constant Field Values
Method Detail

initialize

void initialize()
                throws IllegalStateException,
                       InvalidConfigurationException,
                       LifecycleEventException
Prepares the server for startup. If 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

Throws:
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 event

getServerInitializer

ServerInitializer<K,T> getServerInitializer()
Returns the initializer to be used in initialization, or null if none is defined

Returns:

setServerInitializer

void setServerInitializer(ServerInitializer<K,T> serverInitializer)
                          throws IllegalStateException
Initializer to use in server initialization. Pass null to disable further initialization.

Parameters:
serverInitializer -
Throws:
IllegalStateException - If the server state is anything aside from LifecycleState.PRE_INIT

getConfigInitializer

ConfigurationInitializer<T> getConfigInitializer()
Returns the initializer for the underlying ServerConfig

Returns:

setConfigInitializer

void setConfigInitializer(ConfigurationInitializer<T> configInitializer)
                          throws IllegalStateException
Sets the initializer to be used upon the configuration. Pass null to remove the initializer.

Parameters:
configInitializer -
Throws:
IllegalStateException - If the server state is anything aside from LifecycleState.PRE_INIT

start

void start()
           throws IllegalStateException,
                  Exception
Start lifecycle of the Server, optionally invoking upon initialize() if the state is LifecycleState.PRE_INIT. During execution the state will be LifecycleState.STARTING, and upon successful completion will be LifecycleState.STARTED.

Throws:
IllegalStateException - If the Server is already started or starting
Exception

shutdown

void shutdown()
              throws IllegalStateException,
                     Exception
Stop lifecycle of the Server. During execution the state will be 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.

Throws:
IllegalStateException - If the Server is not started
Exception

getState

LifecycleState getState()
Returns the current state of the Server lifecycle

Returns:
The LifecycleState

registerEventHandler

void registerEventHandler(LifecycleState state,
                          LifecycleEventHandler handler)
                          throws IllegalArgumentException
Registers the specified handler to fire when the server's state enters that of the specified state.

Parameters:
state -
handler -
Throws:
IllegalArgumentException - If either the state or the handler are unspecified

registerEventHandler

void registerEventHandler(LifecycleEventHandler handler,
                          EnumSet<LifecycleState> states)
                          throws IllegalArgumentException
Registers the specified handler to fire when the server's state enters one of the the specified states

Parameters:
handler -
states -
Throws:
IllegalArgumentException - If either the states or the handler are unspecified

registerEventHandler

void registerEventHandler(LifecycleEventHandler handler,
                          LifecycleState... states)
                          throws IllegalArgumentException
Registers the specified handler to fire when the server's state enters one of the the specified states

Parameters:
handler -
states -
Throws:
IllegalArgumentException - If either the states or the handler are unspecified

registerEventHandlers

void registerEventHandlers(LifecycleState state,
                           LifecycleEventHandler... handlers)
                           throws IllegalArgumentException
Registers the specified handlers to fire when the server's state enters that of the specified state.

Parameters:
state -
handlers -
Throws:
IllegalArgumentException - If either the state or the handlers are unspecified

unregisterEventHandler

boolean unregisterEventHandler(LifecycleEventHandler handler,
                               LifecycleState state)
                               throws IllegalArgumentException
Unregisters the specified event handler from firing when the server state changes to the specified state.

Parameters:
state -
handler -
Returns:
Whether or not the handler was removed (ie. false if not registered)
Throws:
IllegalArgumentException - If either the state or handler are unspecified

getConfiguration

T getConfiguration()
Returns the underlying server configuration. If the server state is anything aside from LifecycleState.PRE_INIT, the configuration will be immutable / frozen.

Returns:

setConfiguration

void setConfiguration(T config)
Sets the configuration

Parameters:
config -

getValidator

ConfigurationValidator<T> getValidator()
Returns the (possibly null) validator to be used in asserting the validity of a supplied configuration

Returns:

setValidator

void setValidator(ConfigurationValidator<T> validator)
                  throws IllegalStateException
Sets the specified validator to be used in asserting the validity of a supplied configuration. May be null to remove validation.

Parameters:
validator -
Throws:
IllegalStateException - If the server state is anything aside from LifecycleState.PRE_INIT

addBootstrap

void addBootstrap(Bootstrap<K,T> bootstrap)
                  throws IllegalArgumentException
Adds the specified bootstrap to those to be run on start()

Parameters:
bootstrap -
Throws:
IllegalArgumentException - If the specified bootstrap is null

removeBootstrap

void removeBootstrap(Bootstrap<K,T> bootstrap)
                     throws IllegalArgumentException
Removes the specified bootstrap from those to be run on start()

Parameters:
bootstrap -
Throws:
IllegalArgumentException - If the specified bootstrap is not currently designated as to be run


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.