Class AbstractInstalledPlugin
- java.lang.Object
-
- ca.cgjennings.apps.arkham.plugins.InstalledBundleObject
-
- ca.cgjennings.apps.arkham.plugins.AbstractInstalledPlugin
-
- All Implemented Interfaces:
IconProvider
,java.lang.Comparable<InstalledBundleObject>
- Direct Known Subclasses:
InstalledExtension
,InstalledPlugin
public abstract class AbstractInstalledPlugin extends InstalledBundleObject
An installed plug-in bridges the gap between a plug-in bundle and the plug-ins that it contains. It is not the plug-in itself, but it creates and manages instances of the plug-in on demand. This is an abstract base class for the two basic types of plug-in in Strange Eons: extensions and "regular" plug-ins (which encompasses both theINJECTED
andACTIVATED
plug-in types). These two types are similar except that extensions can only be started once (during startup), while regular plug-ins are stopped and started on demand.- Since:
- 3.0
- Author:
- Chris Jennings
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
collectPluginInfo(Plugin p)
Called to allow subclasses to collect additional information about a plug-in while an information probe is being conducted.boolean
equals(java.lang.Object obj)
Returnstrue
if the two installed plug-ins are equal.java.lang.String
getDescription()
Returns the plug-in description.ThemedIcon
getIcon()
Returns an icon for the plug-in.java.lang.String
getName()
Returns the name of the plug-in.Plugin
getPlugin()
Returns the plug-in instance managed by this InstalledPlugin, ornull
if no instance currently exists.java.lang.String
getPluginClass()
Returns the class or script identifier, in normalized form, that this plug-in represents.int
getPluginType()
Returns the type of the plug-in.java.lang.String
getSettingPrefix()
Returns a prefix that can be used to define a private namespace for the plug-in when accessing settings.float
getVersion()
Returns the plug-in's internal version.int
hashCode()
Returns a hash code based on the plug-in's class identifier, for consistency withequals(java.lang.Object)
.protected boolean
isReloadable()
Returnstrue
if this plug-in is a reloadable type, or false if it is only run once (and thus should be run at the same time as the plug-in info is collected).boolean
isStarted()
Returnstrue
if the plug-in represented by this object is currently started.Plugin
startPlugin()
Instantiates and initializes the plug-in represented by this InstalledPlugin.void
stopPlugin()
Shuts down the plug-in instance, if any.-
Methods inherited from class ca.cgjennings.apps.arkham.plugins.InstalledBundleObject
compareTo, getBundle, getCatalogID, getPluginRoot, getPriority, getRepresentativeImage, isUninstallPending, isUpdatePending, markFailed, toString
-
-
-
-
Method Detail
-
getDescription
public java.lang.String getDescription()
Returns the plug-in description. If necessary, a new instance of the plug-in will be created temporarily in order to get this information.- Specified by:
getDescription
in classInstalledBundleObject
- Returns:
- the description reported by the plug-in
-
getIcon
public ThemedIcon getIcon()
Returns an icon for the plug-in. If the plug-in has a representative image, an icon is returned based on that image. Otherwise, a generic icon is returned based on the type of plug-in bundle.- Specified by:
getIcon
in interfaceIconProvider
- Specified by:
getIcon
in classInstalledBundleObject
- Returns:
- an icon for the plug-in
-
getName
public java.lang.String getName()
Returns the name of the plug-in. If necessary, a new instance of the plug-in will be created temporarily in order to get this information.- Specified by:
getName
in classInstalledBundleObject
- Returns:
- the name reported by the plug-in
-
getPlugin
public Plugin getPlugin()
Returns the plug-in instance managed by this InstalledPlugin, ornull
if no instance currently exists. To create an instance, callstartPlugin()
.- Returns:
- the current plug-in instance, or
null
-
getPluginClass
public java.lang.String getPluginClass()
Returns the class or script identifier, in normalized form, that this plug-in represents.- Returns:
- the plug-in class or script controlled by this instance
-
getPluginType
public int getPluginType()
Returns the type of the plug-in. If necessary, a new instance of the plug-in will be created temporarily in order to get this information.- Returns:
- the type reported by the plug-in
-
getSettingPrefix
public java.lang.String getSettingPrefix()
Returns a prefix that can be used to define a private namespace for the plug-in when accessing settings. The same prefix will be used by the plug-in context.- Returns:
- a setting namespace prefix
- See Also:
Settings.createNamespace(java.lang.String)
,PluginContext.getSettings()
-
getVersion
public float getVersion()
Returns the plug-in's internal version. This is separate from the version information in the catalog ID. If necessary, a new instance of the plug-in will be created temporarily in order to get this information.- Returns:
- the version reported by the plug-in
-
isStarted
public boolean isStarted()
Returnstrue
if the plug-in represented by this object is currently started.- Returns:
true
ifgetPlugin()
would return a non-null
value
-
startPlugin
public Plugin startPlugin() throws PluginException
Instantiates and initializes the plug-in represented by this InstalledPlugin. If an instance already exists, that instance is returned as if bygetPlugin()
.- Returns:
- the started plug-in instance
- Throws:
PluginException
- if the plug-in cannot be started
-
stopPlugin
public void stopPlugin() throws PluginException
Shuts down the plug-in instance, if any. After this call returns,getPlugin()
will returnnull
unless the plug-in is started again.- Throws:
PluginException
- if an exception occurs while stopping the plug-in
-
collectPluginInfo
protected void collectPluginInfo(Plugin p)
Called to allow subclasses to collect additional information about a plug-in while an information probe is being conducted. The base class does nothing.
-
equals
public boolean equals(java.lang.Object obj)
Returnstrue
if the two installed plug-ins are equal. Two installed plug-ins are equal if they have the same class identifier.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- object to compare with- Returns:
- true if
obj
is an installed plug-in with the same plug-in class
-
hashCode
public int hashCode()
Returns a hash code based on the plug-in's class identifier, for consistency withequals(java.lang.Object)
.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- a hash code for the plug-in instance
-
isReloadable
protected boolean isReloadable()
Returnstrue
if this plug-in is a reloadable type, or false if it is only run once (and thus should be run at the same time as the plug-in info is collected).- Returns:
false
if the plug-in is an extension,true
otherwise
-
-