|
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.ExtensionsDirectory
public class ExtensionsDirectory
Represents a directory with extensions. This class can automatically detect changes and install, update or uninstall extensions when files are added, changed or removed from the specified directory. Resources, such as images, JSP files, etc. are automatically extracted from JAR files and placed in the resources directory, which is a directory that should be accessible from the web server.
Field Summary | |
---|---|
private File |
extensionsDir
|
private Set<File> |
ignore
|
private Map<String,ExtensionsFile> |
installedExtensions
|
private Map<File,ExtensionsFile> |
installedFiles
|
private static Logger |
log
|
private PathConverter |
pathConverter
|
private File |
resourcesDir
|
private String |
resourcesUrl
|
private String |
rootUrl
|
private Set<File> |
staticIgnore
|
private VariableConverter |
variableConverter
|
Constructor Summary | |
---|---|
ExtensionsDirectory(File extensionsDir,
File resourcesDir,
String rootUrl,
String resourcesUrl)
|
Method Summary | |
---|---|
void |
addIgnore(File file)
Add a file to the ignore list. |
(package private) void |
addRegistered(String id,
ExtensionsFile file)
|
private XmlLoader |
createXmlLoader()
Creates a new XmlLoader and registers the variableConverter
and pathConverter with it. |
private void |
extractResources(boolean forceUpdate,
ScanResults results)
Extract resources from JAR files. |
File |
getExtensionDirectory()
Get the file object representing the directory where extensions are installed. |
ExtensionsFile |
getFile(String filename)
Get information about an installed extensions file. |
(package private) ExtensionsFile |
getFileByExtensionId(String extensionId)
Get information about the file a given extension or extension point is defined in. |
Iterator<ExtensionsFile> |
getFiles()
Get an iterator returning all XML/JAR files which contains installed extensions. |
(package private) List<String> |
getRegistered(ExtensionsFile file)
|
File |
getResourcesDirectory()
Get the file object representing the directory where resource files are extracted. |
String |
getResourcesUrl()
Get the URL that points to the resources directory when accessed through the web server. |
String |
getResourcesUrl(ExtensionsFile extFile)
Get the URL that points to the resources directory for a specific extensions file when accessed through the web server. |
String |
getRootUrl()
Get the URL that points to the root directory when accessed through the web server. |
String |
getServletsUrl(ExtensionsFile extFile)
Get the URL that points to the servlet directory for a specific extensions file when accessed through the web server. |
(package private) ScanResults |
installAndUpdateExtensions(Registry registry,
ServletContext servletContext,
boolean manualScan,
boolean forceUpdate)
Scan the directory for new/modified/deleted extension files and perform neccesary changed in the registry. |
private void |
loadDefinitions(boolean forceUpdate,
ScanResults results)
Load the extension definitions from XML files. |
private void |
loadServlets(ServletContext servletContext,
boolean forceUpdate,
ScanResults results)
Load servlet definitions from JAR files. |
private void |
registerExtensions(Registry registry,
boolean forceUpdate,
ScanResults results)
Register extensions with the registry. |
void |
removeIgnore(File file)
Remove a file from the ignore list. |
(package private) void |
removeRegistered(String id,
ExtensionsFile file)
|
private void |
resetIgnore()
Clears all files that has been added to the ignore set. |
private int[] |
scanForNewAndUpdated(boolean forceUpdate,
ScanResults results)
Scan for new extensions. |
private int |
unregisterDeleted(Registry registry,
ScanResults results)
Unregister extensions/extension points that no longer exists. |
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 File extensionsDir
private final File resourcesDir
private final String resourcesUrl
private final String rootUrl
private final Map<File,ExtensionsFile> installedFiles
private final Map<String,ExtensionsFile> installedExtensions
private final Set<File> staticIgnore
private final Set<File> ignore
private final VariableConverter variableConverter
private final PathConverter pathConverter
Constructor Detail |
---|
public ExtensionsDirectory(File extensionsDir, File resourcesDir, String rootUrl, String resourcesUrl)
Method Detail |
---|
public File getExtensionDirectory()
public File getResourcesDirectory()
public String getResourcesUrl()
public String getResourcesUrl(ExtensionsFile extFile)
public String getServletsUrl(ExtensionsFile extFile)
public String getRootUrl()
public void addIgnore(File file)
file
- The file to addremoveIgnore(File)
public void removeIgnore(File file)
file
- The file to removeaddIgnore(File)
public Iterator<ExtensionsFile> getFiles()
public ExtensionsFile getFile(String filename)
filename
- The filename of the file
ExtensionsFile
object or null if
the given file doesn't exists or isn't an extensions fileExtensionsFile getFileByExtensionId(String extensionId)
extensionId
- The ID of an extension or extension point
void addRegistered(String id, ExtensionsFile file)
List<String> getRegistered(ExtensionsFile file)
void removeRegistered(String id, ExtensionsFile file)
ScanResults installAndUpdateExtensions(Registry registry, ServletContext servletContext, boolean manualScan, boolean forceUpdate)
registry
- The registry holding registered extension points
and extensionsmanualScan
- TRUE if this is a manual scan, FALSE if it is an automaticforceUpdate
- TRUE to force an update of unmodified extensions,
FALSE to leave them as they are
private int unregisterDeleted(Registry registry, ScanResults results)
private int[] scanForNewAndUpdated(boolean forceUpdate, ScanResults results)
installedFiles
map
if valid or to the ignore
set if not valid. Files already
in the ignore
set are not checked.
private void loadDefinitions(boolean forceUpdate, ScanResults results)
private void extractResources(boolean forceUpdate, ScanResults results)
private void loadServlets(ServletContext servletContext, boolean forceUpdate, ScanResults results)
private void registerExtensions(Registry registry, boolean forceUpdate, ScanResults results)
ExtensionsFile.hasError()
flag set are automatically disabled.
private XmlLoader createXmlLoader()
variableConverter
and pathConverter
with it.
private void resetIgnore()
ignore
set. All files in staticIgnore
are re-added.
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |