authorityinterceptor.java

来自「Ajax和j2ee开发的一个拍卖系统。主要用了DWR」· Java 代码 · 共 38 行

JAVA
38
字号
package org.yeeku.authority;

import javax.servlet.http.HttpSession;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

import org.yeeku.exception.AuctionException;

/**
 * @author  yeeku.H.lee kongyeeku@163.com
 * @version  1.0
 * <br>Copyright (C), 2005-2008, yeeku.H.Lee
 * <br>This program is protected by copyright laws.
 * <br>Program Name:
 * <br>Date: 
 */
public class AuthorityInterceptor implements MethodInterceptor
{
    public Object invoke(MethodInvocation invocation) throws Throwable
	{
        HttpSession sess = null;
        Object[] args = invocation.getArguments();
        for (int i = 0 ; i < args.length ; i++ )
        {
            if (args[i] instanceof HttpSession) sess = (HttpSession)args[i];
        }
		Integer userId = (Integer)sess.getAttribute("userId");
        if ( userId != null && userId.intValue() > 0)
        {
            return invocation.proceed();
        }
        else
        {
            throw new AuctionException("您还没有登陆,请先登陆系统再执行该操作");
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?