Chapter 27. Portlet Filter
The Java Portlet Specification introduces PortletFilter as a standard approach to extend the behaviors of portlet objects. For example, a filter can transform the content of portlet requests and portlet responses.
According to the Portlet Specification, there are normally three steps in setting up a portlet filter:
- Implement a PortletFilter object.
- Define the filter in portlet application deployment descriptor.
- Define the filter mapping in portlet definitions.
While the first two steps are quite straightforward, the third requires developers or administrators to replicate the filter mapping in many portlet definitions. This can be tedious and opens the potential for input errors. The global portlet feature is designed to mitigate these concerns.
Example 27.1. Contents of portlet.xml
Global portlet metadata is declared in the portlet.xml file and conforms with the Portlet 2.0 XSD.
<portlet-app version="1.0" xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
</portlet-app>
The path to the global
portlet.xml is the value of gatein.portlet.config in the configuration.properties.xml file. By default, the file path is $JPP_HOME/standalone/configuration/gatein/portlet.xml
27.1. Global Metadata Elements
27.1.1. Global Metadata Elements
The global
$JPP_HOME/standalone/configuration/gatein/portlet.xml file conforms, with some restrictions, to the portlet deployment descriptor schema defined in the Portlet Specification. In this file, the following elements are supported:
- Portlet Filter
- Portlet Mode
- Window State
27.1.2. Configuring a Portlet Filter
Portlet filter mappings are declared in the global
portlet.xml file and applied across portlet applications.
Example 27.2. Configuring a filter
The filter
ApplicationMonitoringFilter is involved in request handling on any deployed portlet.
<filter> <filter-name>org.exoplatform.portal.application.ApplicationMonitoringFilter</filter-name> <filter-class>org.exoplatform.portal.application.ApplicationMonitoringFilter</filter-class> <life-cycle>ACTION_PHASE</life-cycle> <life-cycle>RENDER_PHASE</life-cycle> <life-cycle>EVENT_PHASE</life-cycle> <life-cycle>RESOURCE_PHASE</life-cycle> </filter>
Application Monitoring Filter supports four life-cycle phases:
- ACTION_PHASE
- EVENT_PHASE
- RENDER_PHASE
- RESOURCE_PHASE
The Application Monitoring Filter records statistic information about deployed portlets. The filter alternates the actual monitoring mechanism in WebUI Framework.