|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.mucommander.extension.ExtensionManager
public class ExtensionManager
Manages muCommander's extensions.
Extensions must be stored in getExtensionsFolder() in order for this class to be aware of them.
Moreover, the method addExtensionsToClasspath() must have been called before extensions can be used.
Extensions are loaded through a custom ClassLoader. The optimal situation is for that ClassLoader
to be the system one, which can only be achieved through setting the java.system.class.loader system property
to com.mucommander.file.AbstractFileClassLoader at boot time.
However, if for some reason such is not the case, we'll use a separate instance of that class. This will work in most cases, but
might cause conflicts under rare circumstances. Extension writers are advised to load resources through the ClassLoader
returned by getClassLoader(), as not doing so might result in using the bootstrap classloader which doesn't have access to
resources found in getExtensionsFolder().
This class can also be used to load Swing look and feel from JAR files that aren't in the system's classpath. In order to achieve this, application writers must:
UIManager.getDefaults().put("ClassLoader", ExtensionManager.getClassLoader()); when initialising their application.
This will force Swing to use our custom classloader when loading Look&Feels.
UIManager.setLookAndFeel((LookAndFeel)Class.forName(lnfName, true, ExtensionManager.getClassLoader()).newInstance());
to set a new look and feel. This will ensure that all classes and resources are available when initialising the Look&Feel.
Quaqua. The only way to get these to load properly is to make sure the system classloader is an instance of
AbstractFileClassLoader.
| Field Summary | |
|---|---|
static java.lang.String |
DEFAULT_EXTENSIONS_FOLDER_NAME
Default name of the extensions folder. |
| Method Summary | |
|---|---|
static void |
addExtensionsToClasspath()
Adds all known extensions to the current classpath. |
static void |
addToClassPath(AbstractFile file)
Adds the specified file to the extension's classpath. |
static java.lang.ClassLoader |
getClassLoader()
Returns the ClassLoader used to load all extensions. |
static AbstractFile |
getExtensionsFile(java.lang.String filename)
Returns an AbstractFile to the extension file with the specified filename and located in the
extensions folder. |
static AbstractFile |
getExtensionsFolder()
Returns the folder in which all extensions are stored. |
static boolean |
importLibrary(AbstractFile file,
boolean force)
Imports the specified file in muCommander's libraries. |
static boolean |
isAvailable(AbstractFile file)
Returns true if the specified file is either in the extension or system classpath. |
static boolean |
isInClasspath(AbstractFile file)
Returns true if the specified file is in the system classpath. |
static boolean |
isInExtensionsPath(AbstractFile file)
Returns true if the specified file is in the extension's classloader path. |
static void |
setExtensionsFolder(AbstractFile folder)
Sets the path to the folder in which all extensions are stored. |
static void |
setExtensionsFolder(java.io.File folder)
Sets the path to the folder in which all extensions are stored. |
static void |
setExtensionsFolder(java.lang.String path)
Sets the path to the folder in which all extensions are stored. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String DEFAULT_EXTENSIONS_FOLDER_NAME
| Method Detail |
|---|
public static void setExtensionsFolder(java.io.File folder)
throws java.io.IOException
If the specified path is not browsable (i.e. a folder or any file that muCommander can treat as such), its parent will be used instead.
folder - path to the folder in which extensions are stored.
java.io.IOException - if the specified folder or the specified file's parent couldn't be accessed.setExtensionsFolder(AbstractFile),
setExtensionsFolder(String),
getExtensionsFolder()
public static void setExtensionsFolder(AbstractFile folder)
throws java.io.IOException
If the specified path is not browsable (i.e. a folder or any file that muCommander can treat as such), its parent will be used instead.
folder - path to the folder in which extensions are stored.
java.io.IOException - if the specified folder or the specified file's parent couldn't be accessed.setExtensionsFolder(File),
setExtensionsFolder(String),
getExtensionsFolder()
public static void setExtensionsFolder(java.lang.String path)
throws java.io.IOException
If the specified path is not browsable (i.e. a folder or any file that muCommander can treat as such), its parent will be used instead.
path - path to the folder in which extensions are stored.
java.io.IOException - if the specified folder or the specified file's parent couldn't be accessed.setExtensionsFolder(File),
setExtensionsFolder(String),
getExtensionsFolder()
public static AbstractFile getExtensionsFolder()
throws java.io.IOException
java.io.IOException - if an error occured while locating the default extensions folder.setExtensionsFolder(AbstractFile)
public static AbstractFile getExtensionsFile(java.lang.String filename)
throws java.io.IOException
AbstractFile to the extension file with the specified filename and located in the
extensions folder. The returned file may or may not exist.
filename - the extension's filename
java.io.IOException - if the file could not be instanciated.public static boolean isInExtensionsPath(AbstractFile file)
true if the specified file is in the extension's classloader path.
file - file whose presence in the extensions path will be checked.
true if the specified file is in the extension's classloader path, false otherwise.public static boolean isInClasspath(AbstractFile file)
true if the specified file is in the system classpath.
file - file whose presence in the system classpath will be checked.
true if the specified file is in the system classpath, false otherwise.public static boolean isAvailable(AbstractFile file)
true if the specified file is either in the extension or system classpath.
This is a convenience method and is equivalent to calling:
.
isInClasspath(file) || isInExtensionsPath(file)
file - file whose availability will be checked.
true if the specified file is either in the extension or system classpath, false otherwise.
public static boolean importLibrary(AbstractFile file,
boolean force)
throws java.io.IOException
file - path to the library to import.force - wether to overwrite eventual existing libraries of the same name.
true if the operation was a success,
false if a library of the same name already exists and
force is set to false.
java.io.IOException - if an I/O error occurs.public static void addToClassPath(AbstractFile file)
file - file to add to the classpath.
public static void addExtensionsToClasspath()
throws java.io.IOException
This method will create the following new classpath entries:
getExtensionsFolder()JAR files in getExtensionsFolder().
java.io.IOException - if the extensions folder is not accessible.public static java.lang.ClassLoader getClassLoader()
ClassLoader used to load all extensions.
ClassLoader used to load all extensions.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard