java用代理判断session是否过期,过期后怎么跳转
package com.essp.uas.proxy;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
public abstract class ProxyFactory<T> implements InvocationHandler {
private T target;
public ProxyFactory(T target) {
super();
this.target = target;
}
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
Object o = null;
try {
before(args);
o = method.invoke(target,args);
after(method.getName(),args);
} catch (Exception e) {
onException(e);
e.printStackTrace();
}
return o;
}
@SuppressWarnings("unchecked")
public T createProxy() {
Class<T> cls = (Class<T>) target.getClass();
if (cls.getInterfaces() != null)
return (T) Proxy.newProxyInstance(cls.getClassLoader(), cls
.getInterfaces(), this);
return target;
}
public abstract void onException(Exception ex);
public abstract void before(Object[] args);
public abstract void after(String methodName,Object[] args);
}