|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.clients.web.extensions.ExtensionsFile
public class ExtensionsFile
Represents a single extensions XML file or a JAR file containing
extensions. Each file has an individual XmlLoader
to
keep track of the extensions/extension points loaded from the file.
Field Summary | |
---|---|
private About |
about
|
private ExtensionsDirectory |
directory
|
private File |
file
|
private boolean |
hasError
|
private boolean |
hasValidated
|
private boolean |
isJar
|
private boolean |
isValid
|
private JarClassLoader |
jarLoader
|
private long |
lastModified
|
private XmlLoader |
loader
|
private static Logger |
log
|
private File |
resourcesDir
|
private Map<String,ServletWrapper> |
servlets
|
private long |
size
|
private Throwable |
validationError
|
Constructor Summary | |
---|---|
ExtensionsFile(ExtensionsDirectory directory,
File file,
File resourcesDir,
XmlLoader loader)
Create a new object. |
Method Summary | |
---|---|
int |
compareTo(ExtensionsFile other)
|
boolean |
equals(Object obj)
|
boolean |
exists()
Check if the file really exists on the disk. |
(package private) int |
extractResources(Pattern filter,
String replacement,
boolean forceOverwrite)
Extract resources from a JAR file to a directory. |
About |
getAbout()
Get information about this extensions file. |
Iterator<ExtensionPoint<?>> |
getExtensionPoints()
Get an iterator returning all extension points that are defined by this file. |
Iterator<Extension<?>> |
getExtensions()
Get an iterator returning all extensions that are defined by this file. |
String |
getFactoryParameters(Object factory)
Get a XML-like string representation of the parameters that was used to initialise a factory. |
String |
getName()
Get the name of the file. |
ServletWrapper |
getServlet(String servletName)
Get a servlet that has been defined in this JAR file. |
Throwable |
getValidationError()
Get more information about the error that caused the validation to fail. |
boolean |
hasError()
If there was an error when registering the extensions in this file. |
int |
hashCode()
|
boolean |
isJar()
If the file name ends with '.jar' the file is considered a JAR file. |
boolean |
isModified()
Check if the file has been modified since the last call to resetModified() . |
boolean |
isNew()
If the file is a new file not previously registered with the extension system. |
boolean |
isValid()
Checks if the file is a valid extensions definition file. |
(package private) void |
loadExtensions()
Load the extension definitions from the XML or JAR file. |
private About |
loadJar()
Load extensions from a validated JAR file. |
(package private) int |
loadServlets(ServletContext context)
Load servlet definitions from a JAR file. |
private About |
loadXml()
Load extensions from a validated XML file. |
(package private) int |
registerExtensionPoints(Registry registry,
boolean forceUpdate)
Register all extension points with a registry. |
(package private) int |
registerExtensions(Registry registry,
boolean forceUpdate)
Register all extensions with a registry. |
(package private) int |
removeResources()
Remove all extracted resources. |
(package private) void |
resetModified()
Resets the remembered timestamp and size attributes of the file. |
(package private) void |
setError(boolean error)
Sets the error status. |
(package private) int |
unregisterAll(Registry registry)
Unregister all extensions and extension points. |
(package private) int |
unregisterMissing(Registry registry)
Unregister extensions and extension points that have been removed from this package after an update. |
private void |
validate()
|
private About |
validateJar()
Try to validate a JAR file with extensions. |
private About |
validateXml()
Try to validate an XML file with extensions. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Logger log
private final ExtensionsDirectory directory
private final File file
private final File resourcesDir
private final XmlLoader loader
private final boolean isJar
private JarClassLoader jarLoader
private boolean hasValidated
private boolean isValid
private Throwable validationError
private long lastModified
private long size
private About about
private boolean hasError
private Map<String,ServletWrapper> servlets
Constructor Detail |
---|
public ExtensionsFile(ExtensionsDirectory directory, File file, File resourcesDir, XmlLoader loader)
directory
- The directory with extensions;file
- The XML or JAR file containting the extension definitionresourcesDir
- The directory where resources are extractedloader
- The XML loader to useMethod Detail |
---|
public int compareTo(ExtensionsFile other)
compareTo
in interface Comparable<ExtensionsFile>
public boolean equals(Object obj)
equals
in class Object
public int hashCode()
hashCode
in class Object
public String getName()
public boolean isJar()
public boolean exists()
File.exists()
public boolean isModified()
resetModified()
. We consider the file to be modified if
the timestamp (File.lastModified()
) or size (File.length()
)
has changed, or if the underlying class loader has detected a change
in any files it depends on (see JarClassLoader.hasChanged(boolean)
).
resetModified()
void resetModified()
isModified()
public boolean isNew()
resetModified()
is called which usually happens when all extensions has been registered.
public boolean isValid()
META-INF/extensions.jar
.
getValidationError()
public Throwable getValidationError()
public boolean hasError()
isValid()
method. Extensions that
has an error are automatically disabled.
void setError(boolean error)
public Iterator<ExtensionPoint<?>> getExtensionPoints()
public Iterator<Extension<?>> getExtensions()
public About getAbout()
public String getFactoryParameters(Object factory)
factory
- The factory object
void loadExtensions()
private void validate()
private About validateXml()
private About validateJar()
private About loadXml()
private About loadJar()
int loadServlets(ServletContext context)
int extractResources(Pattern filter, String replacement, boolean forceOverwrite)
filter
- A regular expression that must match all files
that should be extracted, or null to every filereplacement
- A replacement pattern used to convert the filename
in the JAR file to the filename on disk, or null to not change
the filename. See Matcher.replaceAll(String)
.forceOverwrite
- If TRUE, overwrite files even if they have the same
size and timestamp as the file in the JAR file
int removeResources()
int registerExtensions(Registry registry, boolean forceUpdate)
registry
- The registryforceUpdate
- TRUE to force an update of already registered
extensions, FALSE to only update if the extension package has
been modified
int registerExtensionPoints(Registry registry, boolean forceUpdate)
registry
- The registryforceUpdate
- TRUE to force an update of already registered
extension points, FALSE to only update if the extension package
has been modified
int unregisterMissing(Registry registry)
registry
- The registry
int unregisterAll(Registry registry)
registry
- The registry
public ServletWrapper getServlet(String servletName)
servletName
- The name of the servlet, specified by the
<servlet-name> tag in the XML file.
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |