Portlet 2 Spec
-
Upload
michael-dann -
Category
Documents
-
view
234 -
download
0
Transcript of Portlet 2 Spec
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 1/51
Java Portlet 2.0(JSR 286 Spec)
John A. LewisChief Software Architect
Unicon, Inc.
JA-SIG Conference
28 April 2008
© Copyriht Unicon, Inc., 200!. So"e rihts reser#e$. %his wor& is license$ 'n$er a
Creati#e Co""ons Attri('tion-)onco""ercial-Share Ali&e *.0 Unite$ States License.%o #iew a copy of this license, #isit http+creati#eco""ons.orlicenses(y-nc-sa*.0's
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 2/51
2
Agenda
. ortlet Specs an$ /eat'res
2. JS 281 a3or Chanes
*. JS 281 inor Chanes
4. 5'estions an$ Answers
Special than&s to Cris 6ol$orph fro" Uniconfor helpin to prepare this "aterial.
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 3/51
*
ortlet Specs 7 /eat'res
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 4/51
4
ortlet .0 JS 18 6istory
– Ja#a Co""'nity rocesshttp+www.3cp.oren3sr$etaili$918
– Le$ (y S'n an$ I:
– Starte$+ 2; Jan'ary 2002
– elease$+ 2! <cto(er 200*
– eference I"ple"entation+ Apache l'to
– Interopera(ility (etween ortlets ortals
– Set of AIs $efinin ortlets – Lin&e$ to =S .0 Specification
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 5/51
>
ortlet 2.0 JS 281 6istory
– Ja#a Co""'nity rocesshttp+3cp.oren3sr$etaili$9281
– Le$ (y I:
● Ste#en 6epper ?sthepper@$e.i(".co"
– Starte$+ 2; )o#e"(er 200> – /inal Appro#al :allot+ * arch 2008 ?asse$
– =aitin for %CB an$ eference I"ple"entation?l'to 2.0
– Lin&e$ to =S 2.0 Specification
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 6/51
1
JS 18 /eat're S'""ary
– Lifecycle ?init, action, ren$er, $estroy
– ortlet ULs ?en$er UL, Action UL
– ortlet o$e ?iew, D$it, 6elp
– =in$ow States ?)or"al, aEi"iFe, ini"iFe
– en$er ara"eters
– ortlet references
– ortlet Session
– ortlet eploy"ent escriptor ?portlet.E"l
● eEpiration-cache
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 7/51
!
JS 281 H a3or Chanes
●
ortlet D#ents● '(lic en$er ara"eters
● eso'rce Ser#in
●
ortlet /ilters● Cachin Chanes
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 8/51
8
JS 281 H inor Chanes
●
=in$ow I● )a"espacin
● Lifecycle hase
e'est Attri('te● D)D6DADS
S'(-phase
●
ortlet Coo&ies● Settin ar&'p 6ea$
Dle"ents
●
)eEt ortlet o$es
●
ortlet %a Li(raryChanes
● A$$itional CSSClasses
● ortlet e'estispatcher Chanes
● ortlet eso'rce:'n$le Chanes
● ortlet Container'nti"e <ptions
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 9/51
;
JS 281 - Unchane$
●
ortlet o$es● =in$ow States
● ortlet references
●
ortlet Sec'rity● User Infor"ation
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 10/51
0
ortlet D#ents
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 11/51
D#ents an$ the ortlet Lifecycle
● )ew Lifecycle hase+ Event Processing
● /or each o#erall portal pae re'est+
– Action Phase H calle$ on at "ost one portletwin$ow
– Event Phase H calle$ on as "any portlet win$owsas necessary
– Render Phase H calle$ on 'p to as "any portlet
win$ows that are $isplaye$ on c'rrent pae● D#ents "ay (e enerate$ $'rin Action Phase
or Event Phase H not $'rin Render Phase
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 12/51
2
iara" fro" Ja#aK ortlet Specification, ersion 2.0 '(lic raft , e#. ;
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 13/51
*
EventPortlet Interface
● javax.portlet.EventPortlet Interface
– ay (e i"ple"ente$ (y a Portlet
– Contains one "etho$+
void processEvent(EventRequest, EventResponse)
– EventRequest o(3ect pro#i$es e#ent payloa$ an$other typical portlet info ?"o$e, win$ow state,etc
–
processEvent is si"ilar to processAction forcopyin renderParameters
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 14/51
4
'(lishin D#ents
● D#ents "ay (e p'(lishe$ 'sin "etho$s on ActionResponse or EventResponse
– setEvent or setEvents
– 'ltiple calls to setEvent an$ setEvents are
allowe$
● D#ent $eli#ery an$ processin or$eris not guaranteed
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 15/51
>
D#ent efinitions
● D#ents "'st (e $efine$ in portlet.xml
● After e#ent $efinition, each portlet "'st$eclare what e#ents it will p'(lish or recei#e
●
ortal-$efine$ e#ents $o not ha#e to (e$efine$ in portlet.xml
● D#ent na"in+
–
'st 'se the =*C 5)a"e stan$ar$ – ecei#in e#ents can en$ with a wil$car$
– Can $eclare default-event-namespace in
portlet.E"l an$ 3'st 'se local na"es
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 16/51
1
D#ents an$ JAM:
● JAM: 2.0 "'st (e 'se$ to $efine the D#entayloa$
● JAM: is necessary for interopera(ility with=S e#ents
● I"ple"entin e#ent payloa$ class "'st (eSerialiFa(le an$ annotate$ with JAM:annotations
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 17/51
!
'(lic en$er ara"eters
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 18/51
8
'(lic en$er ara"eters
● ay (e #isi(le to "'ltiple ortlets 7 =e(apps
● anae$ in portlet.xml
– efine$ in the <portlet-application>
–
eclare$ in each <portlet> that wants it● )a"e "'st follow the =*C 5na"e spec H
can $eclare a default-name-space
●
A portal can $eci$e which p'(lic ren$erpara"eters will (e share$ (y which portlets
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 19/51
;
eso'rce Ser#in
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 20/51
20
eso'rce Ser#in
● ortlets can create two types of eso'rceLin&s – irect Lin&s ?not new
– eso'rce UL Lin&s ?newN
●
irect Lin&s – ore efficient
– )ot 'arantee$ to o thro'h ortal
– =ill not ha#e portal conteEt a#aila(le
– )o portal access control
● eso'rce UL Lin&s – =ill o thro'h the ResourceServingPortlet
interface
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 21/51
2
eso'rceSer#inortlet
● ResourceServingPortlet Interface
void serveResource(ResourceRequest, ResourceResponse)
● ortlet can pro$'ce content with
– ResourceResponseWriter
– OutputStream
– eleate with a RequestDispatcher call
● ortal is not allowe$ to "o$ify content
● ortlet sho'l$ not 'se 6%% GD% for statechane 'se 6%% <S%U%DLD%D instea$
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 22/51
22
eso'rce ULs
● ortlet creates a ResourceUR to itself withPortletResponse.createResourceUR!"
● ResourceUR only #ali$ if a ortleti"ple"ents ResourceServingPortlet
● oes not ca'se processAction to (e in#o&e$
● Cannot chane ortlet o$e or =in$ow State
●
All c'rrent ren$er para"eters will (e incl'$e$● )ew para"eters set $o not (eco"e ren$er
para"eters
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 23/51
2*
Cachea(ility of eso'rces
● ResourceUR can control the Ocachea(ilityP ofthe reso'rce #ia the set#achea$ilit% "etho$+
– F!! H %he "ost cachea(le H UL $oes not nee$to contain state of the pae, the c'rrent ren$er
para"eters, portlet "o$e, or win$ow state – P"R#!E# H UL nee$s portlet state ?ren$er
para"eters, portlet "o$e, an$ win$ow state, ('t$oes not nee$ the state of the rest of the pae
– PA$E H %he least cachea(le H UL nee$sco"plete state of pae an$ portlet
● Cannot create ULs with "ore $etail in
eso'rce re'ests fro" ULs with less $etail
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 24/51
24
<ther eso'rce Infor"ation
● ResourceRequest pro#i$es access to a "iE ofortlet infor"ation an$ infor"ation 'ni'e toeso'rces+
– ortlet o$e, =in$ow State, an$ en$er
ara"eters of the re'estin portlet are pro#i$e$ – /'ll access to 6%% hea$ers
?can set on response as well
– 6%% etho$ of the re'est
– %he eso'rce I set on the eso'rce UL ?if any
– %he D%AG for cache #ali$ation
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 25/51
2>
ortlet /ilters
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 26/51
21
ortlet /ilters
● o$ele$ after Ser#let /ilters
● o$ify re'est $ata (y wrappin re'est
● o$ify response $ata (y wrappin response
●
Intercept in#ocation of a portlet (efore an$after it is calle$
● /ilters "ay (e chaine$
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 27/51
2!
ortlet /ilter Interface
● 'st i"ple"ent javax.portlet.&ilter interface
● 'st pro#i$e a p'(lic no-ar constr'ctor
● init!" "etho$ will (e calle$ on all /ilters
(efore (ein calle$ on any ortlets● destro%!" will (e calle$ if /ilter is re"o#e$
fro" ser#ice
●
do&ilter!" "etho$ calle$ if processAction!", processEvent!", render!", or serveResource!" wo'l$ (e calle$ on /iltere$ ortlet
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 28/51
28
eclarin ortlet /ilters
● eclare$ in portlet.xml in <filter> ele"ent
● <filter-mapping> ele"ent "'st specify the
applica(le portlets
●
estrict to specific lifecycle "etho$s 'sin the <lifecycle> ele"ent in <filter-mapping>
● <r$er in portlet.xml "atters for "'ltiplefilters of the sa"e portlet
● ortlet containers are eEpecte$allowe$ tocache the Ofilter chainP
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 29/51
2;
=rappin e'estseponses
● )ew wrapper classes pro#i$e$ for all re'estan$ response o(3ects for 'se with /ilters+
– Actione'est=rapperActionesponse=rapper
– D#ente'est=rapperD#entesponse=rapper
– en$ere'est=rapperen$eresponse=rapper
– eso'rcee'est=rappereso'rceesponse=rapper
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 30/51
*0
ortlet Cachin
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 31/51
*
Cachin
● %wo %ypes+
– DEpiration Cachin
● =hat eEiste$ (efore with so"e chanes
– ali$ation Cachin
● )ew for eEtension of eEpiration cachin
● Cachin is now applie$ to (oth the en$eran$ eso'rce lifecycle phases
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 32/51
*2
DEpiration Cachin
● If no <expiration-cache> #al'e is specifie$
then portlet will (e treate$ as always eEpire$
● )ew <expiration-time> s'(-ele"ent
–
re#io's ti"e-in-secon$s #al'e oes here● )ew <expiration-scope> s'( ele"ent
– P!"#$%&$'PE "ay (e share$ across 'sers
–
PR#*E%&$'PE "ay )<% (e share$ ?$efa'lt● Action or D#ent re'est will eEpire cache
● expiration-time an$ expiration-scope
can (e chane$ prora""atically
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 33/51
**
ali$ation Cachin
● ortlet sho'l$ set E*+ property ?#ali$ation
to&en an$ expiration-time when ren$erin
● )ew ren$erreso'rce re'ests will only (ecalle$ after expiration-time is reache$
● )ew re'est will (e sent the E*+
● ortlet sho'l$ eEa"ine it an$ $eter"ine ifcache is still oo$ H if so, set a newexpiration-time an$ do not render
● 'st set the E*+, eEpiration ti"e, an$
cachin scope (efore writin any o'tp't
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 34/51
*4
JS 281 inor Chanes
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 35/51
*>
=in$ow I
● )ew PortletRequest.getWindo'(D!" "etho$"'st ret'rn the ortlet =in$ow I
● e#iew fro" JS 18+
– Portlet %eplo&'ent ?not "entione$ $irectly inspecification+ portlet.xml file infor"ation
– Portlet %einition+ '(lish ti"e infor"ation
– Portlet Entit&+ S'(scri(e ti"e infor"ation
– Portlet indo*+ LoinSession ti"e infor"ation
● Use$ for portlet-scope$ session $ata
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 36/51
*1
)a"espacin
● get)amespace!" "etho$ now a#aila(le on allortlet e'est classes ?pre#io'sly only onRenderRequest
● ro#i$es a 'ni'e #al'e for the c'rrent ortlet
=in$ow● al'e "ay (e 'se$ to prefiE Ja#ascript
f'nctions #aria(les or other ite"s within a
portal pae that "'st (e 'ni'e● =ill ret'rn the sa"e #al'e for the lifeti"e of
the ortlet =in$ow
f l h (
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 37/51
*!
Lifecycle hase e'est Attri('te
● "#E$$"E%P.&E re'est attri('te of the
PortletRequest interface $eter"ines c'rrentphase+
– $*#'/%P.&E 9 ActionRequest
– EE/*%P.&E 9 EventRequest
– RE/0ER%P.&E 9 RenderRequest
– RE&'R$E%&ER#/+%P.&E 9 ResourceRequest
● esine$ to let fra"ewor&s cast correctly
S ( h
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 38/51
*8
RE/0ER%.E0ER& S'(-phase
● %he en$er hase now has two s'(-phases ifthe render.eaders r'nti"e option is set tr'e
● Sho'l$ (e 'se$ when settin hea$ers,coo&ies, the title, or neEt portlet "o$es
● Strea"in portals will call render twice an$set RE/0ER%PR* portlet re'est attri('te as
follows+
– RE/0ER%.E0ER& on the first call, so perfor"
appropriate hea$er operations
– RE/0ER%1R2P on the secon$ call, so now ren$er
the act'al "ar&'p
l C &i
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 39/51
*;
ortlet Coo&ies
● Coo&ies can now (e set on thePortletResponse an$ retrie#e$ on thePortletRequest
● %hese coo&ies "ay (e store$ (y the ortal
an$ "ay not act'ally reach the client● Coo&ies set in the response of one phase will
(e a#aila(le in s'(se'ent phases ?e.. a
coo&ie set in the action phase will (ea#aila(le $'rin the ren$er phase
S tti & 6 $ Dl t
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 40/51
40
Settin ar&'p 6ea$ Dle"ents
● Use esponse addPropert% "etho$ with 1R2P%.E0%E"E1E/* constant as property
na"e an$ an org.'*c.dom.Element #al'e
● ro#i$e$ < ele"ent sho'l$ (e a$$e$ to
the "ar&'p <head> section of the response tothe client
● S'pport for this property is optional H #erify
#ia the 1R2P%.E0%E"E1E/*%&PP'R* property on the Portal#ontext
● /or a en$er esponse, sho'l$ (e $one in
RE/0ER%.E0ER& s'(-phase
) t i(l tl t $
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 41/51
4
)eEt ossi(le ortlet o$es
● %he RenderResponse can now in$icate theneEt possi(le ortlet o$es an$ =in$owStates
● ortals sho'l$ li"it a#aila(le na#iation
controls accor$inly● %o ens're this wor&s in all portals, set the"
$'rin the RE/0ER%.E0ER& s'(phase
tl t t i t h
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 42/51
42
ortlet e'est ispatcher
● PortletRequestDispatcher "ay now (e calle$fro" processAction!" an$ processEvent!", aswell as render!"
● All non-ren$er lifecycle "etho$s will not (e
allowe$ to (e write to any o'tp't strea"● PortletRequestDispatcher now has (oth an
include!" an$ a +or'ard!" "etho$
● ortlet e'est ispatchers "'st follow anySer#let /ilters set 'p
tl t : $l
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 43/51
4*
ortlet eso'rce :'n$le
● ortlet eso'rce :'n$le can now "anae"ore infor"ation+
– ortlet Info
● title, short-title, &eywor$s
● $isplay-na"e, $escription
– isplay )a"es escriptions
● '(lic ren$er para"eters
●
C'sto" portlet "o$es an$ win$ow states● D#ent $efinitions
● User attri('tes
tl t C t i ti < ti
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 44/51
44
ortlet Container 'nti"e <ptions
● efine a$$itional r'nti"e (eha#ior in portlet.xml
● efine$ at portlet application le#el or theportlet le#el
● Use ,container-runtime-option ele"ent
● C'rrent <ptions+
– javax.portlet.escape/ml
– javax.portlet.render0eaders
– javax.portlet.includedPortletSessionScope
– javax.portlet.actionScopedRequestAttri$utes
tl t % Li(
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 45/51
4>
ortlet %a Li(rary
● )ew resourceR" ta
● DEistin namespace ta re'ire$ to "atch the
#al'e of PortletResponse.get)amespace!"
● )ew copy$urrentRenderParameters attri('te
on Action an$ en$er ULs ?$efa'lt+ false● )ew escape31" attri('te on Action, en$er, an$
eso'rce ULs ?$efa'lt+ tr'e
● )ew property
ta for 'se in Action, en$er, an$
eso'rce ULs to set re'est properties
● define'45ects ta now incl'$es all new
re'estresponse o(3ects an$ access to
PortletSession an$ PortletPre+erences
A$$iti l CSS Cl
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 46/51
41
A$$itional CSS Classes
● )ow incl'$es the %a(le style $efinitions fro"=S .0
● So"e a$$itional /or"s an$ en's stylesha#e (een a$$e$
● )ote1 So"e na"es in the $raft still o#erlapan$ will nee$ to (e correcte$ (efore finalrelease
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 47/51
4!
eso'rces
eso'rces
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 48/51
48
eso'rces
● ain JS 281 =e(site – http+3cp.oren3sr$etaili$9281
● =S 2.0 Specification – http+$ocs.oasis-open.orwsrp#2wsrp-2.0-spec.ht"l
●
I"ple"entations – l'to 2.0 ?In e#elop"ent● http+portals.apache.orpl'to
– J(oss ?elease Can$i$ate● http+www.3(oss.orportletcontainer
– <penortal ?elease Can$i$ate● https+portlet-container.$e#.3a#a.net
– eMo ?elease Can$i$ate● http+www.eEoplatfor".co"
S'pport in Sprin ortlet C
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 49/51
4;
S'pport in Sprin ortlet C
● )ew annotations 7 para"eters+
– @en$erappin● win$owState
– @Actionappin●
na"e ?re'est para"eter Q3a#aE.portlet.actionQ – @D#entappin
● na"e ?local part of the e#ent na"e● na"e ?f'll e#ent na"e
–
@eso'rceappin● I$
– All s'pportin the eEistin para"eters for portlet"o$e an$ re'est para"eters
Sprin ortlet C oa$"ap
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 50/51
>0
Sprin ortlet C oa$"ap
● ortlet 2.0 s'pport planne$ for Sprin *.0
● )o i$ea when it will (e release$
?the tal& is so"eti"e this s'""er, ('t yo' $i$nRthear it fro" "e
● So"e $esin $isc'ssion in JIA+
– http+3ira.sprinfra"ewor&.or(rowseS-42>;
5'estions 7 Answers
8/13/2019 Portlet 2 Spec
http://slidepdf.com/reader/full/portlet-2-spec 51/51
5'estions 7 Answers
John A. LewisChief Software ArchitectUnicon, Inc.
3lewis@'nicon.netwww.'nicon.net