|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.platonos.pluginengine.Plugin
Provides a feature or ability through Java classes, ExtensionPoints, and/or Extensions. A Plugin is defined in the plugin.xml
file. Here is an example plugin.xml with links to the corresponding methods:
<plugin start
="true">
<name
>Example Plugin</name
>
<version
>1.0.0</version
>
<uid
>example</uid
>
<lifecycleclass
>example.ExamplePluginLifecycle</lifecycleclass
>
<dependencies>
<dependency
uid="example.someOtherPlugin" minversion="0.5" maxversion="1" />
<dependency
uid="example.otherPlugin" version="1.0" optional
="true" />
</dependencies>
<extensionpoints>
<extensionpoint
name="startup" interface="example.IStartup" />
</extensionpoints>
<extensions>
<extension
uid="example.otherPlugin" name="help" class="example.HelpAction" />
</extensions>
</plugin>
The "uid" element is required, all other elements and attributes are optional.
PluginLifecycle
,
Dependency
,
ExtensionPoint
,
Extension
Constructor Summary | |
Plugin(PluginEngine pluginEngine)
Creates a new Plugin that cannot load classes and resources. |
|
Plugin(PluginEngine pluginEngine,
java.net.URL pluginURL)
Creates a new Plugin that can load classes and resources at the specified Plugin URL. |
Method Summary | |
void |
addDependency(Dependency dependency)
Adds a Dependency that represents a Plugin that this Plugin is dependent upon. |
void |
addExtension(Extension extension)
Adds an Extension to this Plugin. |
void |
addExtensionPoint(ExtensionPoint extensionPoint)
Adds an ExtensionPoint to this Plugin. |
int |
compareTo(java.lang.Object object)
|
int |
compareTo(Plugin plugin)
Compares this Plugin's version with the specified Plugin's version. |
void |
disable()
Unresolves this specified Plugin and prohibits it from becoming resolved again. |
void |
enable()
Allows this previously disabled Plugin to become resolved again. |
java.util.List |
getDependencies()
Returns a List of this Plugin's Dependencies. |
Dependency |
getDependency(java.lang.String pluginUID)
Returns the Dependency for the specified Plugin UID or null if no Dependency was found. |
boolean |
getDependentPluginLookup()
Returns true if this Plugin will look for classes in Plugins dependent upon it. |
java.util.List |
getDependentPlugins()
Returns a List of Plugins that are dependent upon this Plugin. |
ExtensionPoint |
getExtensionPoint(java.lang.String name)
Returns an ExtensionPoint defined in this Plugin or null if the ExtensionPoint does not exist in this Plugin. |
java.util.List |
getExtensionPoints()
Returns all ExtensionPoints for this Plugin. |
java.util.List |
getExtensions()
Returns a List of all Extensions for this Plugin. |
java.lang.String |
getExtractedResourcePath(java.lang.String name)
Returns an absolute path to the resource with the given name. |
java.lang.String |
getLifecycleClassName()
Returns the name of the lifecycle Class that manages this Plugin's lifecycle or null if there is no lifecycle class. |
PluginLifecycle |
getLifecycleInstance()
Starts the Plugin if not started and returns the lifecycle instance that manages this Plugin's lifecycle or null if there is no lifecycle class or the Plugin could not be started. |
PluginXmlNode |
getMetadataXmlNode()
Returns the PluginXmlNode that represents the "metadata" XML element in the plugin.xml file or null if there is none. |
java.lang.String |
getName()
Returns the friendly name given to this Plugin. |
java.lang.ClassLoader |
getPluginClassLoader()
Returns the ClassLoader used to load classes within this Plugin. |
PluginEngine |
getPluginEngine()
Returns the PluginEngine instance that this Plugin is associated with. |
java.net.URL |
getPluginURL()
Returns the location this Plugin uses to lookup class files and resources. |
boolean |
getStartWhenResolved()
Returns true if this Plugin will be started as soon as possible after being loaded into the PluginEngine. |
java.lang.String |
getUID()
Returns the unique ID for this Plugin. |
PluginVersion |
getVersion()
Returns the version of this Plugin. |
int |
hashCode()
Implements hashCode by using the hash of the objects used in the equals() comparison and multiplying by prime numbers. |
boolean |
isArchive()
Returns true if this Plugin resides in an archive file. |
boolean |
isCompatible(Plugin plugin)
Returns true if the specified Plugin is version compatible with a Dependency of this Plugin or if no Dependency exists. |
boolean |
isDisabled()
Returns true if this Plugin has been disabled. |
boolean |
isResolved()
Returns true if this Plugin has been resolved. |
boolean |
isStarted()
Returns true if this Plugin has been started. |
void |
removeDependency(Dependency dependency)
Unresolves the specified Dependency and removes it from this Plugin. |
void |
removeExtension(Extension extension)
Unresolves the specified Extension and removes it from this Plugin. |
void |
removeExtensionPoint(ExtensionPoint extensionPoint)
Unresolves all Extensions attached to the specified ExtensionPoint and removes it from this Plugin. |
java.lang.String |
replaceToken(java.lang.String token)
Replaces the specified token with a PluginEngine token, System property, or String for the plugin.properties resource file. |
void |
setDependentPluginLookup(boolean dependentPluginLookup)
If true, when this Plugin is unable to find a class within its own classpath and its Dependencies, it first will look in the Plugins that are dependent upon this Plugin for the class before delegating to the class loader that loaded the PluginEngine class. |
void |
setLifecycleClassName(java.lang.String lifecycleClassName)
Sets the name of the lifecycle Class that manages this Plugin's lifecycle. |
void |
setMetadataXmlNode(PluginXmlNode metadataXmlNode)
Sets the root PluginXmlNode for this Plugin's metadata. |
void |
setName(java.lang.String name)
Sets the friendly name of this Plugin. |
void |
setStartWhenResolved(boolean startWhenResolved)
If true, this Plugin will be started as soon as possible after being resolved. |
void |
setUID(java.lang.String uid)
Sets the unique ID for this Plugin. |
void |
setVersion(PluginVersion version)
Sets the version of this Plugin. |
boolean |
start()
Starts this Plugin if it is not already started. |
void |
stop()
Stops this Plugin if it is not already stopped. |
java.lang.String |
toString()
Returns this Plugin's friendly name. |
void |
unload()
Unloads this Plugin. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Plugin(PluginEngine pluginEngine)
public Plugin(PluginEngine pluginEngine, java.net.URL pluginURL)
pluginURL
- The location this Plugin uses to lookup class files and resources.Method Detail |
public boolean start()
public void stop()
public void unload()
public void disable()
public void enable()
public void addExtensionPoint(ExtensionPoint extensionPoint)
public void removeExtensionPoint(ExtensionPoint extensionPoint)
public ExtensionPoint getExtensionPoint(java.lang.String name)
name
- The name of the ExtensionPoint.public java.util.List getExtensionPoints()
public void addExtension(Extension extension)
public void removeExtension(Extension extension)
public java.util.List getExtensions()
public void addDependency(Dependency dependency)
public void removeDependency(Dependency dependency)
addExtension(Extension)
).
public java.util.List getDependencies()
public Dependency getDependency(java.lang.String pluginUID)
public java.util.List getDependentPlugins()
public java.lang.ClassLoader getPluginClassLoader()
public boolean isCompatible(Plugin plugin)
public java.lang.String getExtractedResourcePath(java.lang.String name) throws java.io.IOException
java.io.IOException
- if the resource does not exist or could not be extracted.public java.lang.String replaceToken(java.lang.String token)
token
- A String starting and ending with "%%" for a PluginEngine token or System property, or with "$$" for a
plugin.properties resource.public void setLifecycleClassName(java.lang.String lifecycleClassName)
PluginLifecycle
public java.lang.String getLifecycleClassName()
PluginLifecycle
public PluginLifecycle getLifecycleInstance()
PluginLifecycle
public void setMetadataXmlNode(PluginXmlNode metadataXmlNode)
public PluginXmlNode getMetadataXmlNode()
public void setName(java.lang.String name)
public java.lang.String getName()
public boolean isArchive()
public java.net.URL getPluginURL()
isArchive()
public boolean isStarted()
start()
,
PluginLifecycle.start()
public boolean isResolved()
public boolean isDisabled()
PluginEngine.disablePlugin(Plugin)
public java.lang.String getUID()
public void setUID(java.lang.String uid)
public void setStartWhenResolved(boolean startWhenResolved)
start()
,
PluginLifecycle.start()
public boolean getStartWhenResolved()
public void setDependentPluginLookup(boolean dependentPluginLookup)
public boolean getDependentPluginLookup()
setDependentPluginLookup(boolean)
public void setVersion(PluginVersion version)
public PluginVersion getVersion()
public int hashCode()
public java.lang.String toString()
public PluginEngine getPluginEngine()
public int compareTo(java.lang.Object object)
compareTo
in interface java.lang.Comparable
compareTo(Plugin)
public int compareTo(Plugin plugin)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |