Subversion Repositories bacoAlunos

Rev

Blame | Compare with Previous | Last modification | View Log | RSS feed

/*
 BERSERK - a BusinEss Runtime and SEcurity Resources Kit
 Copyright (C) 2003 Goncalo Luiz

 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 (at your option) 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

 To contact Goncalo Luiz use the following e-mail address (use an @ instead of the _):
 gedl_mega.ist.utl.pt
 */

/*
 * Created on 1/Out/2003, 14:37:47
 *
 * By Goncalo Luiz gedl [AT] rnl [DOT] ist [DOT] utl [DOT] pt
 */

package pt.utl.ist.berserk.logic.serviceManager;
import java.util.ArrayList;
import java.util.List;

import pt.utl.ist.berserk.Definition;
/**
 * A configuration of a particular service. Provides the <code>addChain</code>
 * method.
 *
 * @author Goncalo Luiz gedl [AT] rnl [DOT] ist [DOT] utl [DOT] pt
 *
 *
 * Created at 1/Out/2003, 14:37:47
 *  
 */

public class ServiceDefinition extends Definition implements IServiceDefinition
{
    private 1.5.0/docs/api/java/lang/String.html">String name;
    private 1.5.0/docs/api/java/lang/Class.html">Class implementationClass;
    private 1.5.0/docs/api/java/lang/Boolean.html">Boolean isTransactional;
    private 5+0%2Fdocs%2Fapi+List">List filterChains;
    private 1.5.0/docs/api/java/lang/String.html">String defaultMethod;

    public ServiceDefinition()
    {
        this.filterChains = new 1.5.0/docs/api/java/util/ArrayList.html">ArrayList();
    }
    public 1.5.0/docs/api/java/lang/Class.html">Class getImplementationClass()
    {
        return this.implementationClass;
    }
    public 1.5.0/docs/api/java/lang/String.html">String getName()
    {
        return this.name;
    }
    public 1.5.0/docs/api/java/lang/Boolean.html">Boolean getIsTransactional()
    {
        return this.isTransactional;
    }

    public void setImplementationClass(1.5.0/docs/api/java/lang/Class.html">Class class1)
    {
        this.implementationClass = class1;
    }
    public void setName(1.5.0/docs/api/java/lang/String.html">String string)
    {
        this.name = string;
    }
    public void setIsTransactional(1.5.0/docs/api/java/lang/Boolean.html">Boolean boolean1)
    {
        this.isTransactional = boolean1;
    }
    /**
     * Processes the object and gives a text human-readable version of it.
     *
     * @return the text-based representation of all object's fields
     */

    public 1.5.0/docs/api/java/lang/String.html">String toString()
    {
        1.5.0/docs/api/java/lang/String.html">String result = "[ServiceDefinition ";
        result += "Name=" + this.getName() + "\n";
        result += "Description=" + this.getDescription() + "\n";
        result += "DefaultMethod=" + this.getDefaultMethod() + "\n";
        result += "ImplementationClass=" + this.getImplementationClass() + "\n";
        result += "Transactional=" + this.getIsTransactional() + "\n";
        result += "FilterChains=" + this.getFilterChains() + "]";
        return result;
    }
   
    public 5+0%2Fdocs%2Fapi+List">List getFilterChains()
    {
        return this.filterChains;
    }
    public void setFilterChains(5+0%2Fdocs%2Fapi+List">List list)
    {
        if (list == null)
            this.filterChains = new 1.5.0/docs/api/java/util/ArrayList.html">ArrayList();
        this.filterChains = list;
    }
    /**
     * Adds a filter chain to this service's filter chains list. No duplicates
     * will be checked, so be sure to add only one time.Also receives the name of the method this chain will filter. If you want
     * a chain to filter all services you must add with all method names.
     *
     * @param association
     *            the association between this service, a method and a chain
     */

    public void addMethodChainAssociation(IMethodChainAssociation association)
    {
       
        if (this.filterChains == null)
            this.filterChains = new 1.5.0/docs/api/java/util/ArrayList.html">ArrayList();
        association.setServiceDefinition(this);
        1.5.0/docs/api/java/lang/String.html">String method = association.getMethod();
        if (method == null)
            method = this.getDefaultMethod();
        this.filterChains.add(association);
    }

    public 1.5.0/docs/api/java/lang/String.html">String getDefaultMethod()
    {
        1.5.0/docs/api/java/lang/String.html">String method = this.defaultMethod;
        if (method == null)
            method = "run"; // TODO: the default method. Maybe this could be externalized
       
        return method;
    }

    public void setDefaultMethod(1.5.0/docs/api/java/lang/String.html">String defaultMethod)
    {
        this.defaultMethod = defaultMethod;
    }
}