Class PluginBeanHelper<TBean extends IPluginGenericCustomGUIBean,TPlugin extends IFCPlugin & IPluginGenericCustomGUI<TBean>>

java.lang.Object
de.xima.fc.gui.bean.plugingui.PluginBeanHelper<TBean,TPlugin>
Type Parameters:
TBean - Type of the bean
TPlugin - Type of the plugin
All Implemented Interfaces:
Serializable

public class PluginBeanHelper<TBean extends IPluginGenericCustomGUIBean,TPlugin extends IFCPlugin & IPluginGenericCustomGUI<TBean>> extends Object implements Serializable
Helper class for handling unmanaged beans used by user interfaces provided by a plugin, eg. 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:
  • Method Details

    • destroyBeans

      public final List<de.xima.fc.gui.bean.plugingui.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 final Map<String,TBean> getOrCreateBeans() throws Exception
      Returns:
      An 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 PluginBeanHelper.IPreInitAction<TBean> getPreInitAction()
      Returns:
      the preInitAction
    • removeBeans

      public final 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.

    • setPreInitAction

      public void setPreInitAction(PluginBeanHelper.IPreInitAction<TBean> preInitAction)
      Parameters:
      preInitAction - the preInitAction to set
    • forCurrentApplicationScope

      public static <TBean extends IPluginGenericCustomGUIBean, TPlugin extends IFCPlugin & IPluginGenericCustomGUI<TBean>> PluginBeanHelper<TBean,TPlugin> forCurrentApplicationScope(TPlugin plugin, Mandant client, PluginBeanOptions pluginBeanOptions) throws Exception
      A new helper for application scoped beans of the given plugin.
      Type Parameters:
      TBean - Type of the plugin beans.
      TPlugin - 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.
    • forCurrentRequestScope

      public static <TBean extends IPluginGenericCustomGUIBean, TPlugin extends IFCPlugin & IPluginGenericCustomGUI<TBean>> PluginBeanHelper<TBean,TPlugin> forCurrentRequestScope(TPlugin 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.
    • forCurrentSessionScope

      public static <TBean extends IPluginGenericCustomGUIBean, TPlugin extends IFCPlugin & IPluginGenericCustomGUI<TBean>> PluginBeanHelper<TBean,TPlugin> forCurrentSessionScope(TPlugin plugin, Mandant client, PluginBeanOptions pluginBeanOptions) throws Exception
      A new helper for session scoped beans of the given plugin.
      Type Parameters:
      TBean - Type of the plugin beans.
      TPlugin - 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.
    • forCurrentViewScope

      public static <TBean extends IPluginGenericCustomGUIBean, TPlugin extends IFCPlugin & IPluginGenericCustomGUI<TBean>> PluginBeanHelper<TBean,TPlugin> forCurrentViewScope(TPlugin plugin, Mandant client, PluginBeanOptions pluginBeanOptions) throws Exception
      A new helper for view scoped beans of the given plugin.
      Type Parameters:
      TBean - Type of the plugin beans.
      TPlugin - 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.