001: /**
002: * EasyBeans
003: * Copyright (C) 2006 Bull S.A.S.
004: * Contact: easybeans@ow2.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: SLSBClassInterceptorTest01.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.interceptororder;
025:
026: import java.util.List;
027:
028: import javax.ejb.Remote;
029: import javax.ejb.Stateless;
030: import javax.interceptor.ExcludeClassInterceptors;
031: import javax.interceptor.ExcludeDefaultInterceptors;
032: import javax.interceptor.Interceptors;
033:
034: import org.ow2.easybeans.tests.common.ejbs.base.ItfClassInterceptor;
035: import org.ow2.easybeans.tests.common.interceptors.business.order.PrintOrder01Interceptor;
036: import org.ow2.easybeans.tests.common.interceptors.business.order.PrintOrder02Interceptor;
037: import org.ow2.easybeans.tests.common.interceptors.business.order.PrintOrder03Interceptor;
038: import org.ow2.easybeans.tests.common.interceptors.business.order.PrintOrder04Interceptor;
039: import org.ow2.easybeans.tests.common.interceptors.business.order.PrintOrder06Interceptor;
040:
041: /**
042: * Is used to test if the container call the class interceptors in order.Each method
043: * in appends 0 in the array, the difference amog them is the way that the interceptors
044: * are called.
045: * This class has only one class interceptor.
046: * @author Gisele Pinheiro Souza
047: * @author Eduardo Studzinski E. de Castro
048: */
049: @Stateless(name="SLSBClassInterceptorTest01")
050: @Remote(ItfClassInterceptor.class)
051: @Interceptors({PrintOrder06Interceptor.class})
052: public class SLSBClassInterceptorTest01 implements
053: ItfClassInterceptor<Integer> {
054:
055: /**
056: * Appends an Integer with the value 0 in the par.
057: * This method has only class interceptors that must be call in order.
058: * @param par list used to append the value
059: * @return the list with modified
060: */
061: public List<Integer> withoutMethodInterceptor(
062: final List<Integer> par) {
063: par.add(ORDER);
064: return par;
065: }
066:
067: /**
068: * Appends an Integer with the value 0 in the par. This method has only
069: * class interceptors that must be call in order and the default
070: * interceptor(defined in the xml file) must not be executed
071: * @param par list used to append the value
072: * @return the list with modified
073: */
074: @ExcludeDefaultInterceptors
075: public List<Integer> withExcludeDefaultInterceptor(
076: final List<Integer> par) {
077: par.add(ORDER);
078: return par;
079: }
080:
081: /**
082: * Appends an Integer with the value 0 in the par.
083: * This method has the annotation ExcludeClassInterceptor, so the interceptors
084: * must not be executed.
085: * @param par list used to append the value
086: * @return the list with modified
087: */
088: @ExcludeClassInterceptors
089: public List<Integer> withExcludeClassInterceptor(
090: final List<Integer> par) {
091: par.add(ORDER);
092: return par;
093: }
094:
095: /**
096: * Appends an Integer with the value 0 in the par.
097: * This method has the annotation ExcludeClassInterceptor, so only the method
098: * interceptor must not be executed.
099: * @param par list used to append the value
100: * @return the list with modified
101: */
102: @ExcludeClassInterceptors
103: @Interceptors({PrintOrder01Interceptor.class})
104: public List<Integer> excludeClassAndOneMtd(final List<Integer> par) {
105: par.add(ORDER);
106: return par;
107: }
108:
109: /**
110: * Appends an Integer with the value 0 in the par. This method has the
111: * annotations ExcludeClassInterceptor and ExcludeDefaultInterceptor , so
112: * only the method interceptor must not be executed.
113: * @param par list used to append the value
114: * @return the list with modified
115: */
116: @ExcludeClassInterceptors
117: @ExcludeDefaultInterceptors
118: @Interceptors({PrintOrder01Interceptor.class,PrintOrder02Interceptor.class,PrintOrder03Interceptor.class,PrintOrder04Interceptor.class})
119: public List<Integer> excludeClassDefAndFourMtd(
120: final List<Integer> par) {
121: par.add(ORDER);
122: return par;
123: }
124:
125: /**
126: * Appends an Integer with the value 0 in the par.
127: * This method has the class interceptors and the method interceptor,
128: * so all interceptors must not be executed in order.
129: * @param par list used to append the value
130: * @return the list with modified
131: */
132: @Interceptors({PrintOrder01Interceptor.class})
133: public List<Integer> withOneMethodInterceptor(
134: final List<Integer> par) {
135: par.add(ORDER);
136: return par;
137: }
138:
139: /**
140: * Appends an Integer with the value 0 in the par.
141: * This method has the class interceptors and the method interceptors,
142: * so all interceptors must not be executed in order.
143: * @param par list used to append the value
144: * @return the list with modified
145: */
146: @Interceptors({PrintOrder01Interceptor.class,PrintOrder02Interceptor.class,PrintOrder03Interceptor.class})
147: public List<Integer> withThreeMethodInterceptor(
148: final List<Integer> par) {
149: par.add(ORDER);
150: return par;
151: }
152:
153: }
|