org.objectweb.easybeans.server
Class ContainersMonitor

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

public class ContainersMonitor
extends java.lang.Thread

This class monitors the archives managed by containers and reload them if the archive is changed.

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  Embedded embedded
          Embedded server which is monitored.
private  JLog logger
          Logger.
private  java.util.Map<EZBContainer,java.lang.Long> modifiedFiles
          Map between container and the last updated file.
private static int SLEEP_TIME
          Sleep time for the thread of the cleaner (5s).
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ContainersMonitor(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  long getLastModified(java.io.File archive)
          Gets the last modified attribute of a given archive.
If it is a directory, returns the last modified file of the archive.
 void init()
          Init containers (call at startup).
 void run()
          Start the thread of this class It will clean all the work entries.
private  void scanNewContainers()
          Scan all files present in the ejb3 directory and create container for each one.
 
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<EZBContainer,java.lang.Long> modifiedFiles
Map between container and the last updated file.


embedded

private Embedded embedded
Embedded server which is monitored.


bootInProgress

private boolean bootInProgress
Initializing period ?.

Constructor Detail

ContainersMonitor

public ContainersMonitor(Embedded embedded)
Builds a new monitor by initializing lists.

Parameters:
embedded - the embedded server which is monitored.
Method Detail

init

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


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 java.lang.Thread

scanNewContainers

private void scanNewContainers()
Scan all files present in the ejb3 directory and create container for each one.


checkContainer

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

Parameters:
container - the container to monitor.

getLastModified

protected long getLastModified(java.io.File archive)
Gets the last modified attribute of a given archive.
If it is a directory, returns the last modified file of the archive.

Parameters:
archive - the archive to monitor.
Returns:
the last modified version of the given archive.