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 DefaultInterceptor {
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 Exception runtime exceptions or application exceptions that are allowed in the throws clause of the business method.
045: */
046: @AroundInvoke
047: public Object defaultInterceptor(InvocationContext ctx)
048: throws Exception {
049: Interceptor.profile(ctx, "defaultInterceptor");
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 Exception runtime exceptions.
060: */
061: @PostConstruct
062: public void defaultInterceptorPostConstruct(InvocationContext ctx)
063: throws Exception {
064: Interceptor.profile(ctx, "defaultInterceptorPostConstruct");
065: ctx.proceed();
066: }
067:
068: /**
069: * The interceptor method.
070: * This should intercept postActivate of the bean
071: *
072: * @param ctx - InvocationContext
073: *
074: * @throws Exception runtime exceptions.
075: */
076: @PostActivate
077: public void defaultInterceptorPostActivate(InvocationContext ctx)
078: throws Exception {
079: Interceptor.profile(ctx, "defaultInterceptorPostActivate");
080: ctx.proceed();
081: }
082:
083: /**
084: * The interceptor method.
085: * This should intercept prePassivate of the bean.
086: *
087: * @param ctx - InvocationContext
088: *
089: * @throws Exception runtime exceptions.
090: */
091: @PrePassivate
092: public void defaultInterceptorPrePassivate(InvocationContext ctx)
093: throws Exception {
094: Interceptor.profile(ctx, "defaultInterceptorPrePassivate");
095: ctx.proceed();
096: }
097:
098: /**
099: * The interceptor method.
100: * This should intercept preDestroy of the bean.
101: *
102: * @param ctx - InvocationContext
103: *
104: * @throws Exception runtime exceptions.
105: */
106: @PreDestroy
107: public void defaultInterceptorPreDestroy(InvocationContext ctx)
108: throws Exception {
109: Interceptor.profile(ctx, "defaultInterceptorPreDestroy");
110: ctx.proceed();
111: }
112:
113: }
|