org.apache.avalon.extension.manager.impl
Class DefaultExtensionManager

java.lang.Object
  extended byorg.apache.avalon.extension.manager.impl.DefaultExtensionManager
All Implemented Interfaces:
ExtensionManager

public class DefaultExtensionManager
extends Object
implements ExtensionManager

Interface used to contain "Optional Packages" (formerly known as "Standard Extensions"). It is assumed that each "Optional Package" is represented by a single file on the file system. This Repository searches a path to find the Optional Packages.

Version:
$Revision: 1.2 $ $Date: 2003/12/05 15:13:04 $
Author:
Peter Donald
See Also:
OptionalPackage, ExtensionManager

Field Summary
 
Fields inherited from interface org.apache.avalon.extension.manager.ExtensionManager
ROLE
 
Constructor Summary
DefaultExtensionManager()
          Construct a package repository with no path specified.
DefaultExtensionManager(File[] path)
          Construct a package repository with path.
 
Method Summary
protected  void addPathElements(File[] path)
          Add path elements to repository search path
protected  void addPathElements(String pathString)
          Add path elements to repository search path.
protected  void addPathElements(String[] pathElements)
          Add path elements to repository search path
protected  void cacheOptionalPackage(OptionalPackage optionalPackage)
          Add OptionalPackage to internal cache of Optional Packages.
protected  void clearCache()
          Clear internal cache of optional packages.
protected  void debug(String message)
          Output a debug message for repository.
protected  OptionalPackage[] getAllOptionalPackages()
          Return all the OptionalPackages stored in ExtensionManager.
 OptionalPackage[] getOptionalPackages(Extension extension)
          Return all the OptionalPackages that satisfy specified Extension.
 File[] getPaths()
          Return an array of path elements where each element in array represents a directory in which the ExtensionManager will look for Extensions.
protected  void scanPath()
          Scan the path for this repository and reload all the "Optional Packages" found in the path.
protected  void setPath(File[] path)
          Set the path for the Repository.
protected  void setPath(String pathString)
          Set the path for the Repository.
protected  void setPath(String[] pathElements)
          Set the path for the Repository.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultExtensionManager

public DefaultExtensionManager()
Construct a package repository with no path specified.


DefaultExtensionManager

public DefaultExtensionManager(File[] path)
Construct a package repository with path.

Parameters:
path - The set of directories in which to look for Optional Packages
Method Detail

getPaths

public File[] getPaths()
Return an array of path elements where each element in array represents a directory in which the ExtensionManager will look for Extensions.

Returns:
the list of paths to search in

getOptionalPackages

public OptionalPackage[] getOptionalPackages(Extension extension)
Return all the OptionalPackages that satisfy specified Extension. It is expected that this Extension object will be one retrieved via getLocalExtension() method. If the specified Extension is not local then null is returned.

Specified by:
getOptionalPackages in interface ExtensionManager
Parameters:
extension - the extension to search for
Returns:
an array of optional packages that satisfy the extension (and the extensions dependencies)
See Also:
OptionalPackage, Extension

getAllOptionalPackages

protected OptionalPackage[] getAllOptionalPackages()
Return all the OptionalPackages stored in ExtensionManager.

Returns:
all the OptionalPackages stored in ExtensionManager.

addPathElements

protected void addPathElements(String[] pathElements)
Add path elements to repository search path

Parameters:
pathElements - the path elements to add to repository search path

addPathElements

protected void addPathElements(File[] path)
Add path elements to repository search path

Parameters:
path - the path elements to add to repository search path

addPathElements

protected void addPathElements(String pathString)
Add path elements to repository search path. Note that each path element is separated by a '|' character.

Parameters:
pathString - the path elements to add to repository search path

setPath

protected void setPath(String pathString)
Set the path for the Repository. Note thart each path element is separated by a '|' character.

Parameters:
pathString - the list of directories in which to search

setPath

protected void setPath(String[] pathElements)
Set the path for the Repository.

Parameters:
pathElements - the list of directories in which to search

setPath

protected void setPath(File[] path)
Set the path for the Repository.

Parameters:
path - the list of directories in which to search

scanPath

protected final void scanPath()
Scan the path for this repository and reload all the "Optional Packages" found in the path. All of the old Extensions/Optional Packages will be removed.


clearCache

protected final void clearCache()
Clear internal cache of optional packages.


cacheOptionalPackage

protected final void cacheOptionalPackage(OptionalPackage optionalPackage)
Add OptionalPackage to internal cache of Optional Packages. Note that this method is only protected so that unit tests can sub-class and add entries to PackageRepository by calling this method.

Parameters:
optionalPackage - the OptionalPackage to be added to repository

debug

protected void debug(String message)
Output a debug message for repository.

Parameters:
message - the debug message


Copyright © Apache Software Foundation. All Rights Reserved.