java.lang.Object | |||
↳ | GenericPortlet | ||
↳ | org.springframework.web.portlet.GenericPortletBean | ||
↳ | org.springframework.web.portlet.FrameworkPortlet |
Known Direct Subclasses |
Base portlet for Spring's portlet framework. Provides integration with a Spring application context, in a JavaBean-based overall solution.
This class offers the following functionality:
ApplicationContext
instance per portlet. The portlet's configuration is determined by beans
in the portlet's namespace.
Subclasses must implement doActionService(ActionRequest, ActionResponse)
and doRenderService(RenderRequest, RenderResponse)
to handle action and render requests. Because this extends GenericPortletBean
rather than Portlet directly, bean properties are mapped onto it. Subclasses can
override initFrameworkPortlet()
for custom initialization.
Regards a "contextClass" parameter at the portlet init-param level,
falling back to the default context class
(XmlPortletApplicationContext
)
if not found. Note that, with the default FrameworkPortlet,
a context class needs to implement the
ConfigurablePortletApplicationContext
SPI.
Passes a "contextConfigLocation" portlet init-param to the context instance, parsing it into potentially multiple file paths which can be separated by any number of commas and spaces, like "test-portlet.xml, myPortlet.xml". If not explicitly specified, the context implementation is supposed to build a default location from the namespace of the portlet.
Note: In case of multiple config locations, later bean definitions will override ones defined in earlier loaded files, at least when using one of Spring's default ApplicationContext implementations. This can be leveraged to deliberately override certain bean definitions via an extra XML file.
The default namespace is "'portlet-name'-portlet", e.g. "test-portlet" for a portlet-name "test" (leading to a "/WEB-INF/test-portlet.xml" default location with XmlPortletApplicationContext). The namespace can also be set explicitly via the "namespace" portlet init-param.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | DEFAULT_NAMESPACE_SUFFIX | Suffix for Portlet ApplicationContext namespaces. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
DEFAULT_CONTEXT_CLASS | Default context class for FrameworkPortlet. | ||||||||||
DEFAULT_USERINFO_ATTRIBUTE_NAMES | Default USER_INFO attribute names to search for the current username: "user.login.id", "user.name". | ||||||||||
PORTLET_CONTEXT_PREFIX | Prefix for the PortletContext attribute for the Portlet ApplicationContext. |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.web.portlet.GenericPortletBean
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Close the ApplicationContext of this portlet.
| |||||||||||
Return the custom context class.
| |||||||||||
Return the explicit context config location, if any.
| |||||||||||
Return the namespace for this portlet, falling back to default scheme if
no custom namespace was set.
| |||||||||||
Return this portlet's ApplicationContext.
| |||||||||||
Return the PortletContext attribute name for this portlets's ApplicationContext.
| |||||||||||
ApplicationListener endpoint that receives events from this servlet's
WebApplicationContext.
| |||||||||||
Delegate action requests to processRequest/doActionService.
| |||||||||||
Refresh this portlet's application context, as well as the
dependent state of the portlet.
| |||||||||||
Set a custom context class.
| |||||||||||
Set the context config location explicitly, instead of relying on the default
location built from the namespace.
| |||||||||||
Set a custom namespace for this portlet,
to be used for building a default context config location.
| |||||||||||
Set whether to publish this portlet's context as a PortletContext attribute,
available to all objects in the web container.
| |||||||||||
Set whether this portlet should publish a PortletRequestHandledEvent at the end
of each request.
| |||||||||||
Set whether to expose the LocaleContext and RequestAttributes as inheritable
for child threads (using an
InheritableThreadLocal ). | |||||||||||
Set the list of attributes to search in the USER_INFO map when trying
to find the username of the current user.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Build a LocaleContext for the given request, exposing the request's
primary locale as current locale.
| |||||||||||
Instantiate the Portlet ApplicationContext for this portlet, either a default
XmlPortletApplicationContext or a custom context class if set.
| |||||||||||
Subclasses must implement this method to do the work of action request handling.
| |||||||||||
Delegate render requests to processRequest/doRenderService.
| |||||||||||
Subclasses must implement this method to do the work of event request handling.
| |||||||||||
Subclasses must implement this method to do the work of render request handling.
| |||||||||||
Subclasses must implement this method to do the work of resource request handling.
| |||||||||||
Overridden for friendlier behavior in unit tests.
| |||||||||||
Determine the username for the given request.
| |||||||||||
This method will be invoked after any bean properties have been set and
the ApplicationContext has been loaded.
| |||||||||||
Initialize and publish the Portlet ApplicationContext for this portlet.
| |||||||||||
Overridden method of GenericPortletBean, invoked after any bean properties
have been set.
| |||||||||||
Template method which can be overridden to add portlet-specific refresh work.
| |||||||||||
Post-process the given Portlet ApplicationContext before it is refreshed
and activated as context for this portlet.
| |||||||||||
Process this request, publishing an event regardless of the outcome.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.web.portlet.GenericPortletBean
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.context.ApplicationListener
| |||||||||||
From interface
org.springframework.context.EnvironmentAware
|
Suffix for Portlet ApplicationContext namespaces. If a portlet of this class is given the name "test" in a context, the namespace used by the portlet will resolve to "test-portlet".
Default context class for FrameworkPortlet.
Default USER_INFO attribute names to search for the current username: "user.login.id", "user.name".
Prefix for the PortletContext attribute for the Portlet ApplicationContext. The completion is the portlet name.
Return the namespace for this portlet, falling back to default scheme if no custom namespace was set. (e.g. "test-portlet" for a portlet named "test")
Return this portlet's ApplicationContext.
Return the PortletContext attribute name for this portlets's ApplicationContext.
The default implementation returns PORTLET_CONTEXT_PREFIX + portlet name.
ApplicationListener endpoint that receives events from this servlet's WebApplicationContext.
The default implementation calls onRefresh(ApplicationContext)
in case of a
ContextRefreshedEvent
,
triggering a refresh of this servlet's context-dependent state.
event | the incoming ApplicationContext event |
---|
Delegate action requests to processRequest/doActionService.
IOException | |
---|---|
PortletException |
IOException | |
---|---|
PortletException |
Refresh this portlet's application context, as well as the dependent state of the portlet.
IOException | |
---|---|
PortletException |
Set a custom context class. This class must be of type ApplicationContext; when using the default FrameworkPortlet implementation, the context class must also implement ConfigurablePortletApplicationContext.
Set the context config location explicitly, instead of relying on the default location built from the namespace. This location string can consist of multiple locations separated by any number of commas and spaces.
Set a custom namespace for this portlet, to be used for building a default context config location.
Set whether to publish this portlet's context as a PortletContext attribute, available to all objects in the web container. Default is true.
This is especially handy during testing, although it is debatable whether it's good practice to let other application objects access the context this way.
Set whether this portlet should publish a PortletRequestHandledEvent at the end of each request. Default is true; can be turned off for a slight performance improvement, provided that no ApplicationListeners rely on such events.
Set whether to expose the LocaleContext and RequestAttributes as inheritable
for child threads (using an InheritableThreadLocal
).
Default is "false", to avoid side effects on spawned background threads. Switch this to "true" to enable inheritance for custom child threads which are spawned during request processing and only used for this request (that is, ending after their initial task, without reuse of the thread).
WARNING: Do not use inheritance for child threads if you are
accessing a thread pool which is configured to potentially add new threads
on demand (e.g. a JDK ThreadPoolExecutor
),
since this will expose the inherited context to such a pooled thread.
Set the list of attributes to search in the USER_INFO map when trying to find the username of the current user.
Build a LocaleContext for the given request, exposing the request's primary locale as current locale.
request | current HTTP request |
---|
Instantiate the Portlet ApplicationContext for this portlet, either a default XmlPortletApplicationContext or a custom context class if set.
This implementation expects custom contexts to implement ConfigurablePortletApplicationContext. Can be overridden in subclasses.
parent | the parent ApplicationContext to use, or null if none |
---|
Subclasses must implement this method to do the work of action request handling.
The contract is essentially the same as that for the processAction
method of GenericPortlet.
This class intercepts calls to ensure that exception handling and event publication takes place.
request | current action request |
---|---|
response | current action response |
Exception | in case of any kind of processing failure |
---|
Delegate render requests to processRequest/doRenderService.
IOException | |
---|---|
PortletException |
Subclasses must implement this method to do the work of event request handling.
The contract is essentially the same as that for the processEvent
method of GenericPortlet.
This class intercepts calls to ensure that exception handling and event publication takes place.
request | current event request |
---|---|
response | current event response |
Exception | in case of any kind of processing failure |
---|
Subclasses must implement this method to do the work of render request handling.
The contract is essentially the same as that for the doDispatch
method of GenericPortlet.
This class intercepts calls to ensure that exception handling and event publication takes place.
request | current render request |
---|---|
response | current render response |
Exception | in case of any kind of processing failure |
---|
Subclasses must implement this method to do the work of resource request handling.
The contract is essentially the same as that for the serveResource
method of GenericPortlet.
This class intercepts calls to ensure that exception handling and event publication takes place.
request | current resource request |
---|---|
response | current resource response |
Exception | in case of any kind of processing failure |
---|
Overridden for friendlier behavior in unit tests.
Determine the username for the given request.
The default implementation first tries the UserPrincipal. If that does not exist, then it checks the USER_INFO map. Can be overridden in subclasses.
request | current portlet request |
---|
null
if none foundsetUserinfoUsernameAttributes(String[])
This method will be invoked after any bean properties have been set and the ApplicationContext has been loaded.
The default implementation is empty; subclasses may override this method to perform any initialization they require.
in case of an initialization exception | |
PortletException |
Initialize and publish the Portlet ApplicationContext for this portlet.
Delegates to createPortletApplicationContext(ApplicationContext)
for actual creation.
Can be overridden in subclasses.
Overridden method of GenericPortletBean, invoked after any bean properties have been set. Creates this portlet's ApplicationContext.
PortletException |
---|
Template method which can be overridden to add portlet-specific refresh work. Called after successful context refresh.
This implementation is empty.
context | the current Portlet ApplicationContext |
---|
Post-process the given Portlet ApplicationContext before it is refreshed and activated as context for this portlet.
The default implementation is empty. refresh()
will
be called automatically after this method returns.
pac | the configured Portlet ApplicationContext (not refreshed yet) |
---|
Process this request, publishing an event regardless of the outcome.
The actual event handling is performed by the abstract
doActionService()
and doRenderService()
template methods.
IOException | |
---|---|
PortletException |