com.caucho.env.deploy
Class DeployController<I extends DeployInstance>

java.lang.Object
  extended by com.caucho.env.deploy.DeployController<I>
All Implemented Interfaces:
DeployActionHandler, DeployControllerApi<I>, Dependency
Direct Known Subclasses:
ExpandDeployController

public abstract class DeployController<I extends DeployInstance>
extends java.lang.Object
implements DeployControllerApi<I>, Dependency, DeployActionHandler

DeployController controls the lifecycle of the DeployInstance.


Field Summary
protected  Lifecycle _lifecycle
           
static long REDEPLOY_CHECK_INTERVAL
           
 
Constructor Summary
protected DeployController(java.lang.String id)
           
protected DeployController(java.lang.String id, java.lang.ClassLoader parentLoader)
           
 
Method Summary
 void addLifecycleListener(LifecycleListener listener)
          External lifecycle listeners, so applications can detect deployment and redeployment.
 void alarm()
          Internal notification for modification updates, either from a timer or a repository notification.
 void close()
          Closes the controller
protected  void configureInstance(I deployInstance)
          Configuration of the instance
protected  boolean controllerLogModified(java.util.logging.Logger log)
           
protected  I createDeployInstance()
          Returns the current instance.
protected  boolean destroy()
          Destroys the entry.
protected  void destroyInstance(I instance)
           
 I getActiveDeployInstance()
          Returns the current instance, waiting for active.
 long getActiveWaitTime()
           
 DeployControllerType getControllerType()
          Returns the controller type
 I getDeployInstance()
          Returns the current instance.
 I getDeployInstanceImpl()
          Returns the current instance.
 java.lang.String getId()
          Returns the controller's id.
 java.lang.String getIdKey()
           
 java.lang.String getIdStage()
           
 java.lang.String getIdType()
           
protected  java.util.logging.Logger getLog()
          Returns the appropriate log for debugging.
 java.lang.ClassLoader getParentClassLoader()
          Returns the parent class loader.
 long getRedeployCheckInterval()
          Gets the redeploy-check-interval
 DeployMode getRedeployMode()
          Returns the redeploy mode.
 long getStartTime()
          Returns the start time of the entry.
 DeployMode getStartupMode()
          Returns the startup mode.
 int getStartupPriority()
          Gets the startup priority.
 LifecycleState getState()
          Returns the state name.
 boolean init()
          Initialize the entry.
protected  void initBegin()
          Initial calls for init.
protected  void initEnd()
          Final calls for init.
protected abstract  I instantiateDeployInstance()
          Creates an instance.
protected  boolean isControllerModified()
           
protected  boolean isControllerModifiedNow()
           
 boolean isIdleTimeout()
          Returns true if the instance has been idle for longer than its timeout.
 boolean isModified()
          Returns true if the entry is modified.
 boolean isModifiedNow()
          Returns true if the entry is modified.
 boolean isNameMatch(java.lang.String name)
          Returns true if
 boolean logModified(java.util.logging.Logger log)
          Log the reason for modification
 void merge(DeployControllerApi<I> newController)
          Merges with the new controller information
 void mergeRedeployCheckInterval(long interval)
          Sets the redeploy-check-interval
 void mergeRedeployMode(DeployMode mode)
          Merge the redeploy mode.
protected  void onActive()
           
protected  void onDestroy()
           
protected  void onError(java.lang.Throwable e)
           
protected  void onStartComplete()
           
protected  void onStop()
           
protected  void postConfigureInstance(I deployInstance)
          After instance configuration
protected  void preConfigureInstance(I deployInstance)
          Before instance configuration
 I request()
          Returns the instance for a top-level request
 void restart()
          Force an instance restart from an admin command.
 void setActiveWaitTimeMillis(long wait)
          Sets the delay time waiting for a restart
 void setControllerType(DeployControllerType type)
           
 void setRedeployCheckInterval(Period period)
          Sets the redeploy-check-interval
 void setRedeployMode(DeployMode mode)
          Sets the redeploy mode.
 void setStartupMode(DeployMode mode)
          Sets the startup mode.
 void setStartupPriority(int priority)
          Sets the startup priority.
 void start()
          Force an instance start from an admin command.
protected  I startImpl()
          Starts the entry.
 void startOnInit()
          Starts the entry on initialization
 void stop()
          Stops the controller from an admin command.
protected  void stopImpl()
          Stops the current instance.
protected  void stopLazyImpl()
          Stops the current instance, putting it in the lazy state.
 I subrequest()
          Returns the instance for a subrequest.
 void toRestart()
           
 void toStart()
           
 void toStop()
           
 java.lang.String toString()
          Returns the entry's debug name.
 void update()
          Update the controller from an admin command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

REDEPLOY_CHECK_INTERVAL

public static final long REDEPLOY_CHECK_INTERVAL
See Also:
Constant Field Values

_lifecycle

protected final Lifecycle _lifecycle
Constructor Detail

DeployController

protected DeployController(java.lang.String id)

DeployController

protected DeployController(java.lang.String id,
                           java.lang.ClassLoader parentLoader)
Method Detail

instantiateDeployInstance

protected abstract I instantiateDeployInstance()
Creates an instance.


getId

public final java.lang.String getId()
Returns the controller's id.

Specified by:
getId in interface DeployControllerApi<I extends DeployInstance>

getIdStage

public final java.lang.String getIdStage()

getIdType

public final java.lang.String getIdType()

getIdKey

public final java.lang.String getIdKey()

getParentClassLoader

public java.lang.ClassLoader getParentClassLoader()
Returns the parent class loader.


getControllerType

public DeployControllerType getControllerType()
Description copied from interface: DeployControllerApi
Returns the controller type

Specified by:
getControllerType in interface DeployControllerApi<I extends DeployInstance>

setControllerType

public void setControllerType(DeployControllerType type)

setStartupMode

public void setStartupMode(DeployMode mode)
Sets the startup mode.


setStartupPriority

public void setStartupPriority(int priority)
Sets the startup priority.


getStartupPriority

public int getStartupPriority()
Gets the startup priority.

Specified by:
getStartupPriority in interface DeployControllerApi<I extends DeployInstance>

merge

public void merge(DeployControllerApi<I> newController)
Merges with the new controller information

Specified by:
merge in interface DeployControllerApi<I extends DeployInstance>

getStartupMode

public DeployMode getStartupMode()
Returns the startup mode.


setRedeployMode

public void setRedeployMode(DeployMode mode)
Sets the redeploy mode.


mergeRedeployMode

public void mergeRedeployMode(DeployMode mode)
Merge the redeploy mode.


getRedeployMode

public DeployMode getRedeployMode()
Returns the redeploy mode.


mergeRedeployCheckInterval

public void mergeRedeployCheckInterval(long interval)
Sets the redeploy-check-interval


setRedeployCheckInterval

public void setRedeployCheckInterval(Period period)
Sets the redeploy-check-interval


getRedeployCheckInterval

public long getRedeployCheckInterval()
Gets the redeploy-check-interval


setActiveWaitTimeMillis

public void setActiveWaitTimeMillis(long wait)
Sets the delay time waiting for a restart


getActiveWaitTime

public long getActiveWaitTime()

isNameMatch

public boolean isNameMatch(java.lang.String name)
Returns true if

Specified by:
isNameMatch in interface DeployControllerApi<I extends DeployInstance>

getStartTime

public final long getStartTime()
Returns the start time of the entry.


init

public final boolean init()
Initialize the entry.

Specified by:
init in interface DeployControllerApi<I extends DeployInstance>

initBegin

protected void initBegin()
Initial calls for init.


initEnd

protected void initEnd()
Final calls for init.


getState

public final LifecycleState getState()
Returns the state name.

Specified by:
getState in interface DeployControllerApi<I extends DeployInstance>

isIdleTimeout

public final boolean isIdleTimeout()
Returns true if the instance has been idle for longer than its timeout.

Returns:
true if idle

isModified

public boolean isModified()
Returns true if the entry is modified.

Specified by:
isModified in interface Dependency

isModifiedNow

public boolean isModifiedNow()
Returns true if the entry is modified.


logModified

public final boolean logModified(java.util.logging.Logger log)
Log the reason for modification

Specified by:
logModified in interface Dependency

isControllerModified

protected boolean isControllerModified()

isControllerModifiedNow

protected boolean isControllerModifiedNow()

controllerLogModified

protected boolean controllerLogModified(java.util.logging.Logger log)

getDeployInstance

public I getDeployInstance()
Returns the current instance.

Specified by:
getDeployInstance in interface DeployControllerApi<I extends DeployInstance>

getActiveDeployInstance

public I getActiveDeployInstance()
Description copied from interface: DeployControllerApi
Returns the current instance, waiting for active.

Specified by:
getActiveDeployInstance in interface DeployControllerApi<I extends DeployInstance>

getDeployInstanceImpl

public I getDeployInstanceImpl()
Returns the current instance.


createDeployInstance

protected final I createDeployInstance()
Returns the current instance.


addLifecycleListener

public void addLifecycleListener(LifecycleListener listener)
Description copied from interface: DeployControllerApi
External lifecycle listeners, so applications can detect deployment and redeployment.

Specified by:
addLifecycleListener in interface DeployControllerApi<I extends DeployInstance>

startOnInit

public void startOnInit()
Starts the entry on initialization

Specified by:
startOnInit in interface DeployControllerApi<I extends DeployInstance>

start

public final void start()
Force an instance start from an admin command.

Specified by:
start in interface DeployControllerApi<I extends DeployInstance>

stop

public final void stop()
Stops the controller from an admin command.

Specified by:
stop in interface DeployControllerApi<I extends DeployInstance>

restart

public final void restart()
Force an instance restart from an admin command.

Specified by:
restart in interface DeployControllerApi<I extends DeployInstance>

update

public final void update()
Update the controller from an admin command.

Specified by:
update in interface DeployControllerApi<I extends DeployInstance>

request

public final I request()
Returns the instance for a top-level request

Specified by:
request in interface DeployControllerApi<I extends DeployInstance>
Returns:
the request object or null for none.

subrequest

public final I subrequest()
Returns the instance for a subrequest.

Specified by:
subrequest in interface DeployControllerApi<I extends DeployInstance>
Returns:
the request object or null for none.

startImpl

protected I startImpl()
Starts the entry.


stopLazyImpl

protected void stopLazyImpl()
Stops the current instance, putting it in the lazy state.


stopImpl

protected void stopImpl()
Stops the current instance.


destroyInstance

protected void destroyInstance(I instance)

onActive

protected void onActive()

onError

protected void onError(java.lang.Throwable e)

onStartComplete

protected void onStartComplete()

onStop

protected void onStop()

preConfigureInstance

protected void preConfigureInstance(I deployInstance)
                             throws java.lang.Exception
Before instance configuration

Throws:
java.lang.Exception

configureInstance

protected void configureInstance(I deployInstance)
                          throws java.lang.Exception
Configuration of the instance

Throws:
java.lang.Exception

postConfigureInstance

protected void postConfigureInstance(I deployInstance)
                              throws java.lang.Exception
After instance configuration

Throws:
java.lang.Exception

toStart

public void toStart()
Specified by:
toStart in interface DeployActionHandler

toStop

public void toStop()
Specified by:
toStop in interface DeployActionHandler

toRestart

public void toRestart()
Specified by:
toRestart in interface DeployActionHandler

alarm

public final void alarm()
Description copied from interface: DeployControllerApi
Internal notification for modification updates, either from a timer or a repository notification. Depending on the restart mode, the alarm may trigger a restart.

Specified by:
alarm in interface DeployControllerApi<I extends DeployInstance>

close

public final void close()
Description copied from interface: DeployControllerApi
Closes the controller

Specified by:
close in interface DeployControllerApi<I extends DeployInstance>

destroy

protected boolean destroy()
Destroys the entry.


onDestroy

protected void onDestroy()

getLog

protected java.util.logging.Logger getLog()
Returns the appropriate log for debugging.


toString

public java.lang.String toString()
Returns the entry's debug name.

Overrides:
toString in class java.lang.Object