Using portal site analysis with the JSR 286 Web Content Viewer Portlet
JSR-286: Portlet 2.0 JBoss Portal - Austin Java Users Group
Transcript of JSR-286: Portlet 2.0 JBoss Portal - Austin Java Users Group
JSR-286: Portlet 2.0&
JBoss Portal
Prabhat JhaSenior Engineer
JBoss, a division of Red HatTuesday, Feb 24th 2009
AgendaAgenda
•Concepts
•Portlet 1.0 (JSR-168) specification
•What’s new in Portlet 2.0 (JSR-286)
•JBoss Portal & Enterprise Portal Platform (EPP)
•Q&A
ConceptsConcepts
Portal JargonsPortal Jargons
•Portal
•Page
•Portlet‣ Mode‣ State
•Portlet Container
PortalPortal
•Unify access to your web applications
•Integrate your enterprise-level services
•Provide a consistent UI to your enterprise services
Integration at workIntegration at work
Different users: different views
CSR Portal
Manager PortalCustomer Portal
JBoss Portal Header/Navigation
Product Data
Customer Records
Inventory
ManufacturingInfo
Employee Data
Supply
JBoss Portal Header/Navigation
Product Data
Customer Records
Inventory
Supply
Customer Records
Product Data
Inventory
JBoss Portal Header/Navigation
To use or not to use Portal?To use or not to use Portal?
•Simple application like a web-blog - NO
•Intranet, Insurance Portal, Banking & Finance Portal- Yes
•Have aggregation and integration of content from different sources?
•Need more than simple personalization?
PortletPortlet
•User interface component targeted at the portal ecosystem
•Similar to web applications‣ Deployed in a portlet container‣ Can better focus on single task‣ Can delegate common concerns‣ Reusable
Portlet vs ServletPortlet vs Servlet
•Generate markup fragments vs whole document
•URL constructed via portlet api
•Have means of storing persistent config and customization data
•Session data have two scopes
•Can and send receive events
Portlet containerPortlet container
•Similar to servlet containers but for portlets‣ Runs on top of a servlet container
•Manages portlets on behalf of portals:‣ Exposes portlet metadata to portals‣ Manages portlet lifecycle and state‣ Handles portlet invocations
PortalPortal
Architecture
Portlet ContainerPortlet Container
PortletPortlet PortletPortlet
PortletPortlet PortletPortlet
JSR-168: Portlet 1.0JSR-168: Portlet 1.0
JSR-168 specificationJSR-168 specification
•Portlet ecosystem fragmented prior to JSR-168
•Finalized in October 2003
•Integrated with Java EE but not part of it
•Resulted in wide adoption by portal vendors
JSR-168 overviewJSR-168 overview
•Portlet metadata‣ Description, name, display names‣ Supported content types‣ Keywords‣ Localization
•Web application based packaging‣ Specific descriptor: /WEB-INF/portlet.xml
‣ Portlets implement javax.portlet.Portlet
JSR-168 at workJSR-168 at work
•Two-step request handling‣ action phase to interact with the portlet‣ render phase outputs markup
•Scoped states‣ render parameters for navigation‣ session with portlet and application
scopes‣ preferences that can be set at several
levels
JSR-168 limitationsJSR-168 limitations
•Interportlet communication‣ attributes sharing at the application via
session‣ vendor-specific API
•No resource serving‣ Needed additional servlet
•Limited AJAX support
•Bridging web frameworks difficult
JSR-286: Portlet 2.0JSR-286: Portlet 2.0
JSR-286 specificationJSR-286 specification
•Released in June 2008
•http://jcp.org/en/jsr/detail?id=286
•Main goals:‣ Backward compatibility‣ Improve portlet coordination‣ Provide support for resource serving‣ Better AJAX support‣ Easier bridging of web frameworks
JSR-286 new featuresJSR-286 new features
•Public Render Parameters (PRP) - portlets can share parameters
•Events - portlets can now send and receive events
•Resource serving
•Portlet filters - similar to servlet filters
•Java 5: Generics, enum, Annotation
Coordination: PRPsCoordination: PRPs
•Use cases‣ Simple coordination across web
application boundary- Weather, Map, Events based on a zipcode
‣ Sharing of view state across portlets
•Anti-patterns‣ Not meant to synchronize state‣ Cannot be used for complex
coordination
PRP declarationPRP declaration•In /WEB-INF/portlet.xml
PRP-using portletPRP-using portlet
PRP Wiring in JBossPRP Wiring in JBoss
•You can create ALIAS for semantically equivalent PRP‣ Weather Portlet uses ZIP‣ Map Portlet user ZIP_CODE‣ Create my_zip which maps to ZIP and
ZIP_CODE
•Implicit•Explicit
Coordination: EventsCoordination: Events
•Use cases‣ Decoupling of different applications
that need to communicate‣ Integration of legacy event-using
applications‣ Communication between the portal and
the portlet- Login/Logout- Activities
Coordination: EventsCoordination: Events
•Anti-patterns‣ Not suited for business events as
reliable delivery is not enforced (best effort)
‣ Synchronization of render parameters is better done via PRPs
‣ Beware of infinite event processing loops
‣ Not a messaging system
Coordination: Events Coordination: Events
Ref: http://www.ibm.com/developerworks/websphere/library/techarticles/0803_hepper/image002.gif
Coordination: Events Coordination: Events •New event phase
‣ Optional‣ Occurs after action (which can
generate events) and before render‣ Portlets implementing EventPortlet can
react via processEvent method
Event declarationEvent declaration•In /WEB-INF/portlet.xml
Event-publishing Event-publishing portletportlet
Event-processing Event-processing portletportlet
Events Wiring in JBoss Events Wiring in JBoss PortalPortal
•Implicit
•Explicit
Resource ServingResource Serving
•Logical extension of render phase
•Complete control over HTTP response
•Has access to portlet context, portal security
•Must implement serveResource method on ResourceServingPortlet interface
•Can be leveraged for AJAX‣ Deliver markup fragment as resources‣ Use session to update navigational state
Resource ServingResource Serving
•Different Cacheability‣ Fully cacheable resource
- Does not depend on interaction state‣ Full and shared cacheable resource
- JS library‣ Portlet level cacheability
- pdf view of current portlet‣ Page level cacheablility (default)
- Ajax resources
Resource ServingResource Serving
public void serveResource(ResourceRequest resRequest, ResourceResponse resResp) throws PortletException, IOException {
resResp.setContentType("image/png");
byte[] b = getImage("MyImage.PNG"); //Returns image bytes
resResp.getPortletOutputStream().write(b);
}
Resource serving: Resource serving: AJAX exampleAJAX example
JSR-168
JSR-286
Ref: http://www.ibm.com/developerworks/websphere/library/techarticles/0803_hepper/image005.gif
Portlet filtersPortlet filters•Similar to servlet filters
•Can modify request and response
•Can receive initialization parameters
•Applied to the different lifecycle methods:lifecyclelifecycle parameter parameter methodmethod
ACTION_PHASEACTION_PHASE processActionprocessActionEVENT_PHASEEVENT_PHASE processEventprocessEvent
RENDER_PHASERENDER_PHASE renderrenderRESOURCE_PHASERESOURCE_PHASE serveResourceserveResource
Filter declarationFilter declaration•In /WEB-INF/portlet.xml
Other featuresOther features
•Request and response header access‣ Easier injection of <head> elements in
aggregated markup: doHeaders(..)‣ Read/write HTTP headers‣ Cookie access
•Improved caching
•Improved request dispatching for better bridging support
Compatibility with 1.0Compatibility with 1.0•Generally backward compatible
•But some things to be aware of:‣ Portlet URLs are now XML escaped by
default. Can be changed by overriding runtime option
‣ Specifying multiple values for a parameter now must create a value array
‣ getProtocol now returns ‘HTTP/1.1’ instead of null
‣ RenderResponse.setContentType no longer required to be called before retrieving output stream or writer
JSR-286 new featuresJSR-286 new features
•Class Digram
Summary Of JSR-286Summary Of JSR-286
•JSR-286 is a welcome evolution of the Portlet specification
•Much better coordination options for improved portlet reusability & business like mashup
•Overall improvements make developing portlets easier
• What does it lack??
JBoss Enterprise Portal PlatformJBoss Enterprise Portal Platform
•Standards based
•Easily Extendible
•Performance and Scalability
•Centralized Security (SSO, Identity Manager)
•Modular‣ Lightweight bare portal‣ Deploy/undeploy on demand
JBoss Enterprise Portal PlatformJBoss Enterprise Portal Platform
•JBoss SX: JAAS-based security
•JBoss Cache: performant, fault-tolerant caching
•Hibernate: database independence, persistence
•JBPM: business processes
•JBoss WS: WSRP
•JBoss Portlet Bridge: JSF, MyFaces, RichFaces, Seam
JBoss Enterprise Portal PlatformJBoss Enterprise Portal Platform
1 2 3 4 5 10
Max TPSMax Number of Concurrent Users
Number of Nodes in Cluster
How are we staying busy?How are we staying busy?
•AS 5 Compatibility
•Identity framework
•Authorization framework
•Tooling with JBDS
•Seam and Richfaces Integration
•Presentation Framework
Getting InvolvedGetting Involved
•Contribute Code (Feature, Bug fixes..)
•i18n
•User forum
•Integrating with various frameworks & their HowTo guide
•Documentation
Q & AQ & A