net.grinder.console.distribution
Class FileDistributionImplementation

java.lang.Object
  extended by net.grinder.console.distribution.FileDistributionImplementation
All Implemented Interfaces:
FileChangeWatcher, FileDistribution

public final class FileDistributionImplementation
extends Object
implements FileDistribution

FileDistribution implementation.

Instantiated by PicoContainer.

Author:
Philip Aston

Nested Class Summary
 
Nested classes/interfaces inherited from interface net.grinder.console.distribution.FileChangeWatcher
FileChangeWatcher.FileChangedListener
 
Constructor Summary
FileDistributionImplementation(DistributionControl distributionControl, ProcessControl processControl, Directory directory, Pattern distributionFileFilterPattern)
          Constructor.
 
Method Summary
 void addFileChangedListener(FileChangeWatcher.FileChangedListener listener)
          Add a listener that will be sent events about files that have changed when scanDistributionFiles() is called.
 AgentCacheState getAgentCacheState()
          Accessor for our AgentCacheState.
 FileFilter getDistributionFileFilter()
          Return a FileFilter that can be used to test whether the given file is one that will be distributed.
 FileDistributionHandler getHandler()
          Get a FileDistributionHandler for a new file distribution.
 void scanDistributionFiles()
          Scan the given directory for files that have been recently modified.
 void setDirectory(Directory directory)
          Update the distribution directory.
 void setFileFilterPattern(Pattern distributionFileFilterPattern)
          Update the pattern used to filter out files that shouldn't be distributed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileDistributionImplementation

public FileDistributionImplementation(DistributionControl distributionControl,
                                      ProcessControl processControl,
                                      Directory directory,
                                      Pattern distributionFileFilterPattern)
Constructor.

Parameters:
distributionControl - A DistributionControl.
processControl - A process control.
directory - The base distribution directory.
distributionFileFilterPattern - - The filter. Files with names that match this pattern will be filtered out.
Method Detail

setDirectory

public void setDirectory(Directory directory)
Update the distribution directory.

Specified by:
setDirectory in interface FileDistribution
Parameters:
directory - The base distribution directory.

setFileFilterPattern

public void setFileFilterPattern(Pattern distributionFileFilterPattern)
Update the pattern used to filter out files that shouldn't be distributed.

Specified by:
setFileFilterPattern in interface FileDistribution
Parameters:
distributionFileFilterPattern - - The filter. Files with names that match this pattern will be filtered out.

getAgentCacheState

public AgentCacheState getAgentCacheState()
Accessor for our AgentCacheState.

Specified by:
getAgentCacheState in interface FileDistribution
Returns:
The agent cache state.

getHandler

public FileDistributionHandler getHandler()
Get a FileDistributionHandler for a new file distribution.

The FileDistributionHandler updates our simple model of the remote cache state. Callers should only use one FileDistributionHandler at a time for a given FileDistribution. Using multiple instances concurrently will result in undefined behaviour.

Specified by:
getHandler in interface FileDistribution
Returns:
Handler for new file distribution.

scanDistributionFiles

public void scanDistributionFiles()
Scan the given directory for files that have been recently modified. Update the agent cache state appropriately. Notify our listeners if changed files are discovered.

This method is too coupled to the agent cache. Perhaps this and the file watcher support should be factored out into a separate class.

Currently, the file listeners only get notification for things that match the distribution filter.

Specified by:
scanDistributionFiles in interface FileDistribution

addFileChangedListener

public void addFileChangedListener(FileChangeWatcher.FileChangedListener listener)
Add a listener that will be sent events about files that have changed when scanDistributionFiles() is called.

Specified by:
addFileChangedListener in interface FileChangeWatcher
Parameters:
listener - The listener.

getDistributionFileFilter

public FileFilter getDistributionFileFilter()
Return a FileFilter that can be used to test whether the given file is one that will be distributed.

Specified by:
getDistributionFileFilter in interface FileDistribution
Returns:
The filter. Its behaviour will change according to the current filter pattern.
See Also:
setFileFilterPattern(Pattern)


Copyright © 2000-2013. All Rights Reserved.