I'm trying to understand the booking LoginAction
| //$Id: LoggedInInterceptor.java,v 1.12 2006/07/26 23:19:55 gavin Exp $
| package org.jboss.seam.example.booking;
|
| import java.lang.reflect.Method;
|
| import javax.interceptor.AroundInvoke;
| import javax.interceptor.InvocationContext;
| import javax.faces.event.PhaseId;
|
| import org.jboss.seam.annotations.Interceptor;
| import org.jboss.seam.contexts.Contexts;
| import org.jboss.seam.contexts.Lifecycle;
| import org.jboss.seam.interceptors.BijectionInterceptor;
| import org.jboss.seam.interceptors.BusinessProcessInterceptor;
| import org.jboss.seam.interceptors.ConversationInterceptor;
| import org.jboss.seam.interceptors.RemoveInterceptor;
| import org.jboss.seam.interceptors.ValidationInterceptor;
|
| @Interceptor(around={BijectionInterceptor.class,
ValidationInterceptor.class,
| ConversationInterceptor.class,
BusinessProcessInterceptor.class},
| within=RemoveInterceptor.class)
| public class LoggedInInterceptor
| {
|
| @AroundInvoke
| public Object checkLoggedIn(InvocationContext invocation) throws
Exception
| {
| boolean isLoggedIn =
Contexts.getSessionContext().get("loggedIn")!=null;
| if ( Lifecycle.getPhaseId()==PhaseId.INVOKE_APPLICATION )
| {
| if (isLoggedIn)
| {
| return invocation.proceed();
| }
| else
| {
| return "login";
| }
| }
| else
| {
| if ( isLoggedIn )
| {
| return invocation.proceed();
| }
| else
| {
| Method method = invocation.getMethod();
| if ( method.getReturnType().equals(void.class) )
| {
| return null;
| }
| else
| {
| return method.invoke( invocation.getTarget(),
invocation.getParameters() );
| }
| }
| }
| }
|
| }
|
Wondering two things from this code:
1. what do we get for checking the Lifecycle.PhaseId
2. what is the purpose of calling method.invoke(....) instead of returing a
string outcome (aka, "login") like is done if we are in the INVOKE_APPLICATION
phase.
Thanks,
--jc
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3963696#3963696
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3963696
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user