Skip to main content

Embedding Portlet Container and WSRP Consumer


This page documents the steps required by the Client in order to embed the OpenPortal Portlet Container and OpenPortal WSRP Consumer.

Download the javadocs for the Container API.

The figure shows the relation between the client(i.e Portal Server, Portlet Driver, WSRP Producer), Container API and Portlet Container and WSRP Consumer


Container API


Steps required by the client inorder to use the OpenPortal Portlet Container 2.0 and WSRP Consumer 2.0

Step 1: Optionally implement the services

  • CoordinationService – Handles eventing and public render parameters
  • CachingService - Responsible for managing the cache contents for the portlets(server caching)
  • ClientCachingService - Responsible for managing the cache content of portlet resource(ETag/browser caching)
  • PolicyService – Determines how the events are distributed and render parameters set

Step 2: Implement the Client Context(SPI)

  • ChannelURLFactory – Responsible for getting URLs
  • ChannelURL – Responsible for creating the URL directed towards the Portlet Window
  • WindowRequestReader – Responsible for parsing and providing the request parameters set and used by the portlet.
  • PortletWindowContext - Responsible for providing information pertaining to the portal and the portlet registry files like preferences, session, portlet lists and portlet descriptions
  • PortletWindowContextFactory - Responsible for creating PortletWindowContext implementations

Step 3:Populate the container request/response and invoke the Container to get the content/resource and execute action

Render

For rendering the content, the client needs to perform the following..

1. Using ContainerFactory, get the Container. From the Container get the MarkUp request and response and populate it.

Container c = ContainerFactory.getContainer(ContainerType);

// Populate Request
GetMarkupRequest containerRequest =
c.createGetMarkUpRequest(HttpServletRequest request,
EntityID portletEntityId,
ChannelState channelState,
ChannelMode channelMode,
PortletWindowContext portletWindowContext,
ChannelURLFactory channelURLFactory);
/*
Following are the default values for
Title - Title in portlet.xml
AllowableWindowStates - Maximized, Minimized and Normal
AllowablePortletModes - View, Edit and Help
AllowableContentTypes - contains portletWindowContext.getContentType()
Namespace - portletEntityId
WindowID - portletEntityId
PortalInfo - OpenPortal Portlet Container 2.0
The above values can be overridden using the corresponding set methods on the containerRequest.
containerRequest.setTitle(String);
containerRequest.setAllowableWindowStates(List<ChannelState>);
containerRequest.setAllowablePortletModes(List<ChannelMode>);
containerRequest.setAllowableContentTypes(List<String>);
containerRequest.setNamespace(String);
containerRequest.setWindowID(String);
containerRequest.setPortalInfo(String);
*/

// Populate Response
GetMarkupResponse containerResponse =
c.createGetMarkUpResponse(HttpServletResponse response);

2. Using the above populated request, response objects, call the getMarkUp method.

 c.getMarkup(containerRequest, containerResponse);
StringBuffer = containerResponse.getMarkup()
String = containerResponse.getTitle();

Action ( can be either through ActionURL or RenderURL)

For invoking the action(can be either through RenderURL or ActionURL), the client needs to perform the following..

1. Using ContainerFactory, get the Container. From the Container get the action request and response and populate it.

 Container c = ContainerFactory.getContainer(ContainerType);

// Populate Request
ExecuteActionRequest containerRequest =
c.createExecuteActionRequest(HttpServletRequest request,
EntityID portletEntityId,
ChannelState channelState,
ChannelMode channelMode,
PortletWindowContext portletWindowContext,
ChannelURLFactory channelURLFactory,
WindowRequestReader windowRequestReader);

/*
Following are the default values for
Title - Title in portlet.xml
AllowableWindowStates - Maximized, Minimized and Normal
AllowablePortletModes - View, Edit and Help
AllowableContentTypes - contains portletWindowContext.getContentType()
Namespace - portletEntityId
WindowID - portletEntityId
PortalInfo - OpenPortal Portlet Container 2.0
The above values can be overridden using the corresponding set methods on the containerRequest.
containerRequest.setTitle(String);
containerRequest.setAllowableWindowStates(List<ChannelState>);
containerRequest.setAllowablePortletModes(List<ChannelMode>);
containerRequest.setAllowableContentTypes(List<String>);
containerRequest.setNamespace(String);
containerRequest.setWindowID(String);
containerRequest.setPortalInfo(String);
*/

// Populate Response
ExecuteActionRequest containerResponse =
c.createExecuteActionResponse(HttpServletResponse response);

2. Using the above populated request, response objects, calls the executeAction method and indicates whether the action is associated with the RenderURL or ActionURL

 c.executeAction(containerRequest, containerResponse, ChannelURLType); 
containerResponse.getRedirectURL()
containerResponse.getNewChannelMode();
containerResponse.getNewChannelState();

Resource

For getting the resource, the client needs to perform the following..

1. Using ContainerFactory, get the Container. From the Container get the resource request and response and populate it.

 Container c = ContainerFactory.getContainer(ContainerType);

// Populate Request
GetResourceRequest containerRequest =
c.createGetResourceRequest(HttpServletRequest request,
EntityID portletEntityId,
ChannelState channelState,
ChannelMode channelMode,
PortletWindowContext portletWindowContext,
ChannelURLFactory channelURLFactory,
WindowRequestReader windowRequestReader);
/*
Following are the default values for
Title - Title in portlet.xml
AllowableWindowStates - Maximized, Minimized and Normal
AllowablePortletModes - View, Edit and Help
AllowableContentTypes - contains portletWindowContext.getContentType()
Namespace - portletEntityId
WindowID - portletEntityId
PortalInfo - OpenPortal Portlet Container 2.0
The above values can be overridden using the corresponding set methods on the containerRequest.
containerRequest.setTitle(String);
containerRequest.setAllowableWindowStates(List<ChannelState>);
containerRequest.setAllowablePortletModes(List<ChannelMode>);
containerRequest.setAllowableContentTypes(List<String>);
containerRequest.setNamespace(String);
containerRequest.setWindowID(String);
containerRequest.setPortalInfo(String);
*/

// Populate Response
GetResourceResponse containerResponse =
c.createGetResourceResponse(HttpServletResponse response);

2. Using the above populated request, response objects, call the getResources method.

 c.getResources(containerRequest, containerResponse);
StringBuffer = containerResponse.getContentAsBuffer()
byte[] = containerResponse.getContentAsBytes()

Step 4: Configuration changes


Following configuration changes needs to done in order to use the OpenPortal Portlet Container 2.0
  1. Add container.jar and portlet-container.jar to the server classpath
  2. Add servlet context listeners to the web.xml of portal webapplication in order to initialize Services and PortletContainer implementation as follows. If any service is implemented, specify it via context parameters.
	<!-- 
<context-param>
        <param-name>name_of_the_service</param-name>
        <param-value>service_implementation_class</param-value>
</context-param>
-->
<listener>
        <listener-class>com.sun.portal.container.service.ServiceManagerContextListenerImpl</listener-class>
</listener>
<listener>
  <listener-class>com.sun.portal.portletcontainer.impl.PortletContainerContextListenerImpl</listener-class>
</listener>

Step 5: Preparing portlet webapplication

Typically deploying the portlet webapplication includes following three steps.

  1. Preparing the portlet webapplication
  2. Registering the portlet with the portal
  3. Deploying the portlet webpplication in the webcontainer
#1 is specific to the Portlet Container implementation, while #2 and #3 is handled by the Portal.

#1 involves inserting Portlet Container specific artifacts in the portlet webapplication. This includes adding a servlet entry in the web.xml of the portlet webapplication. In OpenPortal Portlet Container 2.0, those artifacts details are hidden from the user who only needs to use PortletWarUpdater class to create Portlet Container specific WAR file in the following way:
        //Create the updated war file in the warFileDestination
        PortletWarUpdater portletWarUpdater = new PortletWarUpdater();
        boolean success = portletWarUpdater.preparePortlet(warFileObject, warFileDestination);

 
 
Close
loading
Please Confirm
Close