Class StandardPluginManager


  • public final class StandardPluginManager
    extends PluginManager
    Standard implementation of plug-in manager.
    Version:
    $Id: StandardPluginManager.java,v 1.8 2007/04/07 12:41:01 ddimon Exp $
    • Constructor Detail

      • StandardPluginManager

        protected StandardPluginManager​(PluginRegistry aRegistry,
                                        PathResolver aPathResolver,
                                        PluginLifecycleHandler aLifecycleHandler)
        Creates instance of plug-in manager for given registry, path resolver and life cycle handler.
        Parameters:
        aRegistry - some implementation of plug-in registry interface
        aPathResolver - some implementation of path resolver interface
        aLifecycleHandler - an implementation of plug-in life cycle handler
        See Also:
        StandardObjectFactory
    • Method Detail

      • publishPlugins

        public java.util.Map<java.lang.String,​Identity> publishPlugins​(PluginManager.PluginLocation[] locations)
                                                                      throws JpfException
        Registers plug-ins and their locations with this plug-in manager. You should use this method to register new plug-ins to make them available for activation with this manager instance (compare this to PluginRegistry.register(URL[]) method that just makes plug-in's meta-data available for reading and doesn't "know" where are things actually located).
        Specified by:
        publishPlugins in class PluginManager
        Parameters:
        locations - plug-in locations data
        Returns:
        map where keys are manifest URL's and values are registered plug-ins or plug-in fragments, URL's for unprocessed manifests are not included
        Throws:
        JpfException - if given plug-ins can't be registered or published (optional behavior)
        See Also:
        PluginDescriptor, PluginFragment
      • getPlugin

        public Plugin getPlugin​(java.lang.String id)
                         throws PluginLifecycleException
        Looks for plug-in with given ID and activates it if it is not activated yet. Note that this method will never return null.
        Specified by:
        getPlugin in class PluginManager
        Parameters:
        id - plug-in ID
        Returns:
        found plug-in
        Throws:
        PluginLifecycleException - if plug-in can't be found or activated
      • getPluginFor

        public Plugin getPluginFor​(java.lang.Object obj)
        Looks for plug-in, given object belongs to.
        Specified by:
        getPluginFor in class PluginManager
        Parameters:
        obj - any object that maybe belongs to some plug-in
        Returns:
        plug-in or null if given object doesn't belong to any plug-in (possibly it is part of "host" application) and thus doesn't managed by the Framework directly or indirectly
      • isPluginActivated

        public boolean isPluginActivated​(PluginDescriptor descr)
        Specified by:
        isPluginActivated in class PluginManager
        Parameters:
        descr - plug-in descriptor
        Returns:
        true if plug-in with given descriptor is activated
      • isBadPlugin

        public boolean isBadPlugin​(PluginDescriptor descr)
        Specified by:
        isBadPlugin in class PluginManager
        Parameters:
        descr - plug-in descriptor
        Returns:
        true if plug-in disabled as it's activation fails
      • getPluginClassLoader

        public PluginClassLoader getPluginClassLoader​(PluginDescriptor descr)
        Returns instance of plug-in's class loader and not tries to activate plug-in. Use this method if you need to get access to plug-in resources and don't want to cause plug-in activation.
        Specified by:
        getPluginClassLoader in class PluginManager
        Parameters:
        descr - plug-in descriptor
        Returns:
        class loader instance for plug-in with given descriptor
      • shutdown

        public void shutdown()
        Shuts down the framework.
        Calling this method will deactivate all active plug-ins in order, reverse to the order they was activated. It also releases all resources allocated by this manager (class loaders, plug-in descriptors etc.). All disabled plug-ins will be marked as "enabled", all registered event listeners will be unregistered.
        Specified by:
        shutdown in class PluginManager
      • deactivatePlugin

        public void deactivatePlugin​(java.lang.String id)
        Deactivates plug-in with given ID if it has been successfully activated before. Note that this method will effectively deactivate all plug-ins that depend on the given plug-in.
        Specified by:
        deactivatePlugin in class PluginManager
        Parameters:
        id - plug-in ID
      • disablePlugin

        public PluginDescriptor[] disablePlugin​(PluginDescriptor descr)
        Disables plug-in (with dependencies) in this manager instance. Disabled plug-in can't be activated although it may be valid and successfully registered with plug-in registry. Before disabling, plug-in will be deactivated if it was successfully activated.
        Be careful with this method as it can effectively disable large set of inter-depending plug-ins and your application may become unstable or even disabled as whole.
        Specified by:
        disablePlugin in class PluginManager
        Parameters:
        descr - descriptor of plug-in to be disabled
        Returns:
        descriptors of plug-ins that was actually disabled
      • enablePlugin

        public PluginDescriptor[] enablePlugin​(PluginDescriptor descr,
                                               boolean includeDependings)
        Enables plug-in (or plug-ins) in this manager instance.
        Specified by:
        enablePlugin in class PluginManager
        Parameters:
        descr - descriptor of plug-in to be enabled
        includeDependings - if true, depending plug-ins will be also enabled
        Returns:
        descriptors of plug-ins that was actually enabled
        See Also:
        disablePlugin(PluginDescriptor)
      • isPluginEnabled

        public boolean isPluginEnabled​(PluginDescriptor descr)
        Specified by:
        isPluginEnabled in class PluginManager
        Parameters:
        descr - plug-in descriptor
        Returns:
        true if given plug-in is disabled in this manager
      • registerListener

        public void registerListener​(PluginManager.EventListener listener)
        Registers plug-in manager event listener. If given listener has been registered before, this method will throw an IllegalArgumentException.
        Specified by:
        registerListener in class PluginManager
        Parameters:
        listener - new manager event listener
      • unregisterListener

        public void unregisterListener​(PluginManager.EventListener listener)
        Unregisters manager event listener. If given listener hasn't been registered before, this method will throw an IllegalArgumentException.
        Specified by:
        unregisterListener in class PluginManager
        Parameters:
        listener - registered listener