Академический Документы
Профессиональный Документы
Культура Документы
www.JAVA9
By, Srinivas
Interceptors
Separates the cross cutting concerns Pre Processing and Post processing. Manages the work flow.
www.JAVA9
www.JAVA9
Interceptor By E a!ple
" #ogin page
www.JAVA9
Interceptor $y E a!ple
Redisplay the login page for wrong credentials
Access the Authorized page directly with out logging should forward the login page
www.JAVA9
*reating an Interceptor
%he interceptor class should i!ple!ent the Interceptor interface. I!ple!ent the intercept !ethod. &o the pre processing and if everything is ok, invoke the invocation.invoke'( which will call the ne t co!ponent in )ueue. If so!ething goes wrong, return a string $ased on which a result page will $e picked and sent to the client. "fter the invocation.invoke'(, write the post processing logic
Interceptors in defaultstack
-interceptor.stack na!e/0defaultStack01 %interceptor&ref name'(exception()* Handles the result based on the exception. %interceptor&ref name'(alias()* +nables to have a different named parameter %interceptor&ref name'(servlet"onfi$()* ,ill set the request, response, session objects to the action class. %interceptor&ref name'(prepare()* This interceptor calls-prepare./-on actions !hich implement 0reperable %interceptor&ref name'(i12n()*sets the locale specified in a session as the locale for the current action request %interceptor&ref name'(chain()* Helps to chain the actions. %interceptor&ref name'(debu$$in$()*0rovides several different debu$$in$ screens to provide insi$ht into the data behind the pa$e %interceptor&ref name'(profilin$()*#llo!s profilin$ to be enabled or disabled via request parameters, !hen devMode is enabled.
www.JAVA9
Interceptors in defaultstack
%interceptor&ref name'(scopedModelDriven()*#n interceptor that enables scoped model&driven actions. %interceptor&ref name'(modelDriven()*,atches for ModelDriven actions and adds the action3s model on to the value stack %interceptor&ref name'(file4pload()*Helps in file upload. %interceptor&ref name'(checkbox()*5ooks for a hidden identification field that specifies the ori$inal value of the checkbox. %interceptor&ref name'(static0arams()*This interceptor populates the action !ith the static parameters defined in the action confi$uration. %interceptor&ref name'(params(*This interceptor sets all parameters on the value stack %param name'(exclude0arams(*dojo6..7%)param* %)interceptor&ref*
www.JAVA9
Interceptors in defaultstack
%interceptor&ref name'(conversion+rror()* "onversion+rror8nterceptor adds conversion errors from the #ction"ontext to the #ction3s field errors. %interceptor&ref name'(validation(*9alidates the parameters %param name'(excludeMethods(*input,back,cancel,bro!se%)param* %)interceptor&ref* %interceptor&ref name'(!orkflo!(* #n interceptor that does some basic validation !orkflo! before allo!in$ the interceptor chain to continue %param name'(excludeMethods(*input,back,cancel,bro!se%)param* %)interceptor&ref* -2interceptor.stack1
www.JAVA9
%hank you
&ownload PP% and e a!ple code fro!
http3224ava5s.co!