The 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, normally there are 3 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.
Two first steps are quite simple and easy to be done, however, at the step 3, developers/administrators need to replicate the filter mapping in many portlet definitions that makes work erroneous and tedious in several usecases. The global portlet feature is designed to compensate such limitation.
The Global metadata is declared in the
portlet.xml
file conforming with Portlet 2.0 's 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 value of gatein.portlet.config in the configuration.properties
file and varied by hosting
application servers.
For Tomcat: $PLATFORM_TOMCAT_HOME/gatein/conf/portlet.xml
For JBoss: $PLATFORM_JBOSS_HOME/standalone/configuration/gatein/portlet.xml
The global portlet.xml
file conforms to the schema of the portlet deployment descriptor defined in the Portlet
Specification with some restrictions. In this file, the following elements are supported:
Portlet filter: The Portlet filter mappings declared in the global portlet.xml
file are applied across portlet applications. With
the XML configuration below, the ApplicationMonitoringFilter filter involves 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>
<lifecycle>ACTION_PHASE</lifecycle>
<lifecycle>RENDER_PHASE</lifecycle>
<lifecycle>EVENT_PHASE</lifecycle>
<lifecycle>RESOURCE_PHASE</lifecycle>
</filter>
Application Monitoring Filter supports 4 lifecycle phases as the order below: ACTION_PHASE/ EVENT_PHASE/ RENDER_PHASE/ RESOURCE_PHASE and records statistic information on deployed portlets. The filter alternates actual monitoring mechanism in WebUI Framework.
Portlet Mode and Window State: The global portlet.xml
file is considered as an alternative place to declare custom Portlet Modes and Window States.