01: /*
02: * JFox - The most lightweight Java EE Application Server!
03: * more details please visit http://www.huihoo.org/jfox or http://www.jfox.org.cn.
04: *
05: * JFox is licenced and re-distributable under GNU LGPL.
06: */
07: package org.jfox.ejb3.interceptor;
08:
09: import java.lang.reflect.Method;
10: import javax.interceptor.InvocationContext;
11: import javax.ejb.EJBException;
12:
13: /**
14: * Interceptor Method anntated by @Interceptors on Class & Method
15: *
16: * @author <a href="mailto:jfox.young@gmail.com">Young Yang</a>
17: */
18: public class ExternalInterceptorMethod implements InterceptorMethod {
19:
20: private Method interceptorMethod;
21:
22: private Object interceptorInstance;
23:
24: public ExternalInterceptorMethod(Class interceptorClass,
25: Method interceptorMethod) {
26: this .interceptorMethod = interceptorMethod;
27: try {
28: interceptorInstance = interceptorClass.newInstance();
29: } catch (Exception e) {
30: throw new EJBException(
31: "Could not create Interceptor class.", e);
32: }
33: }
34:
35: public Object invoke(InvocationContext invocationContext)
36: throws Exception {
37: return interceptorMethod.invoke(interceptorInstance,
38: invocationContext);
39: }
40:
41: public static void main(String[] args) {
42:
43: }
44: }
|