|
3.2.4: 2013-12-06 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.basedb.util.extensions.manager.ExtensionsManager
public class ExtensionsManager
An extensions manager is responsible for handling a group of extensions in the form of files stored in the file system. The manager will keep track of added, updated and removed files.
Nested Class Summary | |
---|---|
static class |
ExtensionsManager.JarFirstURIComparator
Compare URI:s so that 'jar:' scheme always are listed first. |
Field Summary | |
---|---|
private Set<File> |
directories
|
private Set<File> |
ignore
|
private Map<ObjectKey<?>,ExtensionsFile> |
installedObjects
|
private static org.apache.log4j.Logger |
log
|
private int |
numDeleted
|
private int |
numModified
|
private int |
numNew
|
private int |
numUnmodified
|
private Registry |
registry
|
private Settings |
settings
|
private Map<URI,ExtensionsFile> |
xtFiles
|
Constructor Summary | |
---|---|
ExtensionsManager(Registry registry,
File settingsFile)
Create a new extensions manager and use the given registry to store extensions. |
Method Summary | |
---|---|
int |
addDirectory(File dir)
Add a directory to this manager. |
private void |
addExtensionsFile(ExtensionsFile xtFile)
|
ExtensionsFile |
addFile(File file)
Add a file to the manager that is supposed to contain extensions. |
void |
addIgnore(File file)
Add a file to the ignore list. |
ExtensionsFile |
addURI(URI uri)
Add an URI that points to an XML file containing definitions. |
ExtensionsFile |
getFileByObjectKey(ObjectKey<?> key)
Find out which file the object with the given key was defined. |
ExtensionsFile |
getFileByURI(String uri)
Get the extension file that is located at the given URI. |
List<ExtensionsFile> |
getFiles()
Get a list of all extension files managed by this manager. |
int |
getNumDeleted()
Get the number of deleted files that was found in the last call to scanForChanges() . |
int |
getNumModified()
Get the number of modified files that was found in the last call to scanForChanges() . |
int |
getNumNew()
Get the number of new files that was found in the last call to scanForChanges() . |
int |
getNumUnmodified()
Get the number of unmodified files that was found in the last call to scanForChanges() . |
Registry |
getRegistry()
Get the registry in which all extensions that are managed by this manager are stored. |
Settings |
getSettings()
Get the settings for the extension manager. |
void |
processFiles(ExtensionsFileProcessor processor)
Process all know file with the given processer. |
void |
processFiles(ExtensionsFileProcessor processor,
Filter<ExtensionsFile> filter)
Process all known extension files with the given processor. |
(package private) void |
registerObject(ObjectKey<?> key,
ExtensionsFile xtFile)
Register an object as defined by the given extensions file. |
(package private) void |
removeFile(File file)
Remove a file from the extensions manager. |
void |
removeIgnore(File file)
Remove a file from the ignore list. |
int |
scanForChanges()
Scan the managed directories for new, updated and deleted files. |
private int |
scanForInstalledFiles(File dir,
Settings settings)
Scan the given directory and add files that are installed according to the settings. |
private int |
scanForNewFiles(File dir)
Scan the given directory and add files that are new. |
(package private) void |
unregisterAllObjects(ExtensionsFile xtFile)
Unregister all objects know in the file. |
(package private) void |
unregisterObject(ObjectKey<?> key,
ExtensionsFile xtFile)
Unregister an object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final org.apache.log4j.Logger log
private final Registry registry
private final Settings settings
private final Set<File> ignore
private final Set<File> directories
private final Map<URI,ExtensionsFile> xtFiles
private final Map<ObjectKey<?>,ExtensionsFile> installedObjects
private int numNew
private int numModified
private int numUnmodified
private int numDeleted
Constructor Detail |
---|
public ExtensionsManager(Registry registry, File settingsFile)
registry
- The registry to usesettingsFile
- The file were settings are storedMethod Detail |
---|
public Registry getRegistry()
public Settings getSettings()
public void addIgnore(File file)
file
- The file to addremoveIgnore(File)
public void removeIgnore(File file)
file
- The file to removeaddIgnore(File)
public int addDirectory(File dir)
Settings.isInstalledFile(File)
are loaded into manager.
This method call is ignored if the path is not pointing to an existing directory.
dir
- An existing directory
public ExtensionsFile addFile(File file)
file
- An extensions file (null is not allowed)
void removeFile(File file)
Note that if the file remains in a managed directory it will
reappear in the manager if scanForChanges()
is
called.
file
- The file to remove (if null this method is ignored)public ExtensionsFile addURI(URI uri)
This method can't be used for JAR files and if used for XML files it doesn't detect changes that are made after installation.
uri
- An URI pointing to an extensions file (null is not allowed)
private void addExtensionsFile(ExtensionsFile xtFile)
public int scanForChanges()
processFiles(ExtensionsFileProcessor)
method must be called.
Note! The new or modified status of files are NOT reset as a result of calling this method. The status can only be changed as a result of some processing.
public int getNumNew()
scanForChanges()
.
public int getNumModified()
scanForChanges()
.
public int getNumUnmodified()
scanForChanges()
.
public int getNumDeleted()
scanForChanges()
.
private int scanForNewFiles(File dir)
dir
- The directory to scan
private int scanForInstalledFiles(File dir, Settings settings)
dir
- The directory to scan
public List<ExtensionsFile> getFiles()
public ExtensionsFile getFileByURI(String uri)
addFile(File)
or
addDirectory(File)
.
uri
- An URI that is pointing to an extensions file
public ExtensionsFile getFileByObjectKey(ObjectKey<?> key)
ObjectKey
for various types
of objects to look for.
key
- The object key
void registerObject(ObjectKey<?> key, ExtensionsFile xtFile)
key
- The object keyxtFile
- The extensions file the object is defined invoid unregisterObject(ObjectKey<?> key, ExtensionsFile xtFile)
key
- The object keyxtFile
- The extensions file the object is defined invoid unregisterAllObjects(ExtensionsFile xtFile)
public void processFiles(ExtensionsFileProcessor processor)
processor
- A processor implementation, null is not allowedpublic void processFiles(ExtensionsFileProcessor processor, Filter<ExtensionsFile> filter)
processor
- A processor implementation, null is not allowedfilter
- An optional filter implementation that can be used to
limit which files are sent to the processor
|
3.2.4: 2013-12-06 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |