org.opensaml.util.resource
Class ResourceChangeWatcher

java.lang.Object
  extended by java.util.TimerTask
      extended by org.opensaml.util.resource.ResourceChangeWatcher
All Implemented Interfaces:
java.lang.Runnable

public class ResourceChangeWatcher
extends java.util.TimerTask

A watcher that invokes a callback when a resource update/deletion has been detected.


Field Summary
static int DEFAULT_MAX_RETRY_ATTEMPTS
          Default maximum retry attempts, 0.
static long DEFAULT_POLL_FREQUENCY
          Default polling frequency, 12 hours.
 
Constructor Summary
ResourceChangeWatcher(Resource resource)
          Constructor.
ResourceChangeWatcher(Resource resource, long pollingFrequency)
          Constructor.
ResourceChangeWatcher(Resource resource, long pollingFrequency, int retryAttempts)
          Constructor.
 
Method Summary
 long getPollingFrequency()
          Gets the frequency, in milliseconds, the watched resource should be polled.
 java.util.List<ResourceChangeListener> getResourceListeners()
          Gets the list of registered resource listeners.
 void run()
          
protected  void signalListeners(ResourceChangeListener.ResourceChange changeType)
          Signals all registered listeners of a resource change.
 
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_POLL_FREQUENCY

public static final long DEFAULT_POLL_FREQUENCY
Default polling frequency, 12 hours.

See Also:
Constant Field Values

DEFAULT_MAX_RETRY_ATTEMPTS

public static final int DEFAULT_MAX_RETRY_ATTEMPTS
Default maximum retry attempts, 0.

See Also:
Constant Field Values
Constructor Detail

ResourceChangeWatcher

public ResourceChangeWatcher(Resource resource)
                      throws ResourceException
Constructor.

Parameters:
resource - the resource to be watched
Throws:
ResourceException - thrown if resource existence or last modification time can not be determined

ResourceChangeWatcher

public ResourceChangeWatcher(Resource resource,
                             long pollingFrequency)
                      throws ResourceException
Constructor.

Parameters:
resource - the resource to be watched
pollingFrequency - the frequency, in milliseconds, to poll the resource for changes
Throws:
ResourceException - thrown if resource existence or last modification time can not be determined

ResourceChangeWatcher

public ResourceChangeWatcher(Resource resource,
                             long pollingFrequency,
                             int retryAttempts)
                      throws ResourceException
Constructor.

Parameters:
resource - the resource to be watched
pollingFrequency - the frequency, in milliseconds, to poll the resource for changes
retryAttempts - maximum number of poll attempts before the resource is considered inaccessible
Throws:
ResourceException - thrown if resource existence or last modification time can not be determined
Method Detail

getPollingFrequency

public long getPollingFrequency()
Gets the frequency, in milliseconds, the watched resource should be polled.

Returns:
frequency the watched resource should be polled

getResourceListeners

public java.util.List<ResourceChangeListener> getResourceListeners()
Gets the list of registered resource listeners. New listeners may be registered with the list or old ones removed.

Returns:
list of registered resource listeners

run

public void run()

Specified by:
run in interface java.lang.Runnable
Specified by:
run in class java.util.TimerTask

signalListeners

protected void signalListeners(ResourceChangeListener.ResourceChange changeType)
Signals all registered listeners of a resource change.

Parameters:
changeType - the resource change type


Copyright © 2006-2011 Internet2. All Rights Reserved.