/*
 * JOnAS: Java(TM) Open Application Server
 * Copyright (C) 1999 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(s): ____________________________________.
 * Contributor(s): Lutris Technologies Inc http://www.lutris.com
 *
 * --------------------------------------------------------------------------
 * $Id$
 * --------------------------------------------------------------------------
*/


package org.objectweb.jonas_ejb.deployment.api;

import java.lang.Class;

import org.objectweb.jonas_ejb.deployment.xml.EjbRef;
import org.objectweb.jonas_ejb.deployment.xml.JonasEjbRef;

/**
 * Class that represents an ejb-ref and jonas-ejb-ref tags.
 * Only ejb-name and jndi-name are used in Jonas.
 * @author Christophe Ney
 */
public class EjbRefDesc {

    String name;
    String ejblink;
    String jndiName;

    /**
     * Package protected constructor used by API.
     * The JonasEjbRef may be null when an ejb-link is specified.
     */
    EjbRefDesc(EjbRef bRef, JonasEjbRef jBRef) throws DeploymentDescException {
        name = bRef.getEjbRefName().getValue();
	ejblink = (bRef.getEjbLink() != null) ? bRef.getEjbLink().getValue() : null;
        jndiName = (jBRef != null) ? jBRef.getJndiName().getValue() : null;
    }

    /**
     * Get the name of the ejb-ref 
     * @return String representation of the name.
     */
    public String getName() {
            return name;
    }

    /**
     * Get the ejb-link.
     * The value may be null when a jonas-ejb-ref is specified.
     * @return String representation of the ejb-link
     */
    public String getEjbLink() {
            return ejblink;
    }

    /**
     * Get the jndi name of the ejb-ref.
     * The value may be null when an ejb-link is specified.
     * @return String representation of the JNDI name
     */
    public String getJndiName() {
        return jndiName;
    }
    
    /**
     * String representation of the object for test purpose
     * @return String representation of this object
     */
    public String toString() {
        StringBuffer ret = new StringBuffer();
        ret.append("\ngetName()="+getName());
        ret.append("\ngetEjbLink()="+getEjbLink());
        ret.append("\ngetJndiName()="+getJndiName());
        return ret.toString();
    }
    
    
}

