Comparison of JSR-286 support in

cheeseflapdragonInternet and Web Development

Dec 7, 2013 (3 years and 6 months ago)

70 views

MASARYKOVA UNIVERZITA
FACULTY OF INFORMATICS
Comparison of JSR-286 support in

current portal implementations
BACHELOR THESIS
Tomáš Trčka
Brno, spring 2012
Declaration
Hereby I declare, that this paper is my original authorial work, which I have

worked out by my own. All sources, references and literature used or excerpted

during elaboration of this work are properly cited and listed in complete reference

to the due source.
Tomáš Trčka
Advisor:
Marek Grác
ii
Acknowledgment
I would like to thank my advisors Michal Vančo and Marek Grác. I would also
like to thank my mother for supporting me in my studies.
iii
Abstract
This bachelor's thesis has two main goals. First, to acquaint reader with new
features of Portlet API 2.0 defined by JSR-286 standard. Second, to provide
overview of current open source portal implementations and their JSR-286
support.
It also contains demonstration portlets, which are used to showcase new
API features and to verify how are these features supported by selected portals.
iv
Keywords
Java, portlet, portal, portlet container, JSR-286, Java portlet specification 2.0,
Liferay, eXo, GateIn, OpenPortal, Jetspeed
v
Contents
Contents
....................................................................................................................
1
1. Introduction
..........................................................................................................
2
2. About portals and portlets
....................................................................................
3
2.1. Portal
.............................................................................................................
3
2.1.1 Portlet container
..........................................................................................
4
2.2. Portlet
...........................................................................................................
4
2.2.1. JSR-186
.................................................................................................
4
3. JSR-286 – new portlet specification
....................................................................
5
3.1. JSR-286
....................................................................................................
5
3.2. Coordination between portlets
......................................................................
5
3.2.1. Events
...................................................................................................
5
3.2.2. Public render parameters
......................................................................
6
3.3. Portlet filters
.................................................................................................
7
3.4. Resource serving
..........................................................................................
8
3.4.1 AJAX
.....................................................................................................
9
4. Selected portals and their JSR-286 support
.......................................................
10
4.1 GateIn Portal 3.2.0 (Tomcat 7)
....................................................................
11
4.1.1 Running portal
.....................................................................................
11
4.1.2. Portlet deployment
..............................................................................
11
4.2. eXo Platform Community Edition 3.5 (Tomcat 6)
.....................................
12
4.2.1 Running portal
.....................................................................................
12
4.2.2 Portlet deployment
...............................................................................
12
4.3. Liferay Portal 6.1 (Tomcat 7)
.....................................................................
13
4.3.1. Running portal
....................................................................................
13
4.3.2. Portlet deployment
..............................................................................
13
4.4. OpenPortal Portlet Container 2.1.2 (Tomcat 6)
..........................................
14
4.4.1. Running portal
....................................................................................
14
4.4.2. Portlet deployment
..............................................................................
14
4.5. Jetspeed 2.2.2 (Tomcat 6)
...........................................................................
15
4.5.1. Running portal
....................................................................................
15
4.5.2. Portlet deployment
..............................................................................
15
4.6. Deployment of demo portlets
.....................................................................
16
5. Conclusion
..........................................................................................................
17
Bibliography
..........................................................................................................
18
Contents of the attached CD
..................................................................................
19
1
1. Introduction
In present world it is very important to have easy access to up to date data. One of

solutions that allows this is portal. It aggregates data and informations form many

different sources into one page or set of pages. The concept of treating sources

separately and combining their output into one place allows them to be updated

independently. This results into accessible, up to date informations that aren't

limited by scope of single person or organization.
Special types of these portals era enterprise portals. They are mainly used

in commercial environment, to help people do their jobs more effectively. Typical

enterprise portal gathers tasks and informations from different people and sources

and presents them to user in compact, easy to use form. By doing that portal saves

user from sorting all inputs him/herself. This way portal solution, if properly used,

manages to save both time and expenses.
In this thesis, I focus on current portal implementations and their relation

to latest Java Portlet portlet specification – JSR-286. The main goals are to

provide introduction into new feature of th specification. Overview number of

portal implementations and assess their support of the Portlet Specification 2.0.
The thesis consists of three chapters. First one explains terms like portal,

portlet, portlet container and their mutual relationship. Second chapter is about

JSR-286 specification and its new features. It also contains fragments of source

code with their explanations. This should help people that are interested in starting

using these new features in their own applications. Third chapter focuses on

current portal implementations and deployment of demo portlet. It contains list of

portal vendors, selected open source portals with details and table of results of

demo portlets deployment.
2
2. About portals and portlets
2.1. Portal
Portal is a web based application with main purpose of aggregating content from

different sources and hosts. It usually provides authentication and possibility to

customize content, looks and behavior of pages. Web portals can be both public

and private. They can exist within an organization, accessible only to people who

are a part of the organization like employees, suppliers etc. These portals are

called Intranet Portals. Portals like Yahoo, iGoogle, MSN that are open to all, are

called Internet Portals.
Enterprise portal is a prepackaged software product used organizations for

aggregating information and processes. It has web user interface consisting of

pages. Each page is composed of portlets which are standalone applications. Such

interface is called componentized user interface (UI). In Service oriented

architecture (SOA) creating monolithic application is unassailable as such

application is not flexible and is usually difficult to maintain. Monolithic web UI

based on servlets therefore replaced by portlet based portal pages.
Portal page consists of number of portlet windows with portal fragments –

content. Depending on portal implementation each portlet window can have

decorations and controls, these are unified for consistent look and feel.
3
Portal page
[6]
.
2.1.1 Portlet container
The
portlet container
is the runtime environment for portlets, in which portlets are

instantiated, used, and finally destroyed – it manages their life cycle. Portlets are

deployed in portlet container and container is deployed on portal server.
2.2. Portlet
A portlet is an application that provides a specific piece of content (information or

service) to be included as part of a portal page. It is managed by a portlet

container, that processes requests and generates dynamic content. Portlets are used

by portals as pluggable user interface components that provide a presentation

layer to information systems. The content generated by a portlet is also called a

fragment. A fragment is a piece of markup (e.g. HTML, XHTML, WML) that can

be aggregated with other fragments to form a complete document. The content of

a portlet is normally aggregated with the content of other portlets to form the

portal page. Normally, users interact with content produced by portlets, for

example by following links or submitting forms, resulting in portlet actions being

received by the portal, which are forwarded by it to the portlets targeted by the

user's interactions. The content generated by a portlet may vary from one user to

another depending on the user configuration for the portlet.
2.2.1. JSR-186
Java Portlet Specification v.1.0 was developed by Java Community Process (JCP).

First version was released in 2003 with support of mayor software companies as
IBM or Sun Microsystems. It introduced three portlet modes, Model-View-
Controller styled action processing and rendering, portlet data model with render
parameters etc.
4
Portal architecture
[1]
.
3. JSR-286 – new portlet specification
3.1. JSR-286
JSR-286 is the Java Portlet specification 2.0 and was developed under JCP to

improve the original JSR-186 specification. Its mayor new features are:

Events and public render parameters for interportlet coordination.

Portlet filters similar to already existing servlet filter.

Direct serving of dynamically created resources through portlet.
3.2. Coordination between portlets
In JSR-186 the only mechanism providing coordination between portlets was

using session in the application scope. This meant that data could only be shared

by portlets in the same web application. To address this limitation, new version of

the portlet API introduce another two mechanisms. Public render parameters used

for sharing render states between portlets and events
that are similar to events as

we know them from other applications such as user interfaces etc.
3.2.1. Events
Portlet events
[1]
are intended to allow portlets to react to actions or state changes

not directly related to an interaction of the user with the portlet. Events could be

either portal or portlet container generated or the result of a user interaction with

other portlets. The portlet event model is a loosely coupled, brokered model that

allows creating portlets as stand-alone portlets that can be wired together with

other portlets at runtime. This means that portlets don't need to be part of a single

web application, but can communicate independently.
In order to process and publish events, portlet must implement

javax.portlet.EventPortlet
interface which is usually done by implementing

javax.portlet.GenericPortlet
interface. Event can be set by
setEvent
method

during action processing part of portlet life-cycle. . The event must always have a

name and optionally have a value.
public void processAction(ActionRequest request, …

QName qname = new QName("qName", "eventName");
response.setEvent(qname, eventZone);

The portlet can access the event that triggered the current process event

call by using the
EventRequest.getEvent
method. This method returns an object of

5
type
Event
encapsulating the current event name and value.
public void processEvent(EventRequest request, …
Event event = request.getEvent();
if(event.getName().equals("NewZoneEvent")) {

}
Each event should be declared in portlet.xml deployment descriptor so that

portal is able to distribute the event to other portlets . Portlets that produce events

contain <supported-publishing-event> element and consuming portlets

<supported-processing-event>.
<portlet>
...
<supported-processing-event>
<qname xmlns:x="cz.muni.fi...">x:consumedEvent</qname>
</supported-processing-event>
<supported-publishing-event>
<qname xmlns:x="cz.muni.fi...">x:publichedEvent</qname>
</supported-publishing-event>
</portlet>
...
<event-definition>
<qname xmlns:x="cz.muni.fi...">x:newEvent</qname>
<value-type>java.lang.String</value-type>
<event-definition>
3.2.2. Public render parameters
In JSR-186 render parameters were only available in render phase of the same

portlet. Public render parameters
[1]
are intended for sharing view state across

portlets. Using public render parameters instead of events avoids the additional

process event call and enables the end-user using the browser navigation and

bookmarking if the portal stores the render parameters in the URL.
Public render parameter is set, as ordinary render parameter, by

setRenderParameter
method.
public void processAction(ActionRequest request, …
...
response.setRenderParameter("name", value);
}
Each public render parameter has to be declared in portlet.xml deployment

6
descriptor. Once as
<public-render-parameter>
element containing its identifier

and
qName
. And once in each portlet it is shared by as
<supported-public-render-
parameter>
element with its identifier.
<portlet>
...
<supported-public-render-parameter>
PublicRenderParameterIdentifier
</supported-public-render-parameter>
</portlet>
<public-render-parameter>
<identifier>newZonePRP</identifier>
<qname xmlns:x="cz.muni.fi...">x:NewZonePRP</qname>
</public-render-parameter>
3.3. Portlet filters
Filter
[1]
is a reusable piece of code used to modify portlet request and response

before or after any life-cycle method of portlet. Portlet filters are modeled after

the servlet filters. The difference between portlet and servlet filters is, that servlet

has only one request handling method. Portlet has four request handling method

and therefore four types of filters, one for each method.
javax.portlet.filter.
RenderFilter
for
render
method
javax.portlet.filter.
ActionFilter
for
processAction
method
j
avax.portlet.filter.
EventFilter
for
processEvent
method
javax.portlet.filter.ResourceFilter
for
serveResource
method
After deployment of the portlet application, and before a request causes the

portlet container to access a portlet, the portlet container must locate the list of

portlet filters that must be applied to the portlet. The filter is declared in

portlet.xml deployment descriptor using
<filter>
element and mapped to desired

portlet by
<filter-mapping>
element.
<filter>
<filter-name>PortletFilterExample</filter-name>
<filter-class>cz.muni.fi...PortletFilterExample</filter-class>
<lifecycle>RENDER_PHASE</lifecycle>
<lifecycle>ACTION_PHASE</lifecycle>
7
<lifecycle>EVENT_PHASE</lifecycle>
<lifecycle>RESOURCE_PHASE</lifecycle>
</filter>
<filter-mapping>
<filter-name>PortletFilterExample</filter-name>
<portlet-name>PortletExample</portlet-name>
</filter-mapping>
Each portlet filter implements common interface
javax.portlet.filter.PortletFilter
which contains
init
and
destroy
methods.
public class PortletFilterExample implements RenderFilter {
public void init(FilterConfig filterConfig) throws
PortletException{
this.filterConfig = filterConfig;
...
}
public void destroy() {}
Every type of filter has also its own
doFilter
method which takes request
and response parameters according to its type.
public void doFilter(RenderRequest renderRequest,
RenderResponse...{
...
filterChain.doFilter(renderRequest, renderResponse);
}
}
3.4. Resource serving
In JSR-286 resource serving was introduced. It allows portlet to dynamically

serve content. This is done by new type of URL –
ResourceURL
which call

serveResource
method of portlet. Through this method dynamic or static content

is served. Example below shows how image can be served through
serveResource

method.
public void serveResource(ResourceRequest request, ...
response.setContentType("image/png");
File file =
new File(this.getPortletContext().getRealPath("/image"));
BufferedImage image = ImageIO.read(file);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
8
ImageIO.write(image, "png", baos);
byte[] b = baos.toByteArray();
response.getPortletOutputStream().write(b);
}
3.4.1 AJAX
Thanks to resource serving,
AJAX
or
Asynchronous JavaScript and XML can now

be used for asynchronous call to portlets by invoking the
resourceURL
through
XMLHttpRequest
in client-side JavaScript code.
9
4. Selected portals and their JSR-286 support
From all available portal implementations five portals were selected for further

testing. The requirements were they had to be open source, non commercial and

JSR-286 compliant. Table below contains list of portal vendors, their portal

solutions with latest versions a licenses.
Vendor
Product Name
Version
License
Portlet API
Apache Software

Foundation
Jetspeed 2
2.2.2
Apache License

v2.0
JSR-286
Bluenog
Bluenog ICE
4.5
Proprietary
JSR-186
Broadvision
Broadvision

Portal
8.2AB
Proprietary
JSR-186
eXo
eXo Platform
3.5
Proprietary
JSR-286
eXo Platform CE
LGPL
JBoss + eXo
GateIn Portal
3.2.0
LGPL
JSR-286
Hippo
Hippo CMS
7.7
Open Source and

Proprietary Licenses
JSR-286
IBM
WebSphere

Portal
8
Proprietary
JSR-286,

WSRP
JBoss
JBoss Enterprise

Portal Platform
5.2
Proprietary
JSR-286,

WSRP
Liferay
Liferay Portal EE
6.1
Proprietary
JSR-286
Liferay Portal CE
LGPL
Oracle/community
OpenPortal
2.1.2
CDDL
JSR-286
Oracle
Oracle

WebCenter Suite
11g R1
Proprietary
JSR-286,

WSRP
Oracle
Oracle WebLogic

Portal
10g
Proprietary
JSR-286
Oracle
Oracle

WebCenter

Interaction
10g R4
Proprietary
JSR-186
Oracle
Oracle IAS Portal

11g
Proprietary
JSR-186
SAP AG
SAP NetWeaver
7.0
Proprietary
JSR-186
Jasig
uPortal
4.0.5
Apache License

v2.0
JSR-286
Table of Java based enterprise portals
[10]
.
10
4.1 GateIn Portal 3.2.0 (Tomcat 7)
GateIn
[5]
is a set of projects revolving around the main project called GateIn

Portal.
GateIn portal is a merge of two mature projects, JBoss Portal and eXo

Portal.
JBoss as specialist in middle-ware was able to deliver a scalable portal

with enterprise integration
. eXo then produced a full fledge solution on top of this

portal. The aim is to provide best of eXo's user interface and stability of JBoss

Portal.
4.1.1 Running portal
1.
Go to
./bin
folder.
2.
Depending on operating system run
gatein.sh
for Unix-like system, or
gatein.bat
for Windows.
3.
Default portal URL is
http://localhost:8080/portal/
.
4.1.2. Portlet deployment
1.
Place compiled portlets in .war archive into
./webapps
folder.
2.
In web interface, logged in as root or administrator, go to
Group
>
Administration
>
Application Registry
.
3.
Hit
Import Applications
button, all new .war archives in
./webapps
folder
are then automatically deployed
11
Web interface of GateIn Portal 3.2.0.
4.2. eXo Platform Community Edition 3.5 (Tomcat 6)
The eXo Platform
[6]
project started in 2003 as an implementation of the first

portlet API. It now offers a collection of services that speed the creation of portal-
based sites, including content management, collaboration, social networks,

activity streams or mobile access. eXo Platform is JSR-286 compliant enterprise

portal, built on the same basics as GateIn Portal.
4.2.1 Running portal
1.
In eXo Platform root folder run
start_eXo.sh
for UNIX-like system or
start_eXo.bat
for Windows.
2.
Default portal URL is
http://localhost:8080/portal/
.
4.2.2 Portlet deployment
1.
Place compiled portlets in .war archive into
./webapps
folder.
2.
In web interface, logged in as root or administrator, go to
Group
>
Administration
>
Application Registry
.
3.
Hit
Import Applications
button, all new .war archives in
./webapps
folder
are then automatically deployed
In tested version 3.5 CE I was unable to log in. Problem was caused by missing
configuration file.
12
Web interface of eXo Platform 3.5.
4.3. Liferay Portal 6.1 (Tomcat 7)
Liferay
[8]
is open source Java-based enterprise portal available under LGPL

license. It has also commercial variant with extended support. Project stated in

2000 as portal solution for non-profit organization and developed into one of the

most successful portal platforms.
4.3.1. Running portal
1.
Go to
./tomcat-7.0.23/bin
folder.
2.
Start Tomcat server by running
startup.sh
for UNIX-like systems or
startup.bat
for Windows.
3.
Default portal URL is
http://localhost:8080/portal/
.
4.3.2. Portlet deployment
1.
Place compiled portlets in .war archive into
./deploy
folder.
2.
All archives are automatically deployed.
13
Web interface of Liferay Portal 6.1.
4.4. OpenPortal Portlet Container 2.1.2 (Tomcat 6)
Portlet Container is part of OpenPortal
[4]
project. It is a fully compliant

implementation of JSR-286 specification since version 2.0.0. Project aims to

deliver an enterprise-class portlet container implementation build by community.
4.4.1. Running portal
1.
Go to
./bin
folder.
2.
Start Tomcat server by running
startup.sh
for UNIX-like systems or
startup.bat
for Windows.
3.
Default portal URL is
http://localhost:8080/portletdriver/
.
4.4.2. Portlet deployment
1.
Place compiled portlets in .war archive into
./webapps
folder.
2.
In web interface, go to
Admin
tab, select your .war archive and hit deploy.
14
Web interface of OpenPortal Portlet Container 2.1.2.
4.5. Jetspeed 2.2.2 (Tomcat 6)
Jetspeed
[7]
is an open portal platform and enterprise information portal, written

entirely in open source under the Apache license in Java and XML and based on

open standards. Jetspeed has been fully JSR-286 compliant since release 2.2.0 in

May 2009.
4.5.1. Running portal
1.
Go to
./bin
folder.
2.
Start Tomcat server by running
startup.sh
for UNIX-like systems or
startup.bat
for Windows.
3.
Default portal URL is
http://localhost:8080/jetspeed/ui/
.
4.5.2. Portlet deployment
1.
Go to
./webapps/jetspeed/WEB-INF/deploy
.
2.
All .war archives in this folder will be automatically deployed.
15
Web interface of Jetspeed 2.2.2.
4.6. Deployment of demo portlets
For evaluation of JSR-286 support three demo portlets were used, each one

implementing a key new feature of the specification. First one test interportlet

communication by use of events and public render parameters. These principles

are demonstrated on setting time zone on clock portlet from another portlet

window. Second portlet features portlet filters, which are used for counting

invocations of each of four portlet's request handling methods. Last portlet utilizes

AJAX for asynchronous page updates. This portlet
[3]
was adopted from JSR-286

examples site
[2]
just to evaluate AJAX and resource serving support.
Each demo portlet was deployed on every portal implementation and

results were compiled into following table. The only problem occurred with

GateIn Portal / eXo Platform and Interportlet Communication Demo. When event

was published whole page was rendered, instead of just affected portlets.
GateIn

Portal
eXo Platform

CE
Liferay

Portal
OpenPortal
Jetspeed 2
JSR-286

compliant
Yes
Yes
Since 5.0
Since 2.0
Since 2.2.0
Interportlet

communication
OK*
OK*
OK
OK
OK
Portlet filters
OK
OK
OK
OK
OK
Resource serving-
AJAX
[3]
OK
OK
OK
OK
OK
Table of selected portals and results of demo portlets deployment.
16
5. Conclusion
It seems that 4 years since 2008 when final version of Java Portlet Specification

v.2.0 was released was long enough time for portal vendors to adopt the new

specification. All tested portal implementation managed to deploy demo portlets

without problems.
In future this thesis could be transformed to beginner's guide of sort.

Containing basic information about portal solutions, portlet deployment and

support.
17
Bibliography
[1]
Stefan Hepper, JSR-286 Portlet Specification 2.0 (Final Release), 25th January

2008, [on-line],
Available at:
http://jcp.org/aboutJava/communityprocess/final/jsr286/index.html
[2]
Deepak Gothe, Understanding the Java Portlet Specification 2.0 (JSR 286),
January 2010, [on-line],
Available at:
http://portlet-container.java.net/docs/jsr286.html
[3]
Resource Serving Sample – software [on-line], January 2010,
Available at:
http://portlet-container.java.net/public/Samples.html
[4]
OpenPortal - Portlet Container Project [on-line], 2012,
Available at:
http://portlet-container.java.net
[5]
GateIn Portal [on-line], 2012,
Available at:


http://www.jboss.org/gatein

[6]
eXo Platform Community Edition [on-line],
Available at:
http://community.exoplatform.com/portal/classic/hom
e
[7]
Jetspeed 2 [on-line], [cited on 21st May 2012],
Available at:
http://portals.apache.org/jetspeed-2/
[8]
Liferay Portal [on-line], [cited on 21st May 2012],
Available at:
http://www.liferay.com/products/liferay-portal/overview
[9] Dave Minter & Jeff Linwood, Building Portals with the Java Portlet API,
Apress, 2004, 393 pages, ISBN 1-59059-284-0
[10]
List of enterprise portal vendors [on-line], [cited on 21st May 2012],
Available at:
http://en.wikipedia.org/wiki/List_of_enterprise_portal_vendors
18
Contents of the attached CD
CD contains demonstration portlets in
JSR-286 Demo Portlets
folder, portal

implementations used in this thesis in
Portals
folder and finally two *.pdf files

with JSR-286 specification located in
JSR-286 Portlet Specification v2.0
folder.
19