InterceptorBinding.java :  » J2EE » ow2-easybeans » org » ow2 » easybeans » deployment » xml » struct » Java Open Source

Java Open Source » J2EE » ow2 easybeans 
ow2 easybeans » org » ow2 » easybeans » deployment » xml » struct » InterceptorBinding.java
/**
 * EasyBeans
 * Copyright (C) 2006 Bull S.A.S.
 * Contact: easybeans@ow2.org
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 * USA
 *
 * --------------------------------------------------------------------------
 * $Id: InterceptorBinding.java 2059 2007-11-22 17:22:33Z benoitf $
 * --------------------------------------------------------------------------
 */

package org.ow2.easybeans.deployment.xml.struct;

import java.util.ArrayList;
import java.util.List;

import org.ow2.easybeans.deployment.xml.struct.common.MethodDD;

/**
 * This class represents the <interceptor-binding> element.
 * @author Florent Benoit
 */
public class InterceptorBinding {
    /**
     * Name of this element.
     */
    public static final String NAME = "interceptor-binding";


    /**
     * Name of the EJB. (if * = default interceptor: apply to all beans)
     */
    private String ejbName = null;

    /**
     * List of interceptor-class.
     */
    private List<String> interceptorClassList = null;

    /**
     * Interceptor-order element.<br>
     * (which contains a list of interceptor-classList)
     */
    private List<String> orderInterceptorClassList = null;

    /**
     * Exclude the default interceptors for this bean ?
     */
    private boolean excludeDefaultInterceptors = false;

    /**
     * Exclude class interceptors for a method on a bean.
     */
    private boolean excludeClassInterceptors = false;

    /**
     * setExcludeClassInterceptors() called.
     */
    private boolean excludeClassInterceptorsCalled = false;


    /**
     * setExcludeClassInterceptors() called.
     */
    private boolean excludeDefaultInterceptorsCalled = false;

    /**
     * Method on which apply the interceptors.
     */
    private MethodDD method = null;

    /**
     * Default constructor.<br>
     * orderInterceptorClassList is null by default.
     */
    public InterceptorBinding() {
        this.interceptorClassList = new ArrayList<String>();
    }


    /**
     * @return the name of the EJB.
     */
    public String getEjbName() {
        return ejbName;
    }


    /**
     * Sets the name of this ejb (or wildcard).
     * @param ejbName the name of the ejb.
     */
    public void setEjbName(final String ejbName) {
        this.ejbName = ejbName;
    }

    /**
     * @return the method element
     */
    public MethodDD getMethod() {
        return method;
    }

    /**
     * Method on which define the interceptors.
     * @param method the given method.
     */
    public void setMethod(final MethodDD method) {
        this.method = method;
    }


    /**
     * @return true if the class interceptors are excluded for the given method
     */
    public boolean isExcludeClassInterceptors() {
        return excludeClassInterceptors;
    }


    /**
     * Exclude or not class interceptors ?
     * @param excludeClassInterceptors true/false
     */
    public void setExcludeClassInterceptors(final boolean excludeClassInterceptors) {
        this.excludeClassInterceptors = excludeClassInterceptors;
        this.excludeClassInterceptorsCalled = true;
    }

    /**
     * @return true if method setExcludeClassInterceptors has been called (with false or true)
     */
    public boolean isExcludeClassInterceptorsCalled() {
        return excludeClassInterceptorsCalled;
    }


    /**
     * @return true if the default interceptors are excluded for the given bean
     */
    public boolean isExcludeDefaultInterceptors() {
        return excludeDefaultInterceptors;
    }

    /**
     * Exclude or not default interceptors ?
     * @param excludeDefaultInterceptors true/false
     */
    public void setExcludeDefaultInterceptors(final boolean excludeDefaultInterceptors) {
        this.excludeDefaultInterceptors = excludeDefaultInterceptors;
        this.excludeDefaultInterceptorsCalled = true;
    }

    /**
     * @return true if method setExcludeDefaultInterceptors has been called (with false or true)
     */
    public boolean isExcludeDefaultInterceptorsCalled() {
        return excludeDefaultInterceptorsCalled;
    }

    /**
     * @return list of the interceptor classes.
     */
    public List<String> getInterceptorClassList() {
        return interceptorClassList;
    }

    /**
     * @return list of ordered interceptor classes.
     */
    public List<String> getOrderInterceptorClassList() {
        return orderInterceptorClassList;
    }

    /**
     * Add the given interceptor to the list.
     * @param interceptorClassName the name of the interceptor's class
     */
    public void addInterceptorClass(final String interceptorClassName) {
        interceptorClassList.add(interceptorClassName);
    }

    /**
     * Add the given interceptor to the ordered list.
     * @param interceptorClassName the name of the interceptor's class
     */
    public synchronized void addOrderedInterceptorClass(final String interceptorClassName) {
        if (orderInterceptorClassList == null) {
            orderInterceptorClassList = new ArrayList<String>();
        }
        orderInterceptorClassList.add(interceptorClassName);
    }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.