Class PluginBeanHelper<Bean extends IPluginGenericCustomGUIBean,​TPlugin extends IFCPlugin>

  • Type Parameters:
    Bean - Type of the bean
    TPlugin - Type of the plugin
    All Implemented Interfaces:
    Serializable

    public final class PluginBeanHelper<Bean extends IPluginGenericCustomGUIBean,​TPlugin extends IFCPlugin>
    extends Object
    implements Serializable
    Helper class for handling unmanaged beans used by user interfaces provided by a plugin, e.g. a dashboard plugin or a workflow action plugin:
     PluginBeanHelper.forCurrentViewScope(plugin, client).getOrCreateBeans();
     
    Each helper is associated to a certain scope (request, view, session, or application scope). It should be used by an accompanying managed bean of the same scope. In the PostConstruct method of said bean an instance of this helper should be created and getOrCreateBean(Class) should be called. In the PreDestroy method destroyBeans() should be called (not removeBeans(), as the entire scope is about to be destroyed).
    Author:
    XIMA MEDIA GmbH
    See Also:
    Serialized Form
    • Method Detail

      • destroyBeans

        public List<PluginBeanInfo> destroyBeans()
        Destroys all beans from the current request, view, session or application scope, according to the specified bean scope handler.
        Returns:
        A List of beans that were destroyed.
      • getOrCreateBeans

        public Map<String,​Bean> getOrCreateBeans()
                                                throws Exception
        Returns:
        A map between the bean name and the existing or newly created instance of each bean.
        Throws:
        Exception - When a bean could not be retrieved or created, such as when a bean threw an Exception during initialization or when no active request / session could be found.
      • getPluginName

        public String getPluginName()
        Returns:
        The name of the plugin that provides the bean.
      • getPreInitAction

        public IPreInitAction<Bean> getPreInitAction()
        Gets the custom pre-init action to be executed before initializing the beans. This action can be used to perform additional setup or configuration on the beans before they are initialized.
        Returns:
        The pre-init action to be executed before initializing the beans, or null if no action is set.
      • setPreInitAction

        public void setPreInitAction​(IPreInitAction<Bean> preInitAction)
        Sets a custom pre-init action to be executed before initializing the beans. This can be used to perform additional setup or configuration on the beans before they are initialized.
        Parameters:
        preInitAction - The pre-init action to set, or null to remove any existing action.
      • isStale

        public boolean isStale()
        Checks whether this helper is stale. The helper is judged to be stale when the plugin has changed, i.e. the plugin was deinstalled, deactivated, or updated.
        Returns:
        Whether the helper is stale, i.e. the plugin has changed.
      • removeBeans

        public void removeBeans()
        Destroys all beans and removes them from their current scope.

        Do not call this in a PreDestroy method of a managed bean, or you may run into issues such as concurrent modification exceptions (as the JSF framework is currently iterating over the map from which we remove the beans). Use destroyBeans() instead.

      • forCurrentApplicationScope

        public static <Bean extends IPluginGenericCustomGUIBean,​Plugin extends IFCPlugin & IPluginGenericCustomGUI<Bean>> PluginBeanHelper<Bean,​Plugin> forCurrentApplicationScope​(Plugin plugin,
                                                                                                                                                                                               Mandant client,
                                                                                                                                                                                               PluginBeanOptions pluginBeanOptions)
                                                                                                                                                                                        throws Exception
        A new helper for application scoped beans of the given plugin.
        Type Parameters:
        Bean - Type of the plugin beans.
        Plugin - Type of the plugin that provides the beans.
        Parameters:
        plugin - Plugin that provides the beans
        client - The current client, may be null for the system administrator without a client
        pluginBeanOptions - Options for handling the plugin beans, such as whether post construct annotations should be processed. Pass null to use the defaults.
        Returns:
        A new plugin helper instance for the given data
        Throws:
        Exception - When no plugin runtime could be found for the given plugin; or when no request is currently active.
      • forCurrentApplicationScope

        public static <Bean extends IPluginGenericCustomGUIBean,​Plugin extends IFCPlugin> PluginBeanHelper<Bean,​Plugin> forCurrentApplicationScope​(Plugin plugin,
                                                                                                                                                               IPluginCustomGUIExtractor<Bean,​Plugin> guiExtractor,
                                                                                                                                                               Mandant client,
                                                                                                                                                               PluginBeanOptions pluginBeanOptions)
                                                                                                                                                        throws Exception
        A new helper for application scoped beans of the given plugin.
        Type Parameters:
        Bean - Type of the plugin beans.
        Plugin - Type of the plugin that provides the beans.
        Parameters:
        plugin - Plugin that provides the beans
        guiExtractor - Extractor for the GUI of the plugin, used to retrieve the view and bean classes.
        client - The current client, may be null for the system administrator without a client
        pluginBeanOptions - Options for handling the plugin beans, such as whether post construct annotations should be processed. Pass null to use the defaults.
        Returns:
        A new plugin helper instance for the given data
        Throws:
        Exception - When no plugin runtime could be found for the given plugin; or when no request is currently active.
      • forCurrentRequestScope

        public static <Bean extends IPluginGenericCustomGUIBean,​Plugin extends IFCPlugin & IPluginGenericCustomGUI<Bean>> PluginBeanHelper<Bean,​Plugin> forCurrentRequestScope​(Plugin plugin,
                                                                                                                                                                                           Mandant client,
                                                                                                                                                                                           PluginBeanOptions pluginBeanOptions)
                                                                                                                                                                                    throws Exception
        A new helper for application request beans of the given plugin.
        Parameters:
        plugin - Plugin that provides the beans
        client - The current client, may be null for the system administrator without a client
        pluginBeanOptions - Options for handling the plugin beans, such as whether post construct annotations should be processed. Pass null to use the defaults.
        Returns:
        A new plugin helper instance for the given data
        Throws:
        Exception - When no plugin runtime could be found for the given plugin; or when no request is currently active.
      • forCurrentRequestScope

        public static <Bean extends IPluginGenericCustomGUIBean,​Plugin extends IFCPlugin> PluginBeanHelper<Bean,​Plugin> forCurrentRequestScope​(Plugin plugin,
                                                                                                                                                           IPluginCustomGUIExtractor<Bean,​Plugin> guiExtractor,
                                                                                                                                                           Mandant client,
                                                                                                                                                           PluginBeanOptions pluginBeanOptions)
                                                                                                                                                    throws Exception
        A new helper for application request beans of the given plugin.
        Parameters:
        plugin - Plugin that provides the beans
        client - The current client, may be null for the system administrator without a client
        guiExtractor - Extractor for the GUI of the plugin, used to retrieve the view and bean classes.
        pluginBeanOptions - Options for handling the plugin beans, such as whether post construct annotations should be processed. Pass null to use the defaults.
        Returns:
        A new plugin helper instance for the given data
        Throws:
        Exception - When no plugin runtime could be found for the given plugin; or when no request is currently active.
      • forCurrentSessionScope

        public static <Bean extends IPluginGenericCustomGUIBean,​Plugin extends IFCPlugin & IPluginGenericCustomGUI<Bean>> PluginBeanHelper<Bean,​Plugin> forCurrentSessionScope​(Plugin plugin,
                                                                                                                                                                                           Mandant client,
                                                                                                                                                                                           PluginBeanOptions pluginBeanOptions)
                                                                                                                                                                                    throws Exception
        A new helper for session scoped beans of the given plugin.
        Type Parameters:
        Bean - Type of the plugin beans.
        Plugin - Type of the plugin that provides the beans.
        Parameters:
        plugin - Plugin that provides the beans
        client - The current client, may be null for the system administrator without a client
        pluginBeanOptions - Options for handling the plugin beans, such as whether post construct annotations should be processed. Pass null to use the defaults.
        Returns:
        A new plugin helper instance for the given data
        Throws:
        Exception - When no plugin runtime could be found for the given plugin; or when no request is currently active.
      • forCurrentSessionScope

        public static <Bean extends IPluginGenericCustomGUIBean,​Plugin extends IFCPlugin> PluginBeanHelper<Bean,​Plugin> forCurrentSessionScope​(Plugin plugin,
                                                                                                                                                           IPluginCustomGUIExtractor<Bean,​Plugin> guiExtractor,
                                                                                                                                                           Mandant client,
                                                                                                                                                           PluginBeanOptions pluginBeanOptions)
                                                                                                                                                    throws Exception
        A new helper for session scoped beans of the given plugin.
        Type Parameters:
        Bean - Type of the plugin beans.
        Plugin - Type of the plugin that provides the beans.
        Parameters:
        plugin - Plugin that provides the beans
        guiExtractor - Extractor for the GUI of the plugin, used to retrieve the view and bean classes.
        client - The current client, may be null for the system administrator without a client
        pluginBeanOptions - Options for handling the plugin beans, such as whether post construct annotations should be processed. Pass null to use the defaults.
        Returns:
        A new plugin helper instance for the given data
        Throws:
        Exception - When no plugin runtime could be found for the given plugin; or when no request is currently active.
      • forCurrentViewScope

        public static <Bean extends IPluginGenericCustomGUIBean,​Plugin extends IFCPlugin & IPluginGenericCustomGUI<Bean>> PluginBeanHelper<Bean,​Plugin> forCurrentViewScope​(Plugin plugin,
                                                                                                                                                                                        Mandant client,
                                                                                                                                                                                        PluginBeanOptions pluginBeanOptions)
                                                                                                                                                                                 throws Exception
        A new helper for view scoped beans of the given plugin.
        Type Parameters:
        Bean - Type of the plugin beans.
        Plugin - Type of the plugin that provides the beans.
        Parameters:
        plugin - Plugin that provides the beans
        client - The current client, may be null for the system administrator without a client
        pluginBeanOptions - Options for handling the plugin beans, such as whether post construct annotations should be processed. Pass null to use the defaults.
        Returns:
        A new plugin helper instance for the given data
        Throws:
        Exception - When no plugin runtime could be found for the given plugin; or when no view is currently active.
      • forCurrentViewScope

        public static <Bean extends IPluginGenericCustomGUIBean,​Plugin extends IFCPlugin> PluginBeanHelper<Bean,​Plugin> forCurrentViewScope​(Plugin plugin,
                                                                                                                                                        IPluginCustomGUIExtractor<Bean,​Plugin> guiExtractor,
                                                                                                                                                        Mandant client,
                                                                                                                                                        PluginBeanOptions pluginBeanOptions)
                                                                                                                                                 throws Exception
        A new helper for view scoped beans of the given plugin.
        Type Parameters:
        Bean - Type of the plugin beans.
        Plugin - Type of the plugin that provides the beans.
        Parameters:
        plugin - Plugin that provides the beans
        guiExtractor - Extractor for the GUI of the plugin, used to retrieve the view and bean classes.
        client - The current client, may be null for the system administrator without a client
        pluginBeanOptions - Options for handling the plugin beans, such as whether post construct annotations should be processed. Pass null to use the defaults.
        Returns:
        A new plugin helper instance for the given data
        Throws:
        Exception - When no plugin runtime could be found for the given plugin; or when no view is currently active.