Create a context processor class
When configured, a context processor plug-in is invoked by the web content viewer portlet before rendering and allows the current context, such as the item to display, to be modified.To create a context processor plug-in, create a context processor class and then register the context processor class by deploying it on the server and selecting it from within a Web content viewer portlet.
- Create a Java class that implements the interface com.ibm.workplace.wcm.api.ContextProcessor. This class must implement the following method:
/** * Processes the supplied <i>ContextProcessorParams</i> and updates parameters within * as necessary * * @param p_currentSession The current Http Session * @param p_contextProcessorParams The editable <i>ContextProcessorParams</i> object */ public void process(HttpSession p_currentSession, ContextProcessorParams p_contextProcessorParams);See the Javadoc for further information.
- Implement the process method. This method contains the code that is executed when the plug-in is invoked and allows us to modify the current context using the ContextProcessorParams object before the current context is rendered.
- A plugin.xml file is needed whether the deployment is done using a WAR or EAR, or using a loose jar. If deployed using an application in a WAR or EAR, include the plugin.xml file in the application "WEB-INF" folder. When using a jar, include the plugin.xml in the root of the jar.
<?xml version="1.0" encoding="UTF-8"?> <plugin id="SampleContextProcessorPluginId" name="SampleContextProcessor" provider-name="IBM" version="1.0.0"> <extension point="com.ibm.workplace.wcm.api.ContextProcessor" id="SampleContextProcessorPlugin" > <processor class="com.acme.SampleContextProcessor"/> </extension> </plugin>
- Edit the settings of the web content viewer portlet to associate with the context processor:
- Go to the "configuration" or "edit shared settings" view of a web content viewer portlet.
- Go to Advanced Options > Plugins
- Select a context processor plug-in.
- Each plug-in is represented by a single <extension></extension> tag.
- The value of the point attribute must be "com.ibm.workplace.wcm.api.ContextProcessor".
- Provide an ID value of the choice.
- Specify the provider class for the plug-in.
Naming conventions:
If you create a plug-in application with the same names and IDs as an existing plug-in, the new plug-in may override the first. When creating plug-in applications ensure that the following are unique across the system:
- The plug-in ID, plug-in name, and extension ID of the plugin.xml file.
- The fully qualified class name plus path of all classes within the application.
- The file path of any files within the application.
Parent: Create custom plug-ins