org.eclipse.jetty.policy
Class PolicyMonitor

java.lang.Object
  extended by org.eclipse.jetty.util.component.AbstractLifeCycle
      extended by org.eclipse.jetty.policy.PolicyMonitor
All Implemented Interfaces:
LifeCycle

public abstract class PolicyMonitor
extends AbstractLifeCycle

PolicyMonitor watches a directory for files ending in the *.policy extension, loads them and detects when they change. PolicyGrants are peeped out the onPolicyChange method to whoever is using this monitor.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener
 
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
 
Field Summary
 
Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
 
Constructor Summary
PolicyMonitor()
          empty constructor
PolicyMonitor(String directory)
          construtor with a predetermined directory to monitor
 
Method Summary
protected  void doStart()
          called by the abstract lifecycle to start the monitor
protected  void doStop()
          called by the abstract life cycle to turn off the monitor
 int getScanCount()
          gets the number of times the scan has been run
 int getScanInterval()
          gets the scanner interval
 boolean isInitialized()
          true of the monitor is initialized, meaning that at least one scan cycle has completed and any policy grants found have been chirped
 boolean isReloadEnabled()
          true of reload is enabled, false otherwise
abstract  void onPolicyChange(PolicyBlock grant)
          implemented by the user of the policy monitor to handle custom logic related to the usage of the policy grant instance/s.
 void setPolicyDirectory(String directory)
          set the policy directory to scan on a non-running monitor
 void setReload(boolean reload)
          sets the monitor to reload or not, but only if the monitor isn't already running TODO this doesn't really _have_ to be on a non-running monitor
 void setScanInterval(int scanInterval)
          sets the scanner interval on a non-running instance of the monitor
 void waitForScan()
          initiates a scan and blocks until it has been completed
 
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PolicyMonitor

public PolicyMonitor()
empty constructor


PolicyMonitor

public PolicyMonitor(String directory)
construtor with a predetermined directory to monitor

Parameters:
directory -
Method Detail

setPolicyDirectory

public void setPolicyDirectory(String directory)
set the policy directory to scan on a non-running monitor

Parameters:
directory -

getScanInterval

public int getScanInterval()
gets the scanner interval

Returns:
the scan interval

setScanInterval

public void setScanInterval(int scanInterval)
sets the scanner interval on a non-running instance of the monitor

Parameters:
scanInterval - in seconds
See Also:
Scanner.setScanInterval(int)

isInitialized

public boolean isInitialized()
true of the monitor is initialized, meaning that at least one scan cycle has completed and any policy grants found have been chirped

Returns:
true if initialized

getScanCount

public int getScanCount()
gets the number of times the scan has been run

Returns:
scan count

waitForScan

public void waitForScan()
                 throws Exception
initiates a scan and blocks until it has been completed

Throws:
Exception

isReloadEnabled

public boolean isReloadEnabled()
true of reload is enabled, false otherwise

Returns:
true if reload is enabled

setReload

public void setReload(boolean reload)
sets the monitor to reload or not, but only if the monitor isn't already running TODO this doesn't really _have_ to be on a non-running monitor

Parameters:
reload -

doStart

protected void doStart()
                throws Exception
called by the abstract lifecycle to start the monitor

Overrides:
doStart in class AbstractLifeCycle
Throws:
Exception

doStop

protected void doStop()
               throws Exception
called by the abstract life cycle to turn off the monitor

Overrides:
doStop in class AbstractLifeCycle
Throws:
Exception

onPolicyChange

public abstract void onPolicyChange(PolicyBlock grant)
implemented by the user of the policy monitor to handle custom logic related to the usage of the policy grant instance/s.

Parameters:
grant -


Copyright © 1995-2011 Mort Bay Consulting. All Rights Reserved.