|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.alee.managers.plugin.PluginManager<T>
public abstract class PluginManager<T extends Plugin>
Base class for any plugin manager you might want to create.
Plugin
Field Summary | |
---|---|
protected boolean |
allowSimilarPlugins
Whether should allow loading multiply plugins with the same ID or not. |
protected java.util.List<T> |
availablePlugins
Loaded and running plugins list. |
protected java.util.Map<java.lang.Class<? extends Plugin>,T> |
availablePluginsByClass
Map of plugins cached by their classes. |
protected java.util.Map<java.lang.String,T> |
availablePluginsById
Map of plugins cached by their IDs. |
protected java.lang.Object |
checkLock
Plugin checks lock object. |
protected boolean |
checkRecursively
Whether plugins directory subfolders should be checked recursively or not. |
protected boolean |
createNewClassLoader
Whether should create new class loader for each loaded plugin or not. |
protected java.util.List<DetectedPlugin<T>> |
detectedPlugins
Detected plugins list. |
protected java.io.FileFilter |
fileFilter
Plugin directory files filter. |
protected java.util.List<PluginsListener<T>> |
listeners
Plugins listeners. |
protected Filter<DetectedPlugin<T>> |
pluginFilter
Special filter to filter out unwanted plugins before their initialization. |
protected java.lang.String |
pluginsDirectoryPath
Plugins directory path. |
protected java.util.List<DetectedPlugin<T>> |
recentlyDetected
Recently detected plugins list. |
protected java.util.List<T> |
recentlyInitialized
Recently initialized plugins list. |
Constructor Summary | |
---|---|
PluginManager()
Constructs new plugin manager. |
|
PluginManager(java.lang.String pluginsDirectoryPath)
Constructs new plugin manager. |
|
PluginManager(java.lang.String pluginsDirectoryPath,
boolean checkRecursively)
Constructs new plugin manager. |
Method Summary | ||
---|---|---|
void |
addPluginsListener(PluginsListener<T> listener)
Adds plugins listener. |
|
protected void |
applyInitializationStrategy()
Sorting plugins according to their initialization strategies. |
|
void |
checkPlugins()
Performs plugins search within the specified plugins directory. |
|
void |
checkPlugins(boolean checkRecursively)
Performs plugins search within the specified plugins directory. |
|
void |
checkPlugins(java.lang.String pluginsDirectoryPath)
Performs plugins search within the specified plugins directory. |
|
void |
checkPlugins(java.lang.String pluginsDirectoryPath,
boolean checkRecursively)
Performs plugins search within the specified plugins directory. |
|
protected void |
collectPluginInformation(java.io.File file)
Tries to collect plugin information from the specified file. |
|
protected boolean |
collectPluginsInformation(java.lang.String pluginsDirectoryPath,
boolean checkRecursively)
Collects information about available plugins. |
|
protected boolean |
collectPluginsInformationImpl(java.io.File dir,
boolean checkRecursively)
Collects information about available plugins. |
|
void |
firePluginsCheckEnded(java.lang.String directory,
boolean recursive)
Informs about plugins check operation end. |
|
void |
firePluginsCheckStarted(java.lang.String directory,
boolean recursive)
Informs about plugins check operation start. |
|
void |
firePluginsDetected(java.util.List<DetectedPlugin<T>> plugins)
Informs about newly detected plugins. |
|
void |
firePluginsInitialized(java.util.List<T> plugins)
Informs about newly initialized plugins. |
|
protected java.lang.String |
getAcceptedPluginType()
Returns accepted by this manager plugin type. |
|
java.util.List<T> |
getAvailablePlugins()
Returns list of available loaded plugins. |
|
java.util.List<DetectedPlugin<T>> |
getDetectedPlugins()
Returns list of detected plugins. |
|
int |
getDetectedPluginsAmount()
Returns amount of detected plugins. |
|
int |
getFailedPluginsAmount()
Returns amount of plugins which have failed to load. |
|
java.io.FileFilter |
getFileFilter()
Returns plugins directory file filter. |
|
int |
getLoadedPluginsAmount()
Returns amount of successfully loaded plugins. |
|
|
getPlugin(java.lang.Class<P> pluginClass)
Returns available plugin instance by its class. |
|
|
getPlugin(java.lang.String pluginId)
Returns available plugin instance by its ID. |
|
protected java.lang.String |
getPluginDescriptorFile()
Returns name of the plugin descriptor file. |
|
Filter<DetectedPlugin<T>> |
getPluginFilter()
Returns special filter that filters out unwanted plugins before their initialization. |
|
protected java.lang.String |
getPluginLogoFile()
Returns name of the plugin logo file. |
|
java.lang.String |
getPluginsDirectoryPath()
Returns plugins directory path. |
|
protected void |
initializePlugins()
Initializes detected earlier plugins. |
|
boolean |
isAllowSimilarPlugins()
Returns whether should allow loading multiply plugins with the same ID or not. |
|
boolean |
isCheckRecursively()
Returns whether plugins directory subfolders should be checked recursively or not. |
|
boolean |
isCreateNewClassLoader()
Returns whether should create new class loader for each loaded plugin or not. |
|
boolean |
isDeprecatedVersion(DetectedPlugin<T> plugin)
Returns whether the list of detected plugins contain a newer version of the specified plugin or not. |
|
boolean |
isDeprecatedVersion(DetectedPlugin<T> plugin,
java.util.List<DetectedPlugin<T>> detectedPlugins)
Returns whether the list of detected plugins contain a newer version of the specified plugin or not. |
|
protected boolean |
isSameVersionAlreadyLoaded(DetectedPlugin<T> plugin,
java.util.List<DetectedPlugin<T>> detectedPlugins)
Returns whether the list of detected plugins contain the same version of the specified plugin or not. |
|
void |
registerPlugin(T plugin)
Registers programmatically loaded plugin within this PluginManager. |
|
void |
registerPlugin(T plugin,
PluginInformation information,
javax.swing.ImageIcon logo)
Registers programmatically loaded plugin within this PluginManager. |
|
void |
removePluginsListener(PluginsListener<T> listener)
Removes plugins listener. |
|
void |
setAllowSimilarPlugins(boolean allow)
Sets whether should allow loading multiply plugins with the same ID or not. |
|
void |
setCheckRecursively(boolean checkRecursively)
Sets whether plugins directory subfolders should be checked recursively or not. |
|
void |
setCreateNewClassLoader(boolean createNewClassLoader)
Sets whether should create new class loader for each loaded plugin or not. |
|
void |
setFileFilter(java.io.FileFilter filter)
Sets plugins directory file filter. |
|
void |
setPluginFilter(Filter<DetectedPlugin<T>> pluginFilter)
Sets special filter that filters out unwanted plugins before their initialization. |
|
void |
setPluginsDirectoryPath(java.lang.String path)
Sets plugins directory path. |
|
protected boolean |
wasDetected(java.lang.String pluginFolder,
java.lang.String pluginFile)
Returns whether this plugin file was already detected before or not. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.List<PluginsListener<T extends Plugin>> listeners
protected final java.lang.Object checkLock
protected java.util.List<DetectedPlugin<T extends Plugin>> detectedPlugins
protected java.util.List<DetectedPlugin<T extends Plugin>> recentlyDetected
protected Filter<DetectedPlugin<T extends Plugin>> pluginFilter
protected boolean allowSimilarPlugins
protected java.util.List<T extends Plugin> availablePlugins
protected java.util.Map<java.lang.String,T extends Plugin> availablePluginsById
protected java.util.Map<java.lang.Class<? extends Plugin>,T extends Plugin> availablePluginsByClass
protected java.util.List<T extends Plugin> recentlyInitialized
protected java.lang.String pluginsDirectoryPath
protected boolean checkRecursively
protected java.io.FileFilter fileFilter
protected boolean createNewClassLoader
Constructor Detail |
---|
public PluginManager()
public PluginManager(java.lang.String pluginsDirectoryPath)
pluginsDirectoryPath
- plugins directory pathpublic PluginManager(java.lang.String pluginsDirectoryPath, boolean checkRecursively)
pluginsDirectoryPath
- plugins directory pathcheckRecursively
- whether plugins directory subfolders should be checked recursively or notMethod Detail |
---|
protected java.lang.String getPluginDescriptorFile()
protected java.lang.String getPluginLogoFile()
protected java.lang.String getAcceptedPluginType()
null
is returned this manager accepts any plugin type.
public void registerPlugin(T plugin)
plugin
- plugin to registerpublic void registerPlugin(T plugin, PluginInformation information, javax.swing.ImageIcon logo)
plugin
- plugin to registerinformation
- about this pluginlogo
- plugin logopublic void checkPlugins()
public void checkPlugins(boolean checkRecursively)
checkRecursively
- whether plugins directory subfolders should be checked recursively or notpublic void checkPlugins(java.lang.String pluginsDirectoryPath)
pluginsDirectoryPath
- plugins directory pathpublic void checkPlugins(java.lang.String pluginsDirectoryPath, boolean checkRecursively)
pluginsDirectoryPath
- plugins directory pathcheckRecursively
- whether plugins directory subfolders should be checked recursively or notprotected boolean collectPluginsInformation(java.lang.String pluginsDirectoryPath, boolean checkRecursively)
protected boolean collectPluginsInformationImpl(java.io.File dir, boolean checkRecursively)
dir
- plugins directory
protected void collectPluginInformation(java.io.File file)
file
- plugin file to processprotected boolean wasDetected(java.lang.String pluginFolder, java.lang.String pluginFile)
pluginFolder
- plugin directorypluginFile
- plugin file
protected void initializePlugins()
public boolean isDeprecatedVersion(DetectedPlugin<T> plugin)
plugin
- plugin to compare with other detected plugins
public boolean isDeprecatedVersion(DetectedPlugin<T> plugin, java.util.List<DetectedPlugin<T>> detectedPlugins)
plugin
- plugin to compare with other detected pluginsdetectedPlugins
- list of detected plugins
protected boolean isSameVersionAlreadyLoaded(DetectedPlugin<T> plugin, java.util.List<DetectedPlugin<T>> detectedPlugins)
plugin
- plugin to compare with other detected pluginsdetectedPlugins
- list of detected plugins
protected void applyInitializationStrategy()
public java.util.List<DetectedPlugin<T>> getDetectedPlugins()
public java.util.List<T> getAvailablePlugins()
public <P extends T> P getPlugin(java.lang.String pluginId)
pluginId
- plugin ID
public <P extends T> P getPlugin(java.lang.Class<P> pluginClass)
pluginClass
- plugin class
public int getDetectedPluginsAmount()
public int getLoadedPluginsAmount()
public int getFailedPluginsAmount()
public java.lang.String getPluginsDirectoryPath()
public void setPluginsDirectoryPath(java.lang.String path)
path
- new plugins directory pathpublic boolean isCheckRecursively()
public void setCheckRecursively(boolean checkRecursively)
checkRecursively
- whether plugins directory subfolders should be checked recursively or notpublic java.io.FileFilter getFileFilter()
public void setFileFilter(java.io.FileFilter filter)
filter
- plugins directory file filterpublic boolean isCreateNewClassLoader()
public void setCreateNewClassLoader(boolean createNewClassLoader)
createNewClassLoader
- whether should create new class loader for each loaded plugin or notpublic Filter<DetectedPlugin<T>> getPluginFilter()
public void setPluginFilter(Filter<DetectedPlugin<T>> pluginFilter)
pluginFilter
- special filter that filters out unwanted plugins before their initializationpublic boolean isAllowSimilarPlugins()
public void setAllowSimilarPlugins(boolean allow)
allow
- whether should allow loading multiply plugins with the same ID or notpublic void addPluginsListener(PluginsListener<T> listener)
listener
- new plugins listenerpublic void removePluginsListener(PluginsListener<T> listener)
listener
- plugins listener to removepublic void firePluginsCheckStarted(java.lang.String directory, boolean recursive)
directory
- checked plugins directory pathrecursive
- whether plugins directory subfolders are checked recursively or notpublic void firePluginsCheckEnded(java.lang.String directory, boolean recursive)
directory
- checked plugins directory pathrecursive
- whether plugins directory subfolders are checked recursively or notpublic void firePluginsDetected(java.util.List<DetectedPlugin<T>> plugins)
plugins
- newly detected plugins listpublic void firePluginsInitialized(java.util.List<T> plugins)
plugins
- newly initialized plugins list
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |