com.atlassian.plugin.loaders
Class DirectoryScanner

java.lang.Object
  extended by com.atlassian.plugin.loaders.DirectoryScanner
All Implemented Interfaces:
Scanner

public class DirectoryScanner
extends Object
implements Scanner

Scans the filesystem for changed or added plugin files and stores a map of the currently known ones. Files beginning with "." are ignored.

Since:
2.1.0

Constructor Summary
DirectoryScanner(File pluginsDirectory)
          Constructor for scanner.
 
Method Summary
 void clear(File file)
          Tells the Scanner to forget about a file it has loaded so that it will reload it next time it scans.
 Collection<DeploymentUnit> getDeploymentUnits()
          Retrieve all the DeploymentUnits currently stored.
 DeploymentUnit locateDeploymentUnit(File file)
          Given a file, finds the deployment unit for it if one has already been scanned.
 void remove(DeploymentUnit unit)
          Remove the specified deployment unit in such a way as it will not be picked up by subsequent scans, even if the system is restarted.
 void reset()
          Clears the list of scanned deployment units.
 Collection<DeploymentUnit> scan()
          Scans for all files and directories that have been added or modified since the last call to scan.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DirectoryScanner

public DirectoryScanner(File pluginsDirectory)
Constructor for scanner.

Parameters:
pluginsDirectory - the directory that the scanner should monitor for plugins
Method Detail

locateDeploymentUnit

public DeploymentUnit locateDeploymentUnit(File file)
Given a file, finds the deployment unit for it if one has already been scanned.

Parameters:
file - a jar file.
Returns:
the stored deploymentUnit matching the file or null if none exists.

clear

public void clear(File file)
Tells the Scanner to forget about a file it has loaded so that it will reload it next time it scans.

Parameters:
file - a file that may have already been scanned.

scan

public Collection<DeploymentUnit> scan()
Scans for all files and directories that have been added or modified since the last call to scan. This will ignore all files or directories starting with the '.' character.

Specified by:
scan in interface Scanner
Returns:
Collection of DeploymentUnits that describe newly added files or directories.

getDeploymentUnits

public Collection<DeploymentUnit> getDeploymentUnits()
Retrieve all the DeploymentUnits currently stored.

Specified by:
getDeploymentUnits in interface Scanner
Returns:
the complete unmodifiable list of scanned DeploymentUnits.

reset

public void reset()
Clears the list of scanned deployment units.

Specified by:
reset in interface Scanner

remove

public void remove(DeploymentUnit unit)
            throws PluginException
Description copied from interface: Scanner
Remove the specified deployment unit in such a way as it will not be picked up by subsequent scans, even if the system is restarted.

Specified by:
remove in interface Scanner
Parameters:
unit - the deployment unit to remove
Throws:
PluginException - if the unit has not been properly removed: i.e. a restart would mean the unit would be reloaded.


Copyright © 2014 Atlassian. All rights reserved.