/**
 * JOnAS: Java(TM) Open Application Server
 * Copyright (C) 2004 Bull S.A.
 * Contact: jonas-team@objectweb.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
 *
 * Initial developer: Florent BENOIT
 * --------------------------------------------------------------------------
 * $Id$
 * --------------------------------------------------------------------------
 */

package org.objectweb.jonas_web.deployment.api;

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

import org.objectweb.jonas_lib.deployment.api.SecurityRoleRefDesc;
import org.objectweb.jonas_lib.deployment.xml.SecurityRoleRef;

import org.objectweb.jonas_web.deployment.xml.Servlet;
/**
 * Defines a Servlet object.
 * It manages classname and security-role-ref
 * @author Florent Benoit
 */

public class ServletDesc {

    /**
     * Internal servlet object
     */
    private Servlet servlet = null;

    /**
     * List of securityRoleRef
     */
    private List securityRoleRefDescList = null;



    /**
     * Constructor : Build a new Servlet object
     * @param servlet Servlet object
     */
    public ServletDesc(Servlet servlet) {
        this.servlet = servlet;
        securityRoleRefDescList = new ArrayList();
        for (Iterator it = servlet.getSecurityRoleRefList().iterator(); it.hasNext();) {
            SecurityRoleRef securityRoleRef = (SecurityRoleRef) it.next();
            SecurityRoleRefDesc securityRoleRefDesc =
                new SecurityRoleRefDesc(getServletName(), securityRoleRef, false);
            securityRoleRefDescList.add(securityRoleRefDesc);
        }

    }

    /**
     * @return the name of the servlet
     */
    public String getServletName() {
        return servlet.getServletName();
    }

    /**
     * @return the class of the servlet
     */
    public String getServletClass() {
        return servlet.getServletClass();
    }


    /**
     * Gets the security-role-ref
     * @return the security-role-ref
     */
    public List getSecurityRoleRefList() {
        return securityRoleRefDescList;
    }

}
