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

java.lang.Object
  extended by com.caucho.server.deploy.DeployController<I>
All Implemented Interfaces:
AlarmListener, Dependency, java.util.EventListener
Direct Known Subclasses:
ExpandDeployController

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

DeployController controls the lifecycle of the DeployInstance.


Field Summary
protected  Lifecycle _lifecycle
           
static java.lang.String REDEPLOY_AUTOMATIC
           
static long REDEPLOY_CHECK_INTERVAL
           
static java.lang.String REDEPLOY_DEFAULT
           
static java.lang.String REDEPLOY_LAZY
           
static java.lang.String REDEPLOY_MANUAL
           
static java.lang.String STARTUP_AUTOMATIC
           
static java.lang.String STARTUP_DEFAULT
           
static java.lang.String STARTUP_LAZY
           
static java.lang.String STARTUP_MANUAL
           
 
Constructor Summary
protected DeployController(java.lang.String id)
           
protected DeployController(java.lang.String id, java.lang.ClassLoader parentLoader)
           
 
Method Summary
 void addLifecycleListener(LifecycleListener listener)
           
protected  void addManifestClassPath()
          Adds any manifest Class-Path
protected  void configureInstance(I deployInstance)
          Configuration of the instance
protected  boolean destroy()
          Destroys the entry.
protected  void expandArchive()
          Deploys the entry, e.g.
 java.lang.Throwable getConfigException()
           
protected  DeployControllerAdmin getDeployAdmin()
          Returns the deploy admin.
 I getDeployInstance()
          Returns the current instance.
 java.lang.String getId()
          Returns the controller's id.
protected  java.util.logging.Logger getLog()
          Returns the appropriate log for debugging.
protected  java.lang.String getMBeanId()
           
protected  java.lang.String getMBeanTypeName()
           
 java.lang.ClassLoader getParentClassLoader()
          Returns the parent class loader.
 long getRedeployCheckInterval()
          Gets the redeploy-check-interval
 java.lang.String getRedeployMode()
          Returns the redeploy mode.
 long getStartTime()
          Returns the start time of the entry.
 java.lang.String getStartupMode()
          Returns the startup mode.
 int getStartupPriority()
          Gets the startup priority.
 java.lang.String getState()
          Returns the state name.
 void handleAlarm(Alarm alarm)
          Handles the redeploy check alarm.
 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.
 boolean isActive()
          Returns true if the instance is in the active state.
 boolean isActiveIdle()
          Returns true if the instance has been idle for longer than its timeout.
 boolean isDestroyed()
          Returns true if the entry is destroyed.
 boolean isError()
          Return true if the instance is in the error state.
 boolean isErrorNow()
          Returns true if there's currently an error.
 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 the entry matches.
 boolean isStopped()
          Returns true if the instance is in the stopped state.
 boolean isStoppedLazy()
          Returns true for the stop-lazy state
 boolean logModified(java.util.logging.Logger log)
          Log the reason for modification
protected  void mergeController(DeployController oldController)
          Merges with the old controller.
 void mergeRedeployCheckInterval(long interval)
          Sets the redeploy-check-interval
 void mergeRedeployMode(java.lang.String mode)
          Merge the redeploy mode.
 void mergeStartupMode(java.lang.String mode)
          Merge the startup mode.
 I request()
          Returns the instance for a top-level request
 void restart()
          Force an instance restart from an admin command.
 void setRedeployCheckInterval(Period period)
          Sets the redeploy-check-interval
 void setRedeployMode(java.lang.String mode)
          Sets the redeploy mode.
 void setStartupMode(java.lang.String 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()
          Redeploys the entry if it's modified.
 void stop()
          Stops the controller from an admin command.
 I subrequest()
          Returns the instance for a subrequest.
static java.lang.String toRedeployCode(java.lang.String mode)
          Converts redeploy mode to code.
static java.lang.String toStartupCode(java.lang.String mode)
          Converts startup mode to code.
 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

STARTUP_DEFAULT

public static final java.lang.String STARTUP_DEFAULT
See Also:
Constant Field Values

STARTUP_AUTOMATIC

public static final java.lang.String STARTUP_AUTOMATIC
See Also:
Constant Field Values

STARTUP_LAZY

public static final java.lang.String STARTUP_LAZY
See Also:
Constant Field Values

STARTUP_MANUAL

public static final java.lang.String STARTUP_MANUAL
See Also:
Constant Field Values

REDEPLOY_DEFAULT

public static final java.lang.String REDEPLOY_DEFAULT
See Also:
Constant Field Values

REDEPLOY_AUTOMATIC

public static final java.lang.String REDEPLOY_AUTOMATIC
See Also:
Constant Field Values

REDEPLOY_LAZY

public static final java.lang.String REDEPLOY_LAZY
See Also:
Constant Field Values

REDEPLOY_MANUAL

public static final java.lang.String REDEPLOY_MANUAL
See Also:
Constant Field Values

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

addLifecycleListener

public void addLifecycleListener(LifecycleListener listener)

getId

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


getParentClassLoader

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


setStartupMode

public void setStartupMode(java.lang.String mode)
Sets the startup mode.


setStartupPriority

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


getStartupPriority

public int getStartupPriority()
Gets the startup priority.


mergeController

protected void mergeController(DeployController oldController)
Merges with the old controller.


mergeStartupMode

public void mergeStartupMode(java.lang.String mode)
Merge the startup mode.


getStartupMode

public java.lang.String getStartupMode()
Returns the startup mode.


toStartupCode

public static java.lang.String toStartupCode(java.lang.String mode)
                                      throws ConfigException
Converts startup mode to code.

Throws:
ConfigException

setRedeployMode

public void setRedeployMode(java.lang.String mode)
Sets the redeploy mode.


mergeRedeployMode

public void mergeRedeployMode(java.lang.String mode)
Merge the redeploy mode.


getRedeployMode

public java.lang.String getRedeployMode()
Returns the redeploy mode.


toRedeployCode

public static java.lang.String toRedeployCode(java.lang.String mode)
                                       throws ConfigException
Converts redeploy mode to code.

Throws:
ConfigException

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


isNameMatch

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


getStartTime

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


getDeployAdmin

protected DeployControllerAdmin getDeployAdmin()
Returns the deploy admin.


init

public final boolean init()
Initialize the entry.


initBegin

protected void initBegin()
Initial calls for init.


initEnd

protected void initEnd()
Final calls for init.


getMBeanTypeName

protected java.lang.String getMBeanTypeName()

getMBeanId

protected java.lang.String getMBeanId()

getState

public java.lang.String getState()
Returns the state name.


isActive

public boolean isActive()
Returns true if the instance is in the active state.


isStopped

public boolean isStopped()
Returns true if the instance is in the stopped state.

Returns:
true on stopped state

isStoppedLazy

public boolean isStoppedLazy()
Returns true for the stop-lazy state


isActiveIdle

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

Returns:
true if idle

isError

public boolean isError()
Return true if the instance is in the error state.

Returns:
true for the error state.

isErrorNow

public boolean isErrorNow()
Returns true if there's currently an error.


isModified

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

Specified by:
isModified in interface Dependency

logModified

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

Specified by:
logModified in interface Dependency

isModifiedNow

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


getDeployInstance

public final I getDeployInstance()
Returns the current instance.


startOnInit

public void startOnInit()
Redeploys the entry if it's modified.


start

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


getConfigException

public java.lang.Throwable getConfigException()

stop

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


restart

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


update

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


request

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

Returns:
the request object or null for none.

subrequest

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

Returns:
the request object or null for none.

startImpl

protected I startImpl()
Starts the entry.


expandArchive

protected void expandArchive()
                      throws java.lang.Exception
Deploys the entry, e.g. archive expansion.

Throws:
java.lang.Exception

instantiateDeployInstance

protected abstract I instantiateDeployInstance()
Creates an instance.


addManifestClassPath

protected void addManifestClassPath()
                             throws java.io.IOException
Adds any manifest Class-Path

Throws:
java.io.IOException

configureInstance

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

Throws:
java.lang.Throwable

handleAlarm

public void handleAlarm(Alarm alarm)
Handles the redeploy check alarm.

Specified by:
handleAlarm in interface AlarmListener

isDestroyed

public boolean isDestroyed()
Returns true if the entry is destroyed.


destroy

protected boolean destroy()
Destroys the entry.


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