001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.openejb.test.interceptor;
017:
018: import javax.annotation.PostConstruct;
019: import javax.annotation.PreDestroy;
020: import javax.ejb.PostActivate;
021: import javax.ejb.PrePassivate;
022: import javax.interceptor.AroundInvoke;
023: import javax.interceptor.InvocationContext;
024:
025: /**
026: * @author <a href="mailto:goyathlay.geronimo@gmail.com">Prasad Kashyap</a>
027: *
028: * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 $
029: */
030: public class ClassInterceptor extends SuperClassInterceptor {
031:
032: /**
033: * The interceptor method.
034: * This should intercept all business methods in this bean class
035: * except those annotated with <code>@ExcludeClassInterceptors</code>
036: *
037: * @param ctx - InvocationContext
038: *
039: * @return - the result of the next method invoked. If a method returns void, proceed returns null.
040: * For lifecycle callback interceptor methods, if there is no callback method defined on the bean class,
041: * the invocation of proceed in the last interceptor method in the chain is a no-op, and null is returned.
042: * If there is more than one such interceptor method, the invocation of proceed causes the container to execute those methods in order.
043: *
044: * @throws runtime exceptions or application exceptions that are allowed in the throws clause of the business method.
045: */
046: @AroundInvoke
047: public Object classInterceptor(InvocationContext ctx)
048: throws Exception {
049: Interceptor.profile(ctx, "classInterceptor");
050: return ctx.proceed();
051: }
052:
053: /**
054: * The interceptor method.
055: * This should intercept postConstruct of the bean
056: *
057: * @param ctx - InvocationContext
058: *
059: * @throws runtime exceptions.
060: */
061: @PostConstruct
062: public void classInterceptorPostConstruct(InvocationContext ctx)
063: throws Exception {
064: Interceptor.profile(ctx, "classInterceptorPostConstruct");
065: ctx.proceed();
066: return;
067: }
068:
069: /**
070: * The interceptor method.
071: * This should intercept postActivate of the bean
072: *
073: * @param ctx - InvocationContext
074: *
075: * @throws runtime exceptions.
076: */
077: @PostActivate
078: public void classInterceptorPostActivate(InvocationContext ctx)
079: throws Exception {
080: Interceptor.profile(ctx, "classInterceptorPostActivate");
081: ctx.proceed();
082: return;
083: }
084:
085: /**
086: * The interceptor method.
087: * This should intercept prePassivate of the bean.
088: *
089: * @param ctx - InvocationContext
090: *
091: * @throws runtime exceptions.
092: */
093: @PrePassivate
094: public void classInterceptorPrePassivate(InvocationContext ctx)
095: throws Exception {
096: Interceptor.profile(ctx, "classInterceptorPrePassivate");
097: ctx.proceed();
098: return;
099: }
100:
101: /**
102: * The interceptor method.
103: * This should intercept preDestroy of the bean.
104: *
105: * @param ctx - InvocationContext
106: *
107: * @throws runtime exceptions.
108: */
109: @PreDestroy
110: public void classInterceptorPreDestroy(InvocationContext ctx)
111: throws Exception {
112: Interceptor.profile(ctx, "classInterceptorPreDestroy");
113: ctx.proceed();
114: return;
115: }
116:
117: }
|