01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.openejb.test.interceptor;
17:
18: import javax.annotation.PostConstruct;
19: import javax.interceptor.AroundInvoke;
20: import javax.interceptor.InvocationContext;
21:
22: /**
23: * @author <a href="mailto:goyathlay.geronimo@gmail.com">Prasad Kashyap</a>
24: *
25: * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 $
26: */
27: public class MethodInterceptor {
28:
29: /**
30: * The interceptor method.
31: * This should intercept all business methods in this bean class
32: * except those annotated with <code>@ExcludeClassInterceptors</code>
33: *
34: * @param ctx - InvocationContext
35: *
36: * @return - the result of the next method invoked. If a method returns void, proceed returns null.
37: * For lifecycle callback interceptor methods, if there is no callback method defined on the bean class,
38: * the invocation of proceed in the last interceptor method in the chain is a no-op, and null is returned.
39: * If there is more than one such interceptor method, the invocation of proceed causes the container to execute those methods in order.
40: *
41: * @throws runtime exceptions or application exceptions that are allowed in the throws clause of the business method.
42: */
43: @AroundInvoke
44: public Object methodInterceptor(InvocationContext ctx)
45: throws Exception {
46: Interceptor.profile(ctx, "methodInterceptor");
47: return ctx.proceed();
48: }
49:
50: /**
51: * The interceptor method.
52: * This should intercept postConstruct of the bean when intercepted at the class level.
53: * Verify that this interceptor is not invoked when intercepted at the method-level.
54: *
55: * @throws runtime exceptions.
56: */
57: @PostConstruct
58: public void methodInterceptorPostConstruct(InvocationContext ctx)
59: throws Exception {
60: Interceptor.profile(ctx, "methodInterceptorPostConstruct");
61: ctx.proceed();
62: return;
63: }
64:
65: }
|