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 theINJECTEDandACTIVATEDplug-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 voidcollectPluginInfo(Plugin p)Called to allow subclasses to collect additional information about a plug-in while an information probe is being conducted.booleanequals(java.lang.Object obj)Returnstrueif the two installed plug-ins are equal.java.lang.StringgetDescription()Returns the plug-in description.ThemedIcongetIcon()Returns an icon for the plug-in.java.lang.StringgetName()Returns the name of the plug-in.PlugingetPlugin()Returns the plug-in instance managed by this InstalledPlugin, ornullif no instance currently exists.java.lang.StringgetPluginClass()Returns the class or script identifier, in normalized form, that this plug-in represents.intgetPluginType()Returns the type of the plug-in.java.lang.StringgetSettingPrefix()Returns a prefix that can be used to define a private namespace for the plug-in when accessing settings.floatgetVersion()Returns the plug-in's internal version.inthashCode()Returns a hash code based on the plug-in's class identifier, for consistency withequals(java.lang.Object).protected booleanisReloadable()Returnstrueif 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).booleanisStarted()Returnstrueif the plug-in represented by this object is currently started.PluginstartPlugin()Instantiates and initializes the plug-in represented by this InstalledPlugin.voidstopPlugin()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:
getDescriptionin 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:
getIconin interfaceIconProvider- Specified by:
getIconin 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:
getNamein classInstalledBundleObject- Returns:
- the name reported by the plug-in
-
getPlugin
public Plugin getPlugin()
Returns the plug-in instance managed by this InstalledPlugin, ornullif 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()
Returnstrueif the plug-in represented by this object is currently started.- Returns:
trueifgetPlugin()would return a non-nullvalue
-
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 PluginExceptionShuts down the plug-in instance, if any. After this call returns,getPlugin()will returnnullunless 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)
Returnstrueif the two installed plug-ins are equal. Two installed plug-ins are equal if they have the same class identifier.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- object to compare with- Returns:
- true if
objis 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:
hashCodein classjava.lang.Object- Returns:
- a hash code for the plug-in instance
-
isReloadable
protected boolean isReloadable()
Returnstrueif 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:
falseif the plug-in is an extension,trueotherwise
-
-