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: InterceptorBinding.java 2059 2007-11-22 17:22:33Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.deployment.xml.struct;
025:
026: import java.util.ArrayList;
027: import java.util.List;
028:
029: import org.ow2.easybeans.deployment.xml.struct.common.MethodDD;
030:
031: /**
032: * This class represents the <interceptor-binding> element.
033: * @author Florent Benoit
034: */
035: public class InterceptorBinding {
036: /**
037: * Name of this element.
038: */
039: public static final String NAME = "interceptor-binding";
040:
041: /**
042: * Name of the EJB. (if * = default interceptor: apply to all beans)
043: */
044: private String ejbName = null;
045:
046: /**
047: * List of interceptor-class.
048: */
049: private List<String> interceptorClassList = null;
050:
051: /**
052: * Interceptor-order element.<br>
053: * (which contains a list of interceptor-classList)
054: */
055: private List<String> orderInterceptorClassList = null;
056:
057: /**
058: * Exclude the default interceptors for this bean ?
059: */
060: private boolean excludeDefaultInterceptors = false;
061:
062: /**
063: * Exclude class interceptors for a method on a bean.
064: */
065: private boolean excludeClassInterceptors = false;
066:
067: /**
068: * setExcludeClassInterceptors() called.
069: */
070: private boolean excludeClassInterceptorsCalled = false;
071:
072: /**
073: * setExcludeClassInterceptors() called.
074: */
075: private boolean excludeDefaultInterceptorsCalled = false;
076:
077: /**
078: * Method on which apply the interceptors.
079: */
080: private MethodDD method = null;
081:
082: /**
083: * Default constructor.<br>
084: * orderInterceptorClassList is null by default.
085: */
086: public InterceptorBinding() {
087: this .interceptorClassList = new ArrayList<String>();
088: }
089:
090: /**
091: * @return the name of the EJB.
092: */
093: public String getEjbName() {
094: return ejbName;
095: }
096:
097: /**
098: * Sets the name of this ejb (or wildcard).
099: * @param ejbName the name of the ejb.
100: */
101: public void setEjbName(final String ejbName) {
102: this .ejbName = ejbName;
103: }
104:
105: /**
106: * @return the method element
107: */
108: public MethodDD getMethod() {
109: return method;
110: }
111:
112: /**
113: * Method on which define the interceptors.
114: * @param method the given method.
115: */
116: public void setMethod(final MethodDD method) {
117: this .method = method;
118: }
119:
120: /**
121: * @return true if the class interceptors are excluded for the given method
122: */
123: public boolean isExcludeClassInterceptors() {
124: return excludeClassInterceptors;
125: }
126:
127: /**
128: * Exclude or not class interceptors ?
129: * @param excludeClassInterceptors true/false
130: */
131: public void setExcludeClassInterceptors(
132: final boolean excludeClassInterceptors) {
133: this .excludeClassInterceptors = excludeClassInterceptors;
134: this .excludeClassInterceptorsCalled = true;
135: }
136:
137: /**
138: * @return true if method setExcludeClassInterceptors has been called (with false or true)
139: */
140: public boolean isExcludeClassInterceptorsCalled() {
141: return excludeClassInterceptorsCalled;
142: }
143:
144: /**
145: * @return true if the default interceptors are excluded for the given bean
146: */
147: public boolean isExcludeDefaultInterceptors() {
148: return excludeDefaultInterceptors;
149: }
150:
151: /**
152: * Exclude or not default interceptors ?
153: * @param excludeDefaultInterceptors true/false
154: */
155: public void setExcludeDefaultInterceptors(
156: final boolean excludeDefaultInterceptors) {
157: this .excludeDefaultInterceptors = excludeDefaultInterceptors;
158: this .excludeDefaultInterceptorsCalled = true;
159: }
160:
161: /**
162: * @return true if method setExcludeDefaultInterceptors has been called (with false or true)
163: */
164: public boolean isExcludeDefaultInterceptorsCalled() {
165: return excludeDefaultInterceptorsCalled;
166: }
167:
168: /**
169: * @return list of the interceptor classes.
170: */
171: public List<String> getInterceptorClassList() {
172: return interceptorClassList;
173: }
174:
175: /**
176: * @return list of ordered interceptor classes.
177: */
178: public List<String> getOrderInterceptorClassList() {
179: return orderInterceptorClassList;
180: }
181:
182: /**
183: * Add the given interceptor to the list.
184: * @param interceptorClassName the name of the interceptor's class
185: */
186: public void addInterceptorClass(final String interceptorClassName) {
187: interceptorClassList.add(interceptorClassName);
188: }
189:
190: /**
191: * Add the given interceptor to the ordered list.
192: * @param interceptorClassName the name of the interceptor's class
193: */
194: public synchronized void addOrderedInterceptorClass(
195: final String interceptorClassName) {
196: if (orderInterceptorClassList == null) {
197: orderInterceptorClassList = new ArrayList<String>();
198: }
199: orderInterceptorClassList.add(interceptorClassName);
200: }
201:
202: }
|