org.ow2.jonas.deployablemonitor
Class DeployableMonitor

java.lang.Object
  extended by java.lang.Thread
      extended by org.ow2.jonas.deployablemonitor.DeployableMonitor
All Implemented Interfaces:
Runnable

public class DeployableMonitor
extends Thread

This monitor will search all the deployable from a list of directories.
In development mode, this monitor will detect changes on the deployables and then restart or undeploy them if they have been changed or removed.

Author:
Florent BENOIT

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
DeployableMonitor(DeployableMonitorService service)
          Constructor of this monitor.
 
Method Summary
 org.ow2.util.ee.deploy.api.deployer.IDeployerManager getDeployerManager()
           
 List<File> getDirectories()
           
protected  long getLastModified(File archive)
          Gets the last modified attribute of a given archive.
If it is a directory, returns the last modified file of the archive.
protected  boolean hasBeenUpdated(File file)
          Check if the given file has been updated since the last check.
 boolean isDevelopmentMode()
           
 void reset()
          reset the state of all deployables.
 void run()
          Start the thread of this class.
 void setDeployerManager(org.ow2.util.ee.deploy.api.deployer.IDeployerManager deployerManager)
          Sets the deployer manager for deployers.
 void setDevelopmentMode(boolean developmentMode)
          Enable or disable the development mode.
 void setDirectories(List<File> directories)
          Sets the list of directories to monitor.
 void setExclusionPatterns(List<String> patterns)
           
 void setMonitorInterval(int monitorInterval)
          Set the monitor interval between each directory scan.
 void stopOrder()
          Receives a stop order.
 
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
 

Constructor Detail

DeployableMonitor

public DeployableMonitor(DeployableMonitorService service)
Constructor of this monitor.

Parameters:
service - the DeployableMonitorService instance
Method Detail

reset

public void reset()
reset the state of all deployables.


run

public void run()
Start the thread of this class.
It will search and deploy files to deploy.
In development mode, it will check the changes.

Specified by:
run in interface Runnable
Overrides:
run in class Thread

getLastModified

protected long getLastModified(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.

hasBeenUpdated

protected boolean hasBeenUpdated(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

getDirectories

public List<File> getDirectories()
Returns:
the list of directories that this monitor is monitoring.

setDirectories

public void setDirectories(List<File> directories)
Sets the list of directories to monitor.

Parameters:
directories - the list of directories to use.

isDevelopmentMode

public boolean isDevelopmentMode()
Returns:
true if the development is enabled, else false (production mode).

setDevelopmentMode

public void setDevelopmentMode(boolean developmentMode)
Enable or disable the development mode.

Parameters:
developmentMode - true if it has to be enabled.

setMonitorInterval

public void setMonitorInterval(int monitorInterval)
Set the monitor interval between each directory scan.

Parameters:
monitorInterval - value to set

stopOrder

public void stopOrder()
Receives a stop order.


getDeployerManager

public org.ow2.util.ee.deploy.api.deployer.IDeployerManager getDeployerManager()
Returns:
the instance of the deployer manager.

setDeployerManager

public void setDeployerManager(org.ow2.util.ee.deploy.api.deployer.IDeployerManager deployerManager)
Sets the deployer manager for deployers.

Parameters:
deployerManager - the instance of the deployer manager.

setExclusionPatterns

public void setExclusionPatterns(List<String> patterns)
Parameters:
patterns - List of exclusion patterns.


Copyright © 2010 OW2 Consortium. All Rights Reserved.