Class RegisterExtensionsProcessor
- All Implemented Interfaces:
ExtensionsFileProcessor
- Direct Known Subclasses:
WebClientRegisterExtensionsProcessor
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.
- Since:
- 3.0
- Author:
- Nicklas
- Last modified
- $Date: 2015-04-20 11:08:18 +0200 (må, 20 apr 2015) $
-
Nested Class Summary
Modifier and TypeClassDescription(package private) static class
Keep track of the extension points and extensions found in a file. -
Field Summary
Modifier and TypeFieldDescriptionprivate List<RegisterExtensionsProcessor.FileData>
private boolean
private boolean
private final XmlLoader
private static final Logger
private int
private int
private int
private int
private final ProcessResults
-
Constructor Summary
ConstructorDescriptionRegisterExtensionsProcessor
(XmlLoader loader, ProcessResults results) Create a new processor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
Get the number of files that was had an error.int
Get the number of files that was successfully processed.int
Get the number of extensions + extension points that was registered.int
Get the number of extensions + extension points that was unregistered.Get the loader the processor is using for parsing xml files with extension definitions.boolean
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, ExtensionsManager manager, boolean forceUpdateOrModified) 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)
-
Field Details
-
log
-
loader
-
results
-
delayRegistration
private boolean delayRegistration -
forceUpdate
private boolean forceUpdate -
allData
-
numFiles
private int numFiles -
numError
private int numError -
numRegistered
private int numRegistered -
numUnregistered
private int numUnregistered
-
-
Constructor Details
-
RegisterExtensionsProcessor
Create a new processor.- Parameters:
loader
- The XML loader to use when parsing the metadata
-
-
Method Details
-
begin
Description copied from interface:ExtensionsFileProcessor
Called by the extensions manager before the processing starts.- Specified by:
begin
in interfaceExtensionsFileProcessor
- Parameters:
manager
- The manager that is executing the actionnumFiles
- The number of extension files that is going to be processed this time
-
processFile
Description copied from interface:ExtensionsFileProcessor
Called by the extensions manager for each extensions file that it manages. The order of the files is generally not predicatable and may change from one invokation to the next.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 callsExtensionsFile.WriteableExtensionsFile.close()
once it is done writing.- Specified by:
processFile
in interfaceExtensionsFileProcessor
- Parameters:
manager
- The manager that is executing the actionwFile
- The file to be processed
-
done
Description copied from interface:ExtensionsFileProcessor
Called by the extensions manager after a successful completion of the processing.- Specified by:
done
in interfaceExtensionsFileProcessor
- Parameters:
manager
- The manager that is executing the action
-
done
Description copied from interface:ExtensionsFileProcessor
Called by the extensions manager if an exception was thrown by the processor.- Specified by:
done
in interfaceExtensionsFileProcessor
- Parameters:
manager
- The manager that is executing the actiont
- The exception
-
setDelayRegistration
public 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. The default is to not delay registration, which means that it happend when thedone(ExtensionsManager)
method is called by the manager. If this flag is set thefinalizeRegistration(ExtensionsManager, boolean)
method must be explicitely called. -
isRegistrationDelayed
public boolean isRegistrationDelayed()Is the actual registration delayed or not? -
setForceUpdate
public void setForceUpdate(boolean forceUpdate) Set a flag to indicate if already registered extensions should be re-registered or not.- Parameters:
forceUpdate
- TRUE to always re-register extensions, FALSE to only register new or updated extensions
-
getXmlLoader
Get the loader the processor is using for parsing xml files with extension definitions. -
getProcessResults
-
finalizeRegistration
-
getNumFiles
public int getNumFiles()Get the number of files that was successfully processed. -
getNumError
public int getNumError()Get the number of files that was had an error. -
getNumRegistered
public int getNumRegistered()Get the number of extensions + extension points that was registered. -
getNumUnregistered
public int getNumUnregistered()Get the number of extensions + extension points that was unregistered. -
registerExtensionPoints
private int registerExtensionPoints(RegisterExtensionsProcessor.FileData data, Registry registry, boolean forceUpdate) throws IOException - Throws:
IOException
-
unregisterExtensionPoint
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. In all cases, factory metadata must be removed, since we leak memory otherwise (new factory instances are always created when scanning a modified file).- Returns:
- TRUE if the extension point is not going to be registered again
-
registerExtensions
private int registerExtensions(RegisterExtensionsProcessor.FileData data, ExtensionsManager manager, boolean forceUpdateOrModified) throws IOException - Throws:
IOException
-
unregisterExtension
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. In all cases, factory metadata must be removed, since we leak memory otherwise (new factory instances are always created when scanning a modified file).- Returns:
- TRUE if the extension point is not going to be registered again
-
registerFactory
Register factory parameters for the given factory instance. The parameters are retreived from theXmlLoader.getFactoryParameters(Object)
method.- Parameters:
data
- The extension file the factory was defined infactory
- The factory instance (if null, no registration is done)
-
unregisterFactory
-