Presentation is loading. Please wait.

Presentation is loading. Please wait.

Java Portlets (JSR-168) SSE USTC Qing Ding.

Similar presentations


Presentation on theme: "Java Portlets (JSR-168) SSE USTC Qing Ding."— Presentation transcript:

1 Java Portlets (JSR-168) SSE USTC Qing Ding

2 Agenda Java Portlet (JSR 168) WSRP Products (only a few slides)
Sun Java Enterprise Systeem Portal Server, Portlet Builder

3 What is a Portlet?

4 What is a Portlet? Java technology based web component
Managed by a portal container Generates a piece of markup called “fragment” Adheres to certain rules such as no <html> tags, for instance Fragment generated by a Portlet aggregates with that from other Portlets to form a portal page Fragment generated by a Portlet may vary from one user to another depending on the user configuration

5 What does JSR-168 define? Portlet API Portlet Container
Portlet Requests Preferences User information Security Deployment packaging Portlet Container Extension of servlet container Contract between component and container

6 What are out-scope of JSR 168?
Aggregation Layout management Page personalization and configuration engines Portal administration and configuration

7 Default Desktop

8 Portal/Portlet Architecture

9 Portal and Portlet Interaction

10 (Why can't we use Servlet?)
Why Portlet? (Why can't we use Servlet?)

11 Why Portlets? Servlet architecture does not define the Desktop metaphor where markup aggregation can occur Servlet architecture does not define the possible states and transitions of an included Servlet or JSP Servlet architecture does not define how the state of one Servlet or JSP affects the display of the other included Servlets or JSPs

12 Why Portlets? Servlet architecture does not define a personalization interface nor the idea of persisting the personalization information Servlet architecture does not define URLrewriting functions to allow the creation of links and actions targeted to a specific form within the fragment of a page (Portlet markup fragment) Servlet architecture does not support caching scheme of fragments

13

14 Portlet Architecture

15 Portal Architecture With JSR 168 Support

16 Portal A “specialized” web application that provides value-added services such as Personalization Single Sign-On Content aggregation from various sources Secure search facilities Localization of content A Portal “page” represents a complete markup document consisting of several Portlet components

17 Portlet Container Portlets are deployed in a Portlet container such that container can Provides runtime environment for Portlets Manage life cycle of Portlets Provide persistent storage for storing Portlet preferences Cache the portlets Receive requests from the portal to execute requests on the portlet Not responsible for contents aggregation

18 Servlet Architecture)
Portlet vs. Servlet (Portlet is built over Servlet Architecture)

19 Similarity with Servlet
Both are Java technology based web components Life-cycle is managed by a specialized container Servlet by servlet container Portlet by portlet container Both generate dynamic content Both interact with web client via a request/response paradigm

20 Deployment model Classloading Packaging and deployment Lifecycle management Session management Request dispatching

21 Differences from Servlet
Portlets only generate markup fragments, not complete documents Portlets are not directly bound to a URL Web clients interact with portlets through a portal system Portlets have a more refined request handling action requests and render requests Portlets have predefined states portlet modes and window states Portlets can exist many times in a portal page

22 Extra Features of Portlets
Portlets have means for accessing and storing persistent configuration and customization data Portlets have access to user profile information Portlets have URL rewriting functions for creating hyperlinks within their content allow portal server agnostic creation of links and actions in page fragments Portlets can store transient data in the portlet session in two different scopes application-wide scope the portlet private scope

23 Servlet Features Forbidden to Portlets
Setting the character set encoding of the response Setting HTTP headers on the response The URL of the client request to the portal

24 Servlet Features that are leveraged by Portlets
Portlets can leverage servlets, JSPs and JSP tag-libraries for generating content Content should be markup fragment A portlet can call servlets and JSPs using a request dispatcher

25 Integration between the two
Attributes set in the portlet request are available in the included servlet request Attributes set in the portlet session are accessible from the servlet session and vice versa Portlet and the included servlet or JSP share the same output stream

26 Portlet and Web App. Frameworks

27 Struts/JSF are built over Servlets
Struts/JSF can be built over Portlets APIs exposed to Struts/JSF developers should remain the same Struts/JSF developers must be aware of the markup fragment he has to produce The markup fragment must follow the rules Generate Portlet URL

28 Exo Portal Build on JSF, Struts

29 Portlet Modes & Windows State

30 Portlet Modes Indicates function that a portlet performs
Execute different tasks and generate different content based on the function they perform Portals must support three modes VIEW Portlet renders markup fragment in this mode EDIT Used to change per-user settings to customize rendering HELP Used to display help information

31 Portlet Modes (Contd.) Portals might support other custom modes
ABOUT CONFIG EDIT_DEFAULTS PREVIEW PRINT Portals might support other vendor specific modes

32 Windows State Is an indicator of the amount of portal page space that will be assigned to the content generated by a portlet Provided by portlet container Three states NORMAL MAXIMIZED MINIMIZED Custom states are possible

33 Portlet Features

34 Portlet Persistence Portlets can store persistent data for a given user in a PortletPreferences object Preferences are read-write in the action phase (processAction()) and read-only in render phase Usually user preferences are modified in EDIT mode

35 User Profile Attributes
Can store information about user that can be used to personalize content for that user User profile information is represented as a USER_INFO structure which is then mapped to the real information in datastore Portlet defines the attributes it wants to access in the deployment descriptor

36 Portal context Can provide information on
Portal vendor Version Used by portlets to find out more information about additional extensions supported by Portal

37 Security Authentication is left to the underlying servlet container
Authorization Follows J2EE ‘roles’ model Supports programmatic role checking

38 Session Management Facade on top of the HttpSession
Two scopes: APPLICATION & PORTLET PORTLET is a convenience namespacing It’s common for portlets to appear more than once in a page (i.e.: EU-News, US-News) Servlets, JSPs and Portlets within a Portlet Application share the same session Session creation event notification is supported

39 Portlet Request Dispatcher
Portlets can include Servlets, JSPs and static content during a render request Similar to Servlet’s RequestDispatcher

40 Localization Portlets can be localized by using resource bundles
Resource bundles are specified in deployment descriptor Portlet can access resource bundle via PortletContext.getResourceBundle() API

41 Caching Expiration based caching Declarative caching
Specify <expiration-cache> element in deployment descriptor for the portlet Programmatic caching Modify EXPIRATION_CACHE property of render response

42 Portlet URL Portlets are always accessed through a Portal
Portlets do not have a direct URL mapping Portlet URLs allow Portlets to create URLs that target to themselves (through the Portal end-point)

43 Portlet API's

44

45 Portlet Life Cycle

46 GenericPortlet class Implements Portlet interface
Render()--like service() in servlets, calls specified render methods based on Portlet mode doView() for View mode doEdit() for Edit mode doHelp() for Help mode Is extended by portlet developers Override render methods as necessary

47 DoView()

48 DoEdit()

49 ProcessAction()

50 Other Interfaces/Classes
PortletConfig, PortletContext, PortalContext,PortletSession PortletPreferences interface WindowState (MINIMIZED, NORMAL & MAXIMIZED) PortletMode (VIEW, EDIT & HELP) PortletURL PortletRequestDispatcher Portlet Tag Library

51 PortletPreferences Persistent read/write Portlet configuration
getValues(), setValues() to access PortletPreferences May modify attributes and store() in persistence during processAction() Normally, portlet preferences are per portlet/per user Persistency is managed by the portletcontainer Default values are defined in the portlet.xml deployment descriptor

52 Portlet Example – portlet class

53 Packaging & Deployment

54 Portlet Web Application
All resources, portlets, deployment descriptors are packaged in one web application archive (WAR file) PortletApp\ jsp htmls WEB-INF\ web.xml portlet.xml sun-portlet.xml classes\ Lib\

55 Portlet Example – portlet.xml

56 WeatherPortlet Sample Code

57 WeatherPortlet

58 WeatherPortlet (1 of 7)

59 WeatherPortlet (2 of 7)

60 WeatherPortlet (3 of 7)

61 WeatherPortlet (4 of 7)

62 WeatherPortlet (5 of 7)

63 WeatherPortlet (6 of 7)

64 portlet.xml

65 WSRP (Web Services for Remote Portlet)

66 WSRP Value Proposition
Provides protocols and metadata for Presentation-oriented Web services Meant for aggregation and syndication with no programming on the consumer side Roles WSRP Producers (Web service provider) WSRP Consumers (Web service consumer)

67 Portal Architecture With WSRP Support

68 JSR168 and WSRP They were designed in collaboration mode
Their functionality is fully aligned Portlet:Portlet.processAction() WSRP: WSRP.performBlockingInteraction() Portlet: Portlet.render() WSRP: WSRP.getMarkup()

69 Sun Java System Portal Server

70 Integrated Communications Desktop and Wireless Access

71 Personalization Modify any aspect of the desktop (as allowed by the Administrator) Add or delete portlets Customize the desktop layout Use or create personalized themes Modify or create multiple tabs Update user profile information Modify portlets settings and properties

72 Sun Java System Portal Server and Portal standards
Sun Java System Portal Server supports JSR 168 WSRP will be supported in the first Sun Java System update

73 Sun Java System Portal Server Architecture
How do JSR168 and WSRP fit in ?

74 Sun ONE Portal Server with JSR 168 and integration to EIS

75 Sun Java Studio Portlet Builder

76 Portlet Builder Portlet development plug-in for Sun JavaTM Studio
Easy development It has wizards It creates and updates the portlet.xml Supports portlets execution, debugging and deployment within the Studio IDE Runs in Sun JavaTM Studio 4.x and 5.x

77

78

79 Resources

80 Resources JSR 168 SunTM ONE Portal Server Sun ONE Portlet Builder
SunTM ONE Portal Server Sun ONE Portlet Builder OASIS XML Cover Pages


Download ppt "Java Portlets (JSR-168) SSE USTC Qing Ding."

Similar presentations


Ads by Google