|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.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 exclusive class loader for each plugin or not. |
protected java.util.List<DetectedPlugin<T>> |
detectedPlugins
Detected plugins list. |
protected java.util.Map<java.lang.String,DetectedPlugin<T>> |
detectedPluginsByPath
Detected plugins cached by plugin file path. |
protected java.io.FileFilter |
fileFilter
Plugin directory files filter. |
protected java.util.List<PluginsListener<T>> |
listeners
Plugins listeners. |
protected boolean |
loggingEnabled
Whether plugin manager logging is enabled or not. |
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. |
protected java.util.List<PluginManager> |
relatedManagers
Related plugin managers 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. |
|
void |
addRelatedManager(PluginManager manager)
Adds plugin manager into related managers list. |
|
protected void |
applyInitializationStrategy()
Sorting plugins according to their initialization strategies. |
|
protected boolean |
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 void |
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. |
|
DetectedPlugin<T> |
getDetectedPlugin(java.io.File file)
Returns plugin information from the specified plugin file. |
|
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 DetectedPlugin<T> |
getPluginInformation(java.io.File file)
Returns plugin information from the specified plugin file. |
|
protected java.lang.String |
getPluginLogoFile()
Returns name of the plugin logo file. |
|
java.lang.String |
getPluginsDirectoryPath()
Returns plugins directory path. |
|
protected void |
initializeDetectedPlugins()
Initializes earlier detected plugins. |
|
protected void |
initializeDetectedPluginsImpl()
Initializes earlier detected 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. |
|
boolean |
isLoggingEnabled()
Returns whether plugin manager logging is enabled or not. |
|
boolean |
isPluginAvailable(java.lang.String pluginId)
Returns whether plugin is available 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. |
|
PluginsAdapter<T> |
onPluginsDetection(DetectedPluginsRunnable<T> runnable)
Adds plugins detection event action. |
|
PluginsAdapter<T> |
onPluginsInitialization(PluginsRunnable<T> runnable)
Adds plugins initialization end event action. |
|
PluginsAdapter<T> |
onPluginsScanEnd(DirectoryRunnable runnable)
Adds plugins scan end event action. |
|
PluginsAdapter<T> |
onPluginsScanStart(DirectoryRunnable runnable)
Adds plugins scan start event action. |
|
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 |
removeRelatedManager(PluginManager manager)
Removes plugin manager from related managers list. |
|
void |
scanPlugin(java.io.File pluginFile)
Tries to load plugin from the specified file. |
|
void |
scanPlugin(java.lang.String pluginFile)
Tries to load plugin from the specified file. |
|
void |
scanPlugin(java.net.URL pluginFileURL)
Downloads plugin from the specified URL and tries to load it. |
|
void |
scanPluginsDirectory()
Performs plugins search within the specified plugins directory. |
|
void |
scanPluginsDirectory(boolean checkRecursively)
Performs plugins search within the specified plugins directory. |
|
void |
scanPluginsDirectory(java.lang.String pluginsDirectoryPath)
Performs plugins search within the specified plugins directory. |
|
void |
scanPluginsDirectory(java.lang.String pluginsDirectoryPath,
boolean checkRecursively)
Performs plugins search within the specified plugins directory. |
|
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 |
setLoggingEnabled(boolean loggingEnabled)
Sets whether plugin manager logging is enabled or not. |
|
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 void |
sortRecentlyDetectedPluginsByDependencies()
Tries to sort recently detected plugins list by known plugin dependencies. |
|
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 final java.util.List<PluginManager> relatedManagers
protected java.util.List<DetectedPlugin<T extends Plugin>> detectedPlugins
protected java.util.Map<java.lang.String,DetectedPlugin<T extends Plugin>> detectedPluginsByPath
protected java.util.List<DetectedPlugin<T extends Plugin>> recentlyDetected
protected Filter<DetectedPlugin<T extends Plugin>> pluginFilter
protected boolean allowSimilarPlugins
protected boolean loggingEnabled
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 addRelatedManager(PluginManager manager)
manager
- plugin manager to add into related managers listpublic void removeRelatedManager(PluginManager manager)
manager
- plugin manager to add into related managers listpublic 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 scanPlugin(java.net.URL pluginFileURL)
pluginFileURL
- plugin file URLpublic void scanPlugin(java.lang.String pluginFile)
pluginFile
- plugin file pathpublic void scanPlugin(java.io.File pluginFile)
pluginFile
- plugin filepublic void scanPluginsDirectory()
public void scanPluginsDirectory(boolean checkRecursively)
checkRecursively
- whether plugins directory subfolders should be checked recursively or notpublic void scanPluginsDirectory(java.lang.String pluginsDirectoryPath)
pluginsDirectoryPath
- plugins directory pathpublic void scanPluginsDirectory(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 void collectPluginsInformationImpl(java.io.File dir, boolean checkRecursively)
dir
- plugins directoryprotected boolean collectPluginInformation(java.io.File file)
file
- plugin file to process
protected void sortRecentlyDetectedPluginsByDependencies()
protected DetectedPlugin<T> getPluginInformation(java.io.File file)
file
- plugin file to process
public DetectedPlugin<T> getDetectedPlugin(java.io.File file)
file
- plugin file to process
protected boolean wasDetected(java.lang.String pluginFolder, java.lang.String pluginFile)
pluginFolder
- plugin directorypluginFile
- plugin file
protected void initializeDetectedPlugins()
protected void initializeDetectedPluginsImpl()
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 boolean isPluginAvailable(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 boolean isLoggingEnabled()
public void setLoggingEnabled(boolean loggingEnabled)
loggingEnabled
- whether plugin manager logging is enabled or notpublic void addPluginsListener(PluginsListener<T> listener)
listener
- new plugins listenerpublic PluginsAdapter<T> onPluginsScanStart(DirectoryRunnable runnable)
runnable
- action to perform
public PluginsAdapter<T> onPluginsScanEnd(DirectoryRunnable runnable)
runnable
- action to perform
public PluginsAdapter<T> onPluginsDetection(DetectedPluginsRunnable<T> runnable)
runnable
- action to perform
public PluginsAdapter<T> onPluginsInitialization(PluginsRunnable<T> runnable)
runnable
- action to perform
public 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 |