How Do You Implement Them? What are Portlets and How Do You Implement Them? Rima Patel Sriganesh Technology Evangelist Sun Microsystems, Inc.
Obectives Introduce Portlet components Provide information on various Portlet standards efforts Provide a basic how-to understanding about implementing Portlet components
Agenda Introduction to Portals and Portlets Portlet Standards JSR 168 Portlet Specification WSRP Web Services for Remote Portals Sample implemenation of a HelloWorld Portlet Resources
Agenda Introduction to Portals and Portlets Portlet Standards JSR 168 Portlet Specification WSRP Web Services for Remote Portals Sample implemenation of a HelloWorld Portlet Resources
Portals Portals are becoming a platform for Integration Aggregation Delivery of applications and content through different channels and devices Portals are common entry point for accessing applications and content
Portal Functions Typical portal functions Authentication and Authorization Personalization Customization Searching User relationship management Registration, Profile management, etc. Single sign-on Etc.
Portal example
Portlets Portals comprises of components called Portlets Alike web components such as Servlets with special properties Each Portlet produces a markup fragment that is combined with markup generated by other portlets, all within a portal page markup Designed to be aggregatable in larger context of a portal page
Portlet Context Managed by host Portal Provides information pertaining to User profile Individual portlet instance data Portlet settings UI related Portlet Window State (Min, Max, etc.) Portlet Modes (View, edit, configuration, help, etc.) Portlet Events (actions)
Portlet example If clicked on Edit, Portlet would generate appropriate EVENT and Perform appropriate ACTION UI related settings * Portlet is currently in View mode * Many such portlet components are invoked in a single request for a Portal page
Positioning of Portlet An important Service Delivery architectural component Other Service Delivery architectural components Java Server Pages (JSPTM) Application Frameworks Iplanet JATO/JSF (JSR 127) Struts, etc.
Agenda Introduction to Portals and Portlets Portlet Standards JSR 168 Portlet Specification WSRP Web Services for Remote Portals Sample implemenation of a HelloWorld Portlet Resources
JSR 168 Portlet Specification Aims towards Enabling interoperability between Portals and Portlets Defining a set of APIs for addressing different areas of Portal computing Aggregation Personalization Presentation Security Based on JavaTM Servlet API
JSR 168 Portlet Invocation Model Portal Page Servlet EJBs Action Local Portlet Connectors Local Portlet J2EE APIs Web Services Local Portlet Servlet API Portlet API Portlet Container Portlet Context Registries, Directories, Security and Content Management Infrastructure
Specification Areas JSR 168 will provide lifecycle and semantics for Portlets Deployment Descriptor Developer APIs Vendor Extension APIs for security, user customization and layout management
States defined JSR 168 defines a minimum set of possible states for a portlet Normal Minimized Maximized
Design Goals JSR 168 will try to achieve following design goals Client agnostic Support for multiple types of clients (multi- device) Simple Portlet API Support for Localization and Internationalization
Design Goals (Contd.) Hot deployment and re-deployment of Portal applications Declarative security (similar to that of Servlet and EJBTM) Architected to support remote execution of Portlets
Support for Portlet Context JSR 168 would provide APIs so that Portlets can perform contextual tasks Accessing user profile information for the current user Participation in portal window and action event model Accessing web client information Sharing information with other Portlets Storing/retrieving per-user/per-instance Portlet data persistently
URL Rewriting Support JSR 168 will support URL Rewriting mechanism so that Links within a Portlet would be able to trigger actions without requiring knowledge of how URLs are structured in a particular web application
Portlet Deployment Portlets would be grouped in a Portal application by bundling them in a single WAR with a Portlet deployment descriptor Portlet API will provide means for sharing data among portlets of the same Portal application
Support for Remote Portlets JSR 168 would allow support for remote Portlet execution Will not address transport protocol for remote execution of Portlets leaving specifics to Portal implementations For e.g. A static Portlet proxy could be used to invoke a remote Portlet OR can rely on WSRP mechanisms for invoking remote Portlets
Goals for consideration JSR 167 Expert Group will decide whether to support specialized Portlet implementations for Syndication (based on RSS) Web Services access Credential mapping service (somewhat akin to SSO)
Schedule and other information Release of 1.0 specification expected in in December, 2002 Proposed package namespace javax.servlet.portlet An extension to J2EETM 1.4 platform
Agenda Introduction to Portals and Portlets Portlet Standards JSR 168 Portlet Specification WSRP Web Services for Remote Portals Sample implemenation of a HelloWorld Portlet Resources
WSRP Aimed towards defining a protocol for Enabling interactive, user-facing web services to be easily plugged into standards compliant portals Making internet a marketplace of visual web services, ready to be integrated into portals Effort began in January 2002 WSRP Specification 1.0 and compliance Test Kit in December 2002
Portal Architecture and WSRP Portal Server Clients Local Portlets HTML WML VoiceXML... HTTP Portlet API Generic Portlet Proxies Other Portals WSRP Remote Portlets WSRP Pubish/Find Web Services (SOAP) UDDI Registry
WSRP Service Lifecycle UDDI Registry WSRP Services Register Bind Find Portal Client Request
WSRP Plug-n-Play
Scope WSRP will define A WSDL interface description for invocation of WSRP services Ways to Publish, Find and Bind WSRP services and their metadata Markup fragment rules for markup emitted by WSRP services Applicable Security mechanisms, Billing mechanisms, etc.
Business Scenarios supported Content/Application Provider providing WSRP Service Portal publishing Portlets as WSRP Services Provision of syndicated Content/Billing/Mobility services via WSRP Multimedia portals Enterprise Application services
Scenario Content/Application provider providing WSRP service Client Portals can aggregate presentation from many WSRP services WSRP Services can be portal context aware User profile from portal Desired locale and markup- type User's device constraints UI WSRP Consumer Portal Mark-up fragment transferred via SOAP WSRP Producer
Scenario Portals publishing Portlets as WSRP Service Multiple clients WSRP Consumer WSRP Producer WSRP Wrapper Server Portal Portlet Portal Portlet Portlet Intermediary Portal Publishing Portal Admin of Publishing portal publishes portlet as WSRP service to a UDDI registry Admin of Intermediary portal finds WSRP service through a UDDI browser and binds to it Clients of Intermediary portal select remote portlets like any local portlet to put on their page
Interaction between Portal and WSRP User WSRP Consumer WSRP Producer Allocate new Instance Adds Portlet Create Portlet Instance I Generate Markup Views Portlet Get Portlet Markup I I S A Action Handling Clicks Portlet Perform Portlet Action A S I I S A Destroy Instance Removes Portlet Destroy Portlet Instance I I
WSRP/WSIA Common Interfaces Share common interfaces for Basic life-cycle operations Basic operations for processing actions and getting markup
WSRP Interfaces Define interfaces for Advanced life-cycle operations Advanced operations for processing actions/getting markup pertaining to User profile information contained in requests Device information contained in requests Locale information contained in requests
WSRP Protocol Defines protocol of interaction between portal and services Caching considerations Contract for handling instances and sessions Order in which to invoke operations
WSRP Publish / Find / Bind / Metadata Defines method used to publish/find services to and from UDDI Defines metadata to be provided when publishing service Name, Titles, Descriptions Supported Markups/Locales Caching hints
WSRP Markup Fragment Rules/Styles Define valid markup fragments for XHTML/HTML WML/cHTML/VoiceXML (Second prirority) Define URL Rewriting
WSRP and Security, Identity, Single Sign-On (SSO) Define how security mechanisms can be employed with WSRP Define how identity is to be provided by consumers to producers Define how SSO via a consumer to multiple producers may be achieved
Agenda Introduction to Portals and Portlets Portlet Standards JSR 168 Portlet Specification WSRP Web Services for Remote Portals Sample implemenation of a HelloWorld Portlet Resources
HelloWorldPortlet Example Sample Implementation uses JetSpeed Import org.apache.jetspeed.portal.portlets.AbstractPortlet; ... public class HelloWorldPortlet extends AbstractPortlet { public ConcreteElement getContent (RunData objRunData) { return (new StringElement ("Hello World!!") } } * ConcreteElement is an Apache ECS (Element Construction Set, an object based markup generator) class * RunData -> Turbine Class. Would be used later. Source: www.bluesunrise.com
HelloWorldPortlet Registration To JetSpeed Portlets Registry <?xml version="1.0" encoding="UTF-8"?> <registry> <portlet-entry name="HelloWorld" hidden="false" type="instance" application="false"> <meta-info> <title>HelloWorld</title> <description> Portlet How To Example 1 – Hello World </description> </meta-info> <classname>HelloWorldPortlet</classname> <media-type ref="html"/> </portlet-entry> </registry> Source: www.bluesunrise.com
Customize portal page to add HelloWorldPortlet Source: www.bluesunrise.com
Personalizing Hello! public class HelloWorldPortlet extends AbstractPortlet { public ConcreteElement getContent (RunData objRunData) { StringBuffer objStringBuffer = new StringBuffer(); objStringBuffer.append("Hello "); String sName = objRunData.getUser(). getFirstName(); objStringBuffer.append (sName + "!"); return (new StringElement (objStringBuffer.toString()); } } Source: www.bluesunrise.com
Soft-coding Personalized Hello! public class NewsPortlet extends AbstractPortlet { public ConcreteElement getContent (RunData objRunData) { ... objStringBuffer.append(getPortletConfig(). getInitParameter ("greeting")); ... } } Configure parameters for this Portlet in Jetspeed Configuration file (jetspeed-config.jcfg) <portlet-entry ....> <classname>HelloWorldPortlet</classname> <parameter name="greeting" value = "Hello, " /> ... </portlet-entry> Source: www.bluesunrise.com
RunData and User RunData object provides access to Servlet Request object Other session context information Security, Turbine Actions, Cookies, Servlet Parameters (parsed), Current user (via getUser() as shown), etc. User object is used to access typical user information Name, contact information, password, login information, etc.
Resources JSR 168 http://www.jcp.org/jsr/detail/168.jsp SunTM ONE Portal Server http://wwws.sun.com/software/products/portal_srvr/home_portal.h tml WSRP and WSIA @ OASIS http://www.oasis-open.org/committees/wsrp/ http://www.oasis-open.org/committees/wsia/ WSRP and WSIA @ XML Cover Pages http://xml.coverpages.org/wsrp.html http://xml.coverpages.org/wscm.html
code/articles/links/chats/resources http://www.sun.com/developers/evangcentral In pursuit of the best software in the universe All presentations Audiocasts Codecamp materials Technology briefings code/articles/links/chats/resources
Rima Patel Sriganesh rima.patel@sun.com http://www.sun.com/developers/evangcentral