Class ExtensionsFile.WriteableExtensionsFile
- java.lang.Object
-
- net.sf.basedb.util.extensions.manager.ExtensionsFile.WriteableExtensionsFile
-
- Enclosing class:
- ExtensionsFile
public static class ExtensionsFile.WriteableExtensionsFile extends Object
An extensions file with additional methods that allows adding or modifying information in the underlying extensions file. This kind of view is usually handed out toExtensionsFileProcessor
implementations as a result of callingExtensionsManager.processFiles(ExtensionsFileProcessor)
.Note that the file starts out in read-only mode and that the processor has to call
open()
to aquire a write-lock before calling any writing methods. It is recommended that the lock is released as soon as possible by callingclose()
.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
isClosed
private ExtensionsFile
xtFile
-
Constructor Summary
Constructors Constructor Description WriteableExtensionsFile(ExtensionsFile xtFile)
Creates a new writeable extensions file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
checkClosed()
Check if the file has been closed and throws an IllegalStateException if it has.void
close()
Close the writeable file.ExtensionsFile
getExtensionsFile()
Get the underlying extensions file (for readin information)void
markAsProcessed()
Mark the file as fully processed by the extensions manager.boolean
open()
<M> void
registerMetadata(ObjectKey<M> key, M metadata)
Register metadata about an object.<O> void
registerObject(ObjectKey<O> key, O obj)
Register an object as "defined" by this extensions file.void
resetClassLoader()
Reset the classloader for this file, forcing a new instance in case the JAR file has been changed.void
setError(boolean error)
Sets the error status.void
setInstalled()
Mark the file as installed.void
setUninstalled()
Mark the file as uninstalled.<M> void
unregisterMetadata(ObjectKey<M> key)
Unregister metadata about an object.<O> void
unregisterObject(ObjectKey<O> key)
Unregister an object that was "defined" by this extensions file.
-
-
-
Field Detail
-
xtFile
private final ExtensionsFile xtFile
-
isClosed
private boolean isClosed
-
-
Constructor Detail
-
WriteableExtensionsFile
WriteableExtensionsFile(ExtensionsFile xtFile)
Creates a new writeable extensions file.
-
-
Method Detail
-
getExtensionsFile
public ExtensionsFile getExtensionsFile()
Get the underlying extensions file (for readin information)
-
close
public void close()
Close the writeable file. This will release the lock and any further write operations are disallowed.
-
open
public boolean open()
-
checkClosed
private void checkClosed()
Check if the file has been closed and throws an IllegalStateException if it has.
-
markAsProcessed
public void markAsProcessed()
Mark the file as fully processed by the extensions manager.
-
setUninstalled
public void setUninstalled()
Mark the file as uninstalled.
-
setInstalled
public void setInstalled()
Mark the file as installed.
-
setError
public void setError(boolean error)
Sets the error status. This method can be called even on closed files, since it is important to error handling.
-
resetClassLoader
public void resetClassLoader()
Reset the classloader for this file, forcing a new instance in case the JAR file has been changed. This method should be called before re-installing an extension and theExtensionsFile.checkModified()
returns true.- Throws:
IllegalStateException
- If the file has been closed- Since:
- 3.10
-
registerObject
public <O> void registerObject(ObjectKey<O> key, O obj)
Register an object as "defined" by this extensions file.- Parameters:
key
- The object key used to identify the objectobj
- The object to register- Throws:
IllegalStateException
- If the file has been closed
-
unregisterObject
public <O> void unregisterObject(ObjectKey<O> key)
Unregister an object that was "defined" by this extensions file.- Parameters:
key
- The object key used to identify the object- Throws:
IllegalStateException
- If the file has been closed
-
registerMetadata
public <M> void registerMetadata(ObjectKey<M> key, M metadata)
Register metadata about an object. The difference between this method and theregisterObject(ObjectKey, Object)
method is that theregisterObject
method also registers the objects with theExtensionsManager
.- Parameters:
key
- The object key used to identify the metadatametadata
- The metadata to store under the key
-
unregisterMetadata
public <M> void unregisterMetadata(ObjectKey<M> key)
Unregister metadata about an object.- Parameters:
key
- The object key used to identify the metadata
-
-