Portlet, WSRP and Application Xiao Dong Wang, Rob Allan Daresbury Laboratory

advertisement
Portlet, WSRP and Application
Xiao Dong Wang, Rob Allan
Daresbury Laboratory
x.d.wang@dl.ac.uk, r.j.allan@dl.ac.uk
GridSphere and Portlet Workshop, NESC, 3-4 March 2005
Table of Content
1. Portal
2. Portlet --- JSR 168
3. Web Services for Remote Portlets --- WSRP
4. Application
Presenter
XD WangName
e-Science
Centre
Facility
Name
Portal
Application Framework
Presenter
XD WangName
e-Science
Centre
Facility
Name
Why Portal ?
•
•
What is Web Portal ?
– A portal is a Web-based application that acts as a gateway between users and a range
of services.
• Personalization:
– Provide customized content to users
• Single sign-on:
– Integrate with other applications to allow access to multiple systems with a
single sign-on
• Aggregation:
– Integrate content from different sources with a webpage
• Customization:
– Done by a portal based on what it knows about user.
Why a web portal ?
– Different roles
• require different information. Someone from grounds and buildings needs different
info than the chair of computer science. (Customization)
– Different people
• with the same role work differently. (Personalization)
– Efficiency
• people get directly to the info they need. (Work Flow) Customization insures they
don't miss anything.
– Link Integrity
Presenter
XD WangName
• Software insures that links work or go away.
e-Science
Centre
Facility
Name
Portal Server Implementation
• Difference Between Application Server and Portal Server
– Application server
• a system that provides the execution environment that is at the
core of network computing or web-based architectures, providing
a full set of services.
– Portal server
• an application server running a portal software or a portal
application
• Open sources
– GridSphere, Pluto, uPortal, Jetspeed, jPorta, Cocoon, oPortal, CHEF,
Sakai, Liferay, eXo, Redhat Portal Server, Gluecode Portal
Foundation Server, Lutece
Presenter
XD WangName
e-Science
Centre
Facility
Name
Portlet
Portal Component
Presenter
XD WangName
e-Science
Centre
Facility
Name
Portlet
• What is portlet ?
– A portlet is a Java technology based web component, 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.
• What is JSR ?
– Java Specification Request ( JSR ) is a way to standardize certain
java related technologies.
• What is JSR 168 ?
– "The Java Specification Request 168 Portlet Specification (JSR 168)
standardizes how components for portal servers are to be developed.
Presenter
XD WangName
e-Science
Centre
Facility
Name
What Does JSR 168 Define?
• Portlet API
– Portlet Requests
– Preferences
– User information
– Security
– Deployment packaging
• Portlet Container
– Extension of servlet container
• Contract between component and container
Presenter
XD WangName
e-Science
Centre
Facility
Name
Portlet/Portal Architecture
Presenter
XD WangName
e-Science
Centre
Facility
Name
Portlet Modes & Windows
•
JSR168 defines three modes:
– View
• Generate markup visualizing the portlet state and properties.
• Mandatory.
– Edit
• Produce markup to enable modification of portlet properties.
• Optional.
– Help
• Provide help text for the portlet.
• Optional.
•
JSR168 provides three window states
– Normal
• Share the screen with other portlets.
– Minized
• Provide little or no output.
– Maximized
• Doesn’t share the screen with other portlets.
Presenter
XD WangName
e-Science
Centre
Facility
Name
Portlet Life Cycle
Initialized by Container
init()
Notifies initialization of
portlet by container
Render()
Handle Requests
Notifies the portlet
to generate the
markup fragment
processAction()
Notifies the portlet
about user’s request
for action
Destroy by Container
Destroy()
Notifies the destruction
of portlet by container.
Should free up
resources in this method
Presenter
XD WangName
e-Science
Centre
Facility
Name
Portlet Features
•
•
•
•
•
•
•
•
•
Portlet persistence
User profile attribute
Portal context
Security
Session management
Portlet request dispatcher
Localization
Caching
Portlet URL
Presenter
XD WangName
e-Science
Centre
Facility
Name
Portlet Persistence
• PortletPreference
– Simply data stored
– Read-write in processAction
– Read-only in render
– Modified in Edit mode
• How to deploy
– Portlet.xml
• preferencesValidator
– Web.xml
<portlet-preferences>
<preference>
<name>displaysize</name>
<value>33</value>
<read-only>true</read-only>
</preference>
</portlet-preferences>
<portlet-preferences>
<preferences-validator>
com.sss.PortletValidator
</preferences-validator>
</portlet-preferences>
Presenter
XD WangName
e-Science
Centre
Facility
Name
Portlet session management
• Application scope
– PortletSession.APPLICATION_SCOPE
• Visiable all portlets in portlet application
• Portlet scope
– PortletSession.PORTLET_SCOPE
• Visiable in local portlet
• Both are visited in httpSession
Presenter
XD WangName
e-Science
Centre
Facility
Name
Portlet localization
• Localized by using resource bundles
– Supported by I18n
– Specified in portlet.xml
<portlet>
……………….
<support-locale>en</support-locale>
<support-locale>fr</support-locale>
<resource-bundle>uk.dl.esc.portletLocale</resourcebundle>
………………..
</portlet>
Presenter
XD WangName
e-Science
Centre
Facility
Name
Portlet tag library
• defineObjects
– org.apache.pluto.tags.DefineObjectsTag
• renderResponse, renderRequest, actionRequest, ……
• actionURL
– PortletURL url = renderResponse.createActionURL();
– Suitable for real action
• renderURL
– PortletURL url = renderResponse.createRenderURL();
– Suitable for transformation in portlet
• Namespace
– Specific for each portlet
• Param
Presenter
XD WangName
e-Science
Centre
Facility
Name
Portlet caching
• Portlet expiration based on caching
• Declarative caching in portlet.xml
<portlet>
………………
<expiration-cache>500</expiration-cache>
………………
</portlet>
• Programmatic caching
– Modify EXPIRATION_CACHE property of render response
– renderResponse.setProperty( key, value );
Presenter
XD WangName
e-Science
Centre
Facility
Name
Portlet request and response
•
•
•
Portlet request
– Actionrequest
– Renderrequest
Invoke by
– actionURL
– renderURL
Portlet response
– Actionresponse
• Redirect
• Modify windows state and portlet mode
– Renderresponse
• Set ContentType
• Buffering
• Set portlet title
• Output page
Presenter
XD WangName
e-Science
Centre
Facility
Name
Portlet Deployment
• Portlet application
– A collection of one or more portlets
– portlet.xml
– web.xml
– Package in a war file with the same
structure as a web application
• Registring with Portal Server/Container
and integrating into page layout is nonstandard.
Presenter Name
• Portlet container is non-standard Facility
Name
XD Wang
e-Science Centre
Portlet Application
Presenter
XD WangName
e-Science
Centre
Facility
Name
Portlet Application
• Scenario
– Portlet --- GT3 Index Service portlet,
OGSA-DAI interface mechanism portlet,
Grid Portlets Package GT2 based
– Portlet mode --- edit, help and view
– Portal Framework --- uPortal
– Portlet container --- pluto integrated in
uPortal
Presenter
XD WangName
e-Science
Centre
Facility
Name
GT3 Index Service Portlet Architecture
Node 1
UDDI
Node 2
Node n
……
GT3 Client
GT3 Index
Service Portlet
Presenter
XD WangName
e-Science
Centre
Facility
Name
GT3 Index Service Portlet --- doView()
Render( )
GenericPortlet
doView( )
UDDI Registry
IndexServicePortlet
IndexServicePortletView
Presenter
XD WangName
e-Science
Centre
Facility
Name
doView( ) --- Index service Portlet
public class IndexServicePortlet extends GenericPortlet {
public void doView( RenderRequest request, RenderResponse response ) throws
PortletException, java.io.IOException
{
response.setContentType( request.getResponseContentType( ) );
PortletSession session = request.getPortletSession( );
IndexServiceResource resource = ( IndexServiceResource )session.getAttribute(
VIEW_RESOURCE );
if( resource == null )
{
// Search UDDI to get Index Service Handles
IndexServiceResource _resource = new IndexServiceResource( );
session.setAttribute( VIEW_RESOURCE, _resource );
}
// Invoke the JSP to render
PortletRequestDispatcher rd = getPortletContext( ).getRequestDispatcher(
"/jsp/uk/dl/esc/ogsa/gt3/IndexServicePortletView.jsp" );
rd.include( request, response );
}
………………………
}
Presenter
XD WangName
e-Science
Centre
Facility
Name
GT3 Index Service Portlet --- doHelp()
Render( )
GenericPortlet
IndexServicePortletView
doHelp( )
IndexServicePortlet
IndexServicePortletHelp
Presenter
XD WangName
e-Science
Centre
Facility
Name
doHelp( ) --- Index Service Portlet
public class IndexServicePortlet extends GenericPortlet
{
public void doHelp( RenderRequest request, RenderResponse
response ) throws PortletException, IOException
{
// Set the MIME type for the render response
response.setContentType( request.getResponseContentType( ) );
// Invoke the JSP to render
PortletRequestDispatcher rd = getPortletContext( ).getRequestDispatcher(
"/jsp/uk/dl/esc/ogsa/gt3/IndexServicePortletHelp.jsp" );
rd.include( request, response );
}
……………………………..
}
Presenter
XD WangName
e-Science
Centre
Facility
Name
GT3 Index Service Portlet --- doEdit()
Render( )
GenericPortlet
IndexServicePortletView
doEdit( )
IndexServicePortlet
IndexServicePortletEdit
Presenter
XD WangName
e-Science
Centre
Facility
Name
doEdit( ) --- Index Service Portlet
public class IndexServicePortlet extends GenericPortlet {
public void doEdit( RenderRequest request, RenderResponse
response ) throws PortletException, java.io.IOException
{
// Set the MIME type for the render response
response.setContentType( request.getResponseContentType( ) );
// Invoke the JSP to render
PortletRequestDispatcher rd =
getPortletContext().getRequestDispatcher(
"/jsp/uk/dl/esc/ogsa/gt3/IndexServicePortletEdit.jsp" );
rd.include( request, response );
}
………………………….
}
Presenter
XD WangName
e-Science
Centre
Facility
Name
GT3 Index Service Portlet --- processAction()
processAction( )
IndexServicePortlet
Presenter
XD WangName
e-Science
Centre
Facility
Name
processAction( ) --- Index Service Portlet
public class IndexServicePortlet extends GenericPortlet {
public void processAction( ActionRequest request, ActionResponse response ) throws PortletException,
java.io.IOException {
// Make a session bean
PortletSession session = request.getPortletSession();
IndexServiceResource resource = ( IndexServiceResource )session.getAttribute( VIEW_RESOURCE );
// Display View
if( request.getPortletMode( ).equals( PortletMode.VIEW ) ) {
PortletSession _session = request.getPortletSession( );
if( request.getParameter( RESEARCH_ACTION ) != null ) {
_session.removeAttribute( INDEXSERVICE_RESEARCH );
}
else {
_session.setAttribute( INDEXSERVICE_RESEARCH, "true" );
}
}
// Transfer index service handle information to portlet session
if( request.getParameter( INDEX_CONTAINER ) != null ) {
PortletSession __session = request.getPortletSession();
String index = request.getParameter( INDEX_CONTAINER );
__session.setAttribute( RESEARCH_INDEX, inmdex );
}
// Go back to View after invoking Edit and Help
if( request.getPortletMode( ).equals( PortletMode.HELP ) || request.getPortletMode( ).equals( PortletMode.EDIT ) ) {
response.setPortletMode( PortletMode.VIEW );
}
}
………………………………
}
Presenter
XD WangName
e-Science
Centre
Facility
Name
portlet.xml --- Index Service Portlet
<?xml version="1.0" encoding="UTF-8"?>
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" version="1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd
http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
<portlet>
<description>IndexService portlet</description>
<description xml:lang="en">IndexService portlet</description>
<portlet-name>IndexServicePortlet</portlet-name>
<display-name>IndexService portlet</display-name>
<display-name xml:lang="en">IndexService portlet</display-name>
<portlet-class>uk.dl.esc.ogsa.gt3.IndexServicePortlet</portlet-class>
<expiration-cache>-1</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
<portlet-mode>edit</portlet-mode>
<portlet-mode>help</portlet-mode>
</supports>
<supported-locale>en</supported-locale>
<portlet-info>
<title>IndexService portlet</title>
</portlet-info>
</portlet>
Presenter
XD WangName
e-Science
Centre
Facility
Name
web.xml --- Index Service Portlet
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/webapp_2_3.dtd">
<web-app>
<display-name>IndexServicePortlet Wrapper</display-name>
<description>Automated generated Portlet Wrapper</description>
<servlet>
<servlet-name>IndexServicePortlet</servlet-name>
<display-name>IndexServicePortlet Wrapper</display-name>
<description>Automated generated Portlet Wrapper</description>
<servlet-class>org.apache.pluto.core.PortletServlet</servlet-class>
<init-param>
<param-name>portlet-class</param-name>
<param-value>uk.dl.esc.ogsa.gt3.IndexServicePortlet</param-value>
</init-param>
<init-param>
<param-name>portlet-guid</param-name>
<param-value>gt3.IndexServicePortlet</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>IndexServicePortlet</servlet-name>
<url-pattern>/IndexServicePortlet/*</url-pattern>
</servlet-mapping>
<taglib>
<taglib-uri>http://java.sun.com/portlet</taglib-uri>
<taglib-location>/WEB-INF/tld/portlet.tld</taglib-location>
</taglib>
</web-app>
Presenter
XD WangName
e-Science
Centre
Facility
Name
OGSA-DAI Portlet
view
processAction
Help
Presenter
XD WangName
e-Science
Centre
Facility
Name
Grid Portlets Package GT2 based
Presenter
XD WangName
e-Science
Centre
Facility
Name
Portlets Package WSRF based
Portlet Session
GUI Interface
CoG Services ?
UDDI
GRAM
Databases
Index Service
OGSA-DAI
GridFTP
Security Mechanism
MyProxy Server
Presenter
XD WangName
e-Science
Centre
Facility
Name
WSRP
Web Services for Remote Portlets
Presenter
XD WangName
e-Science
Centre
Facility
Name
WSRP
• What is WSRP?
– Web Services for Remote Portlets ( WSRP ) defines a web
service standard of how to plug remote web services from
Producer into the pages of online portals and other user-facing
applications on Consumer.
• Does WSRP standard?
– WSRP v1.0 is an OASIS standard.
• What is WSRP Producer?
– Hosts portlets and provides such services as self-description,
mark up, registration and portlet management.
• What is WSRP Consumer?
– An intermediary system that communicates with presentationoriented web services on behalf of its users.
Presenter
XD WangName
e-Science
Centre
Facility
Name
WSRP Benefits
• Decouples the deployment and delivery of
applications
• Delivers both data and data’s presentation
logic
• Needs little or no programming
• Interoperability
• Portability
• Support by large players in the industry
Presenter
XD WangName
e-Science
Centre
Facility
Name
How WSRP Works
End User
Consumer
Producer
Registry
2. Consumer visits Registry
and discovers Producer
1. Publish itself to Registry
3. Consumer discovers Producer and connects it.
4. Consumer and Producer relationship is established
5. Consumer learns all capabilities of Producer
6. Consumer creates a proxy portlet
7. End-User accesses Consumer
8. Consumer aggregates pages,
often with portlets, for users
9. End-User sends a page
request to Consumer
11. Consumer aggregates the
portlet markup in a page and
sends it to the end-user’s
browser
10. Producer responds with portlet markup and/or some portlet
state
Presenter
XD WangName
e-Science
Centre
Facility
Name
WSRP Interfaces and Operations
• Service Description Interface
– offered by all producers
• Markup Interface
– offered by all producers
• Registration Interface
• Portlet Management Interface
Presenter
XD WangName
e-Science
Centre
Facility
Name
WSRP Interfaces and Operations
• Service Description Interface
– Aim
• Provide description and portlets list of Producer
to Consumer
– API
• getServiceDescription
• getServiceDescriptionResponse
– Supported Locales
– Offered Portlets
– Supported MIME types
– Modes and window states supported
– Description
getServiceDescription
Consumer
Producer
getServiceDescriptionResponse
Presenter
XD WangName
e-Science
Centre
Facility
Name
WSRP Interfaces and Operations
•
Markup Interface
– Aim
• Producer sends out markup of portlets to consumer to generate page; consumer sends
out interaction requests to producer and then receive markup reflection.
– API
• getMarkup
– RegistrationContext
» registrationHandle
– PortletContext
» portletHandle
– RuntimeContext
» userAuthetication
– UserContext
» userContextKey
– MarkupParams
» secureClientCommunication
» mimeTypes
» markupCharacterSets
• getMarkupResponse
– MarkupContext
» Markup for the portlet, a title, locale and MIME type of the markup
– SessionContext
» sessionIN
» expires
• performBlockingInteraction
Presenter
XD WangName
• initCookie
e-Science
Centre
Facility
Name
• releaseSessions
WSRP Interfaces and Operations
• Markup Interface
– performBlockingInteraction
Presenter
XD WangName
e-Science
Centre
Facility
Name
WSRP Interfaces and Operations
• Registration Interface
– Aim
• Provide a means within
the WSRP protocol for
a Consumer to register
with a Producer
– API
• Register
– registrationContext
• modifyRegistration
– registrationHandle
– registrationState
• deregister
Presenter
XD WangName
e-Science
Centre
Facility
Name
WSRP Interfaces and Operations
• Portlet Management Interface
– Aim
• Let Consumers manage the persistent state
and lifecycle of portlets explicitly
– API
• getPortletDescription
• getPortletPropertyDescription
• getPortletProperties
• clonePortlet
• setPortletProperties
Presenter Name
• destroyPortlets
XD Wang
e-Science
Centre
Facility
Name
WSRP Interfaces and Operations
• Portlet Lifecycle
Presenter
XD WangName
e-Science
Centre
Facility
Name
WSRP Interfaces and Operations
• Cloning and Setting Portlet Properties
Presenter
XD WangName
e-Science
Centre
Facility
Name
WSRP Interfaces and Operations
• Cloning and Destroy for Managing Portlet
Customizations
Presenter
XD WangName
e-Science
Centre
Facility
Name
Companies and Projects to support WSRP
• Projects to support WSRP
– WSRP4J, eXo, uPortal
• Companies to support WSRP
– BEA, Fujitsu, Gluecode, IBM, Intrafinity,
Liferay, Microsoft, NetUnity, Oracle,
Plumtree, Sun, webMethods, Vignette
Presenter
XD WangName
e-Science
Centre
Facility
Name
WSRP Example
Presenter
XD WangName
e-Science
Centre
Facility
Name
WSRP Example
• Scenario
– Portlet
• HelloWorld ( JSR 168 )
– WSRP Comsumer
• uPortal
– WSRP Producer
• WSRP4J
Presenter
XD WangName
e-Science
Centre
Facility
Name
WSRP4J Producer Architecture
Presenter
XD WangName
e-Science
Centre
Facility
Name
WSRP Example Application
• Application Architecture
WebServer
ServerAA
Web
(Tomcat)
(Tomcat)
WebServer
ServerBB
Web
(Tomcat)
(Tomcat)
uPortal
uPortal
(PortletChannel)
Channel)
(Portlet
uPortal
uPortal
(WSRPConsumer
ConsumerChannel)
Channel)
(WSRP
WSDL, SOAP
JSPPortlet
Portlet
JSP
WSRP4J
WSRP4J
Producer) )
( (Producer
Presenter
XD WangName
e-Science
Centre
Facility
Name
WSRP Example Application
Screenshot of Web Server B
Local portlet provided
by HelloWorld Portlet
and displayed on
uPortal Portlet
Channel
Presenter
XD WangName
e-Science
Centre
Facility
Name
WSRP Example Application
Screenshot of Web Server A
Remote portlet
provided by WSRP4J
Producer and displayed
on uPortal Consumer
Channel
Presenter
XD WangName
e-Science
Centre
Facility
Name
Download