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 thePostConstruct
method of said bean an instance of this helper should be created and getOrCreateBean(Class) should be called. In thePreDestroy
methoddestroyBeans()
should be called (notremoveBeans()
, as the entire scope is about to be destroyed).- Author:
- XIMA MEDIA GmbH
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
PluginBeanHelper.IPreInitAction<TBean extends IPluginGenericCustomGUIBean>
Interface for a callback before a bean is initialized.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.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.Map<String,TBean>
getOrCreateBeans()
String
getPluginName()
PluginBeanHelper.IPreInitAction<TBean>
getPreInitAction()
void
removeBeans()
Destroys all beans and removes them from their current scope.void
setPreInitAction(PluginBeanHelper.IPreInitAction<TBean> preInitAction)
-
-
-
Method Detail
-
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). UsedestroyBeans()
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 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.
-
-