Class 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 the INJECTED and ACTIVATED 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 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 class InstalledBundleObject
        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 interface IconProvider
        Specified by:
        getIcon in class InstalledBundleObject
        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 class InstalledBundleObject
        Returns:
        the name reported by the plug-in
      • getPlugin

        public Plugin getPlugin()
        Returns the plug-in instance managed by this InstalledPlugin, or null if no instance currently exists. To create an instance, call startPlugin().
        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
      • 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()
        Returns true if the plug-in represented by this object is currently started.
        Returns:
        true if getPlugin() 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 by getPlugin().
        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 return null 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)
        Returns true if the two installed plug-ins are equal. Two installed plug-ins are equal if they have the same class identifier.
        Overrides:
        equals in class java.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 with equals(java.lang.Object).
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        a hash code for the plug-in instance
      • isReloadable

        protected boolean isReloadable()
        Returns true 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