[jboss-user] [JBoss Seam] - Re: one question about Interceptor
diyun2008
do-not-reply at jboss.com
Sun Jan 21 11:13:20 EST 2007
You probably misunderstand.
The comlete code is here:
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() );
| }
| }
| }
| }
|
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4004553#4004553
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4004553
More information about the jboss-user
mailing list