Package de.xima.fc.gui.bean.plugingui
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 beanTPlugin
- 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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Interface for a callback before a bean is initialized. -
Method Summary
Modifier and TypeMethodDescriptionfinal List<de.xima.fc.gui.bean.plugingui.PluginBeanInfo>
Destroys all beans from the current request, view, session or application scope, according to the specified bean scope handler.static <TBean extends IPluginGenericCustomGUIBean,
TPlugin extends IFCPlugin & IPluginGenericCustomGUI<TBean>>
PluginBeanHelper<TBean,TPlugin> forCurrentApplicationScope
(TPlugin plugin, Mandant client, PluginBeanOptions pluginBeanOptions) A new helper for application scoped beans of the given plugin.static <TBean extends IPluginGenericCustomGUIBean,
TPlugin extends IFCPlugin & IPluginGenericCustomGUI<TBean>>
PluginBeanHelper<TBean,TPlugin> forCurrentRequestScope
(TPlugin plugin, Mandant client, PluginBeanOptions pluginBeanOptions) A new helper for application request beans of the given plugin.static <TBean extends IPluginGenericCustomGUIBean,
TPlugin extends IFCPlugin & IPluginGenericCustomGUI<TBean>>
PluginBeanHelper<TBean,TPlugin> forCurrentSessionScope
(TPlugin plugin, Mandant client, PluginBeanOptions pluginBeanOptions) A new helper for session scoped beans of the given plugin.static <TBean extends IPluginGenericCustomGUIBean,
TPlugin extends IFCPlugin & IPluginGenericCustomGUI<TBean>>
PluginBeanHelper<TBean,TPlugin> forCurrentViewScope
(TPlugin plugin, Mandant client, PluginBeanOptions pluginBeanOptions) A new helper for view scoped beans of the given plugin.final void
Destroys all beans and removes them from their current scope.void
setPreInitAction
(PluginBeanHelper.IPreInitAction<TBean> preInitAction)
-
Method Details
-
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
- 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
- Returns:
- The name of the plugin that provides the bean.
-
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). UsedestroyBeans()
instead. -
setPreInitAction
- 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 beansclient
- The current client, may benull
for the system administrator without a clientpluginBeanOptions
- Options for handling the plugin beans, such as whether post construct annotations should be processed. Passnull
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 beansclient
- The current client, may benull
for the system administrator without a clientpluginBeanOptions
- Options for handling the plugin beans, such as whether post construct annotations should be processed. Passnull
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 beansclient
- The current client, may benull
for the system administrator without a clientpluginBeanOptions
- Options for handling the plugin beans, such as whether post construct annotations should be processed. Passnull
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 beansclient
- The current client, may benull
for the system administrator without a clientpluginBeanOptions
- Options for handling the plugin beans, such as whether post construct annotations should be processed. Passnull
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.
-