org.jboss.bootstrap.impl.base.server
Class AbstractServer<K extends org.jboss.bootstrap.spi.server.Server<K,T>,T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>

java.lang.Object
  extended by javax.management.NotificationBroadcasterSupport
      extended by org.jboss.bootstrap.impl.base.server.AbstractServer<K,T>
All Implemented Interfaces:
NotificationBroadcaster, NotificationEmitter, org.jboss.bootstrap.spi.server.Server<K,T>

public abstract class AbstractServer<K extends org.jboss.bootstrap.spi.server.Server<K,T>,T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>
extends NotificationBroadcasterSupport
implements org.jboss.bootstrap.spi.server.Server<K,T>, NotificationBroadcaster

AbstractServer Generic support for Server implementations

Version:
$Revision: $
Author:
ALR

Field Summary
 
Fields inherited from interface org.jboss.bootstrap.spi.server.Server
START_NOTIFICATION_TYPE, STOP_NOTIFICATION_TYPE
 
Constructor Summary
protected AbstractServer(Class<K> actualClass)
          Constructor Creates a new Server using an uninitialized, default configuration (which is an instance of the Class specified by getDefaultServerConfigClass()
protected AbstractServer(Class<K> actualClass, T configuration)
          Constructor Creates a new Server, specifying the configuration to be used.
 
Method Summary
 void addBootstrap(org.jboss.bootstrap.spi.Bootstrap<K,T> bootstrap)
           
protected  K covarientReturn()
          Returns this instance as a typed server (as specified by K), throwing a descriptive error message in case the server is not assignable
protected  void doInitialize()
          Implementation-specific initialization logic; invoked by initialize()
protected abstract  void doShutdown()
          Implementation-specific shutdown hook
protected abstract  void doStart()
          Implementation-specific start hook
protected  Class<K> getActualClass()
           
 org.jboss.bootstrap.spi.config.ConfigurationInitializer<T> getConfigInitializer()
           
 T getConfiguration()
           
protected abstract  Class<? extends T> getDefaultServerConfigClass()
          Obtains the Class used in constructing a new default Server Configuration if one is not supplied to the constructor
 org.jboss.bootstrap.spi.server.ServerInitializer<K,T> getServerInitializer()
           
 org.jboss.bootstrap.spi.lifecycle.LifecycleState getState()
           
 org.jboss.bootstrap.spi.config.ConfigurationValidator<T> getValidator()
           
 void initialize()
           
 void registerEventHandler(org.jboss.bootstrap.spi.lifecycle.LifecycleEventHandler handler, EnumSet<org.jboss.bootstrap.spi.lifecycle.LifecycleState> states)
           
 void registerEventHandler(org.jboss.bootstrap.spi.lifecycle.LifecycleEventHandler handler, org.jboss.bootstrap.spi.lifecycle.LifecycleState... states)
           
 void registerEventHandler(org.jboss.bootstrap.spi.lifecycle.LifecycleState state, org.jboss.bootstrap.spi.lifecycle.LifecycleEventHandler handler)
           
 void registerEventHandlers(org.jboss.bootstrap.spi.lifecycle.LifecycleState state, org.jboss.bootstrap.spi.lifecycle.LifecycleEventHandler... handlers)
           
 void removeBootstrap(org.jboss.bootstrap.spi.Bootstrap<K,T> bootstrap)
           
protected  void sendNotificationWithCurrentTimeUserData(String type, int sequenceNumber)
          Sends a JMX Notification with specified type and sequence number, setting user data to the number of milliseconds since the epoch.
protected  void sendStartJmxNotification()
          Sends the JMX Notification with type signaling the start of the server
protected  void sendStopJmxNotification()
          Sends the JMX Notification with type signaling the stop of the server
 void setConfigInitializer(org.jboss.bootstrap.spi.config.ConfigurationInitializer<T> configInitializer)
           
 void setConfiguration(T configuration)
           
 void setServerInitializer(org.jboss.bootstrap.spi.server.ServerInitializer<K,T> serverInitializer)
           
 void setValidator(org.jboss.bootstrap.spi.config.ConfigurationValidator<T> validator)
           
 void shutdown()
           
protected  void shutdownBootstraps()
          Shuts down the bootstraps that have been started
 void start()
           
protected  void startBootstraps()
          Starts the bootstraps
 boolean unregisterEventHandler(org.jboss.bootstrap.spi.lifecycle.LifecycleEventHandler handler, org.jboss.bootstrap.spi.lifecycle.LifecycleState state)
           
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.management.NotificationBroadcaster
addNotificationListener, getNotificationInfo, removeNotificationListener
 

Constructor Detail

AbstractServer

protected AbstractServer(Class<K> actualClass)
                  throws IllegalArgumentException
Constructor Creates a new Server using an uninitialized, default configuration (which is an instance of the Class specified by getDefaultServerConfigClass()

Throws:
IllegalArgumentException - If the actual class was not supplied

AbstractServer

protected AbstractServer(Class<K> actualClass,
                         T configuration)
                  throws IllegalArgumentException
Constructor Creates a new Server, specifying the configuration to be used.

Parameters:
configuration - The configuration to set. If null a new default configuration will be made (which is an instance of the Class specified by getDefaultServerConfigClass()
Throws:
IllegalArgumentException - If the configuration or actual class has not been supplied
Method Detail

getConfiguration

public T getConfiguration()
Specified by:
getConfiguration in interface org.jboss.bootstrap.spi.server.Server<K extends org.jboss.bootstrap.spi.server.Server<K,T>,T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>

setConfiguration

public void setConfiguration(T configuration)
Specified by:
setConfiguration in interface org.jboss.bootstrap.spi.server.Server<K extends org.jboss.bootstrap.spi.server.Server<K,T>,T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>

getState

public final org.jboss.bootstrap.spi.lifecycle.LifecycleState getState()
Specified by:
getState in interface org.jboss.bootstrap.spi.server.Server<K extends org.jboss.bootstrap.spi.server.Server<K,T>,T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>

shutdown

public void shutdown()
              throws IllegalStateException,
                     Exception
Specified by:
shutdown in interface org.jboss.bootstrap.spi.server.Server<K extends org.jboss.bootstrap.spi.server.Server<K,T>,T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>
Throws:
IllegalStateException
Exception

start

public void start()
           throws IllegalStateException,
                  Exception
Specified by:
start in interface org.jboss.bootstrap.spi.server.Server<K extends org.jboss.bootstrap.spi.server.Server<K,T>,T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>
Throws:
IllegalStateException
Exception

addBootstrap

public void addBootstrap(org.jboss.bootstrap.spi.Bootstrap<K,T> bootstrap)
                  throws IllegalStateException,
                         IllegalArgumentException
Specified by:
addBootstrap in interface org.jboss.bootstrap.spi.server.Server<K extends org.jboss.bootstrap.spi.server.Server<K,T>,T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>
Throws:
IllegalStateException
IllegalArgumentException

removeBootstrap

public void removeBootstrap(org.jboss.bootstrap.spi.Bootstrap<K,T> bootstrap)
                     throws IllegalStateException,
                            IllegalArgumentException
Specified by:
removeBootstrap in interface org.jboss.bootstrap.spi.server.Server<K extends org.jboss.bootstrap.spi.server.Server<K,T>,T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>
Throws:
IllegalStateException
IllegalArgumentException

getValidator

public org.jboss.bootstrap.spi.config.ConfigurationValidator<T> getValidator()
Specified by:
getValidator in interface org.jboss.bootstrap.spi.server.Server<K extends org.jboss.bootstrap.spi.server.Server<K,T>,T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>

initialize

public final void initialize()
                      throws IllegalStateException,
                             org.jboss.bootstrap.spi.config.InvalidConfigurationException,
                             org.jboss.bootstrap.spi.lifecycle.LifecycleEventException
Specified by:
initialize in interface org.jboss.bootstrap.spi.server.Server<K extends org.jboss.bootstrap.spi.server.Server<K,T>,T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>
Throws:
IllegalStateException
org.jboss.bootstrap.spi.config.InvalidConfigurationException
org.jboss.bootstrap.spi.lifecycle.LifecycleEventException

doInitialize

protected void doInitialize()
                     throws IllegalStateException,
                            org.jboss.bootstrap.spi.config.InvalidConfigurationException,
                            org.jboss.bootstrap.spi.lifecycle.LifecycleEventException
Implementation-specific initialization logic; invoked by initialize()

Throws:
IllegalStateException
org.jboss.bootstrap.spi.config.InvalidConfigurationException
org.jboss.bootstrap.spi.lifecycle.LifecycleEventException

getServerInitializer

public final org.jboss.bootstrap.spi.server.ServerInitializer<K,T> getServerInitializer()
Specified by:
getServerInitializer in interface org.jboss.bootstrap.spi.server.Server<K extends org.jboss.bootstrap.spi.server.Server<K,T>,T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>

setServerInitializer

public final void setServerInitializer(org.jboss.bootstrap.spi.server.ServerInitializer<K,T> serverInitializer)
                                throws IllegalStateException
Specified by:
setServerInitializer in interface org.jboss.bootstrap.spi.server.Server<K extends org.jboss.bootstrap.spi.server.Server<K,T>,T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>
Throws:
IllegalStateException

getConfigInitializer

public final org.jboss.bootstrap.spi.config.ConfigurationInitializer<T> getConfigInitializer()
Specified by:
getConfigInitializer in interface org.jboss.bootstrap.spi.server.Server<K extends org.jboss.bootstrap.spi.server.Server<K,T>,T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>

setConfigInitializer

public final void setConfigInitializer(org.jboss.bootstrap.spi.config.ConfigurationInitializer<T> configInitializer)
Specified by:
setConfigInitializer in interface org.jboss.bootstrap.spi.server.Server<K extends org.jboss.bootstrap.spi.server.Server<K,T>,T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>

setValidator

public final void setValidator(org.jboss.bootstrap.spi.config.ConfigurationValidator<T> validator)
Specified by:
setValidator in interface org.jboss.bootstrap.spi.server.Server<K extends org.jboss.bootstrap.spi.server.Server<K,T>,T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>

registerEventHandler

public void registerEventHandler(org.jboss.bootstrap.spi.lifecycle.LifecycleState state,
                                 org.jboss.bootstrap.spi.lifecycle.LifecycleEventHandler handler)
                          throws IllegalArgumentException
Specified by:
registerEventHandler in interface org.jboss.bootstrap.spi.server.Server<K extends org.jboss.bootstrap.spi.server.Server<K,T>,T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>
Throws:
IllegalArgumentException

registerEventHandler

public void registerEventHandler(org.jboss.bootstrap.spi.lifecycle.LifecycleEventHandler handler,
                                 EnumSet<org.jboss.bootstrap.spi.lifecycle.LifecycleState> states)
                          throws IllegalArgumentException
Specified by:
registerEventHandler in interface org.jboss.bootstrap.spi.server.Server<K extends org.jboss.bootstrap.spi.server.Server<K,T>,T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>
Throws:
IllegalArgumentException

registerEventHandler

public void registerEventHandler(org.jboss.bootstrap.spi.lifecycle.LifecycleEventHandler handler,
                                 org.jboss.bootstrap.spi.lifecycle.LifecycleState... states)
                          throws IllegalArgumentException
Specified by:
registerEventHandler in interface org.jboss.bootstrap.spi.server.Server<K extends org.jboss.bootstrap.spi.server.Server<K,T>,T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>
Throws:
IllegalArgumentException

registerEventHandlers

public void registerEventHandlers(org.jboss.bootstrap.spi.lifecycle.LifecycleState state,
                                  org.jboss.bootstrap.spi.lifecycle.LifecycleEventHandler... handlers)
                           throws IllegalArgumentException
Specified by:
registerEventHandlers in interface org.jboss.bootstrap.spi.server.Server<K extends org.jboss.bootstrap.spi.server.Server<K,T>,T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>
Throws:
IllegalArgumentException

unregisterEventHandler

public boolean unregisterEventHandler(org.jboss.bootstrap.spi.lifecycle.LifecycleEventHandler handler,
                                      org.jboss.bootstrap.spi.lifecycle.LifecycleState state)
                               throws IllegalArgumentException
Specified by:
unregisterEventHandler in interface org.jboss.bootstrap.spi.server.Server<K extends org.jboss.bootstrap.spi.server.Server<K,T>,T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>
Throws:
IllegalArgumentException

doStart

protected abstract void doStart()
                         throws Exception
Implementation-specific start hook

Throws:
Exception

doShutdown

protected abstract void doShutdown()
                            throws Exception
Implementation-specific shutdown hook

Throws:
Exception

getDefaultServerConfigClass

protected abstract Class<? extends T> getDefaultServerConfigClass()
Obtains the Class used in constructing a new default Server Configuration if one is not supplied to the constructor

Returns:

sendStartJmxNotification

protected void sendStartJmxNotification()
Sends the JMX Notification with type signaling the start of the server


sendStopJmxNotification

protected void sendStopJmxNotification()
Sends the JMX Notification with type signaling the stop of the server


sendNotificationWithCurrentTimeUserData

protected final void sendNotificationWithCurrentTimeUserData(String type,
                                                             int sequenceNumber)
Sends a JMX Notification with specified type and sequence number, setting user data to the number of milliseconds since the epoch.

Parameters:
type -
sequenceNumber -

startBootstraps

protected void startBootstraps()
                        throws Exception
Starts the bootstraps

Throws:
Exception

shutdownBootstraps

protected void shutdownBootstraps()
Shuts down the bootstraps that have been started


covarientReturn

protected final K covarientReturn()
Returns this instance as a typed server (as specified by K), throwing a descriptive error message in case the server is not assignable


getActualClass

protected final Class<K> getActualClass()
Returns:
the actualClass


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