|
3.0.2: 2012-01-25 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.basedb.util.extensions.manager.processor.RegisterExtensionsProcessor
public class RegisterExtensionsProcessor
Extension file processor implementation that will load the extension definitions from each file and register them with the registry that is managed by the manager. This processor is a two-step processer. The first step will load extension definitions from the files. The second step will register the loaded extension with the managers registry.
The first step is executed via the manager:
ExtensionsManager.processFiles(ExtensionsFileProcessor)
.
The second step is either automatically executed when all files
have been processed or executed by by calling
finalizeRegistration(ExtensionsManager, boolean)
.
Note! It is recommended that this processor is paired with a
ValidAndNewOrModifiedFilter
since it is usually no
point in trying to register invalid extensions.
Nested Class Summary | |
---|---|
(package private) static class |
RegisterExtensionsProcessor.FileData
Keep track of the extension points and extensions found in a file. |
Field Summary | |
---|---|
private List<RegisterExtensionsProcessor.FileData> |
allData
|
private boolean |
delayRegistration
|
private boolean |
forceUpdate
|
private XmlLoader |
loader
|
private static Logger |
log
|
private int |
numError
|
private int |
numFiles
|
private int |
numRegistered
|
private int |
numUnregistered
|
private ProcessResults |
results
|
Constructor Summary | |
---|---|
RegisterExtensionsProcessor(XmlLoader loader,
ProcessResults results)
Create a new processor. |
Method Summary | |
---|---|
void |
begin(ExtensionsManager manager,
int numFiles)
Called by the extensions manager before the processing starts. |
void |
done(ExtensionsManager manager)
Called by the extensions manager after a successful completion of the processing. |
void |
done(ExtensionsManager manager,
Throwable t)
Called by the extensions manager if an exception was thrown by the processor. |
void |
finalizeRegistration(ExtensionsManager manager,
boolean unregisterMissing)
|
int |
getNumError()
Get the number of files that was had an error. |
int |
getNumFiles()
Get the number of files that was successfully processed. |
int |
getNumRegistered()
Get the number of extensions + extension points that was registered. |
int |
getNumUnregistered()
Get the number of extensions + extension points that was unregistered. |
ProcessResults |
getProcessResults()
|
XmlLoader |
getXmlLoader()
Get the loader the processor is using for parsing xml files with extension definitions. |
boolean |
isRegistrationDelayed()
Is the actual registration delayed or not? |
void |
processFile(ExtensionsManager manager,
ExtensionsFile.WriteableExtensionsFile wFile)
Called by the extensions manager for each extensions file that it manages. |
private int |
registerExtensionPoints(RegisterExtensionsProcessor.FileData data,
Registry registry,
boolean forceUpdate)
|
private int |
registerExtensions(RegisterExtensionsProcessor.FileData data,
Registry registry,
boolean forceUpdate)
|
private void |
registerFactory(RegisterExtensionsProcessor.FileData data,
Object factory)
Register factory parameters for the given factory instance. |
void |
setDelayRegistration(boolean delayRegistration)
Set a flag to indicate if the actual registration of the found extensions and extension points should be delayed or not. |
void |
setForceUpdate(boolean forceUpdate)
Set a flag to indicate if already registered extensions should be re-registered or not. |
private boolean |
unregisterExtension(RegisterExtensionsProcessor.FileData data,
Extension ext,
Registry registry)
Unregister the given extension if it is not included in the new file data information. |
private boolean |
unregisterExtensionPoint(RegisterExtensionsProcessor.FileData data,
ExtensionPoint ep,
Registry registry)
Unregister the given extension point if it is not included in the new file data information. |
private void |
unregisterFactory(RegisterExtensionsProcessor.FileData data,
Object factory)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Logger log
private final XmlLoader loader
private final ProcessResults results
private boolean delayRegistration
private boolean forceUpdate
private List<RegisterExtensionsProcessor.FileData> allData
private int numFiles
private int numError
private int numRegistered
private int numUnregistered
Constructor Detail |
---|
public RegisterExtensionsProcessor(XmlLoader loader, ProcessResults results)
loader
- The XML loader to use when parsing the metadataMethod Detail |
---|
public void begin(ExtensionsManager manager, int numFiles)
ExtensionsFileProcessor
begin
in interface ExtensionsFileProcessor
manager
- The manager that is executing the actionnumFiles
- The number of extension files that is going to be processed this timepublic void processFile(ExtensionsManager manager, ExtensionsFile.WriteableExtensionsFile wFile)
ExtensionsFileProcessor
If the processor throws an exception the manager will abort
processing and call ExtensionsFileProcessor.done(ExtensionsManager, Throwable)
.
Error that are related to a specific file should be catched
by the processor and registered by calling .......
If all files was processed without exceptions the manager
will call ExtensionsFileProcessor.done(ExtensionsManager)
.
Note that the file is read-only to begin with. If the processor
wants to call any write-operation the file must be opened by
calling ExtensionsFile.WriteableExtensionsFile.open()
. It is recommended
that the processor calls ExtensionsFile.WriteableExtensionsFile.close()
once it is done writing.
processFile
in interface ExtensionsFileProcessor
manager
- The manager that is executing the actionwFile
- The file to be processedpublic void done(ExtensionsManager manager)
ExtensionsFileProcessor
done
in interface ExtensionsFileProcessor
manager
- The manager that is executing the actionpublic void done(ExtensionsManager manager, Throwable t)
ExtensionsFileProcessor
done
in interface ExtensionsFileProcessor
manager
- The manager that is executing the actiont
- The exceptionpublic void setDelayRegistration(boolean delayRegistration)
done(ExtensionsManager)
method is
called by the manager. If this flag is set the
finalizeRegistration(ExtensionsManager, boolean)
method must be explicitely called.
public boolean isRegistrationDelayed()
public void setForceUpdate(boolean forceUpdate)
forceUpdate
- TRUE to always re-register extensions,
FALSE to only register new or updated extensionspublic XmlLoader getXmlLoader()
public ProcessResults getProcessResults()
public void finalizeRegistration(ExtensionsManager manager, boolean unregisterMissing)
public int getNumFiles()
public int getNumError()
public int getNumRegistered()
public int getNumUnregistered()
private int registerExtensionPoints(RegisterExtensionsProcessor.FileData data, Registry registry, boolean forceUpdate)
private boolean unregisterExtensionPoint(RegisterExtensionsProcessor.FileData data, ExtensionPoint ep, Registry registry)
private int registerExtensions(RegisterExtensionsProcessor.FileData data, Registry registry, boolean forceUpdate)
private boolean unregisterExtension(RegisterExtensionsProcessor.FileData data, Extension ext, Registry registry)
private void registerFactory(RegisterExtensionsProcessor.FileData data, Object factory)
XmlLoader.getFactoryParameters(Object)
method.
data
- The extension file the factory was defined infactory
- The factory instance (if null, no registration is done)private void unregisterFactory(RegisterExtensionsProcessor.FileData data, Object factory)
|
3.0.2: 2012-01-25 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |