org.objectweb.easybeans.server
Class DirectoryDeployerMonitor

java.lang.Object
  extended by java.lang.Thread
      extended by org.objectweb.easybeans.server.ContainersMonitor
          extended by org.objectweb.easybeans.server.DirectoryDeployerMonitor
All Implemented Interfaces:
java.lang.Runnable

public class DirectoryDeployerMonitor
extends ContainersMonitor

This class monitors scan the directory and deploy archive if any. Also, archives are monitored. If there is a change, the archive is reloaded or undeployed and then deployed.

Author:
Florent Benoit

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private  boolean bootInProgress
          Initializing period ?.
private  java.util.Map<java.io.File,EZBDeployable> deployed
          List of deployed files (by this monitor).
private  EZBDeployer deployer
          Deployer.
private  java.util.List<java.io.File> failed
          List of File that have a failed deployment (by this monitor).
private  JLog logger
          Logger.
private  java.util.Map<java.io.File,java.lang.Long> modifiedFiles
          Map between an File (monitored) and the last updated file.
private static int SLEEP_TIME
          Sleep time for the thread of the cleaner (5s).
private  boolean stopped
          Stop order received ?
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
DirectoryDeployerMonitor(Embedded embedded)
          Builds a new monitor by initializing lists.
 
Method Summary
protected  void checkContainer(EZBContainer container)
          Check a container (and its archive) and see if there is a need to reload the container.
protected  void checkModifiedDeployables()
          Check if the current deployables that are deployed have been updated.
private  void detectNewArchives()
          Scan all files present in the deploy directory and deploy them.
protected  boolean hasBeenUpdated(java.io.File file)
          Check if the given file has been updated since the last check.
 void init()
          Init containers (call at startup).
 void run()
          Start the thread of this class It will clean all the work entries.
 void stopOrder()
          Receives a stop order.
 
Methods inherited from class org.objectweb.easybeans.server.ContainersMonitor
getEmbedded, getLastModified
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SLEEP_TIME

private static final int SLEEP_TIME
Sleep time for the thread of the cleaner (5s).

See Also:
Constant Field Values

logger

private JLog logger
Logger.


modifiedFiles

private java.util.Map<java.io.File,java.lang.Long> modifiedFiles
Map between an File (monitored) and the last updated file.


deployed

private java.util.Map<java.io.File,EZBDeployable> deployed
List of deployed files (by this monitor).


failed

private java.util.List<java.io.File> failed
List of File that have a failed deployment (by this monitor).


bootInProgress

private boolean bootInProgress
Initializing period ?.


stopped

private boolean stopped
Stop order received ?


deployer

private EZBDeployer deployer
Deployer.

Constructor Detail

DirectoryDeployerMonitor

public DirectoryDeployerMonitor(Embedded embedded)
                         throws EmbeddedException
Builds a new monitor by initializing lists.

Parameters:
embedded - the embedded server which is monitored.
Throws:
EmbeddedException - if there is an exception for this monitor.
Method Detail

init

public void init()
Init containers (call at startup).

Overrides:
init in class ContainersMonitor

run

public void run()
Start the thread of this class It will clean all the work entries.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class ContainersMonitor

detectNewArchives

private void detectNewArchives()
                        throws EmbeddedException
Scan all files present in the deploy directory and deploy them. (if not deployed).

Throws:
EmbeddedException - if there is a problem during the scan

hasBeenUpdated

protected boolean hasBeenUpdated(java.io.File file)
Check if the given file has been updated since the last check.

Parameters:
file - the file to test
Returns:
true if the archive has been updated

checkModifiedDeployables

protected void checkModifiedDeployables()
                                 throws EmbeddedException
Check if the current deployables that are deployed have been updated. If it is the case, undeploy them and then deploy it again (except for EJB3 Deployable where there is a stop/start).

Throws:
EmbeddedException - if the redeployment fails

checkContainer

protected void checkContainer(EZBContainer container)
Check a container (and its archive) and see if there is a need to reload the container.

Overrides:
checkContainer in class ContainersMonitor
Parameters:
container - the container to monitor.

stopOrder

public void stopOrder()
Receives a stop order.

Overrides:
stopOrder in class ContainersMonitor