/*
 * JBoss, Home of Professional Open Source
 * Copyright 2005, JBoss Inc., and individual contributors as indicated
 * by the @authors tag. See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * This 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 software 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 software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.jboss.metadata;

import org.w3c.dom.Element;

import org.jboss.deployment.DeploymentException;

/** The meta data information for a resource-env-ref element.
The resource-env-ref element contains a declaration of an enterprise
beans reference to an administered object associated with a resource
in the enterprise beans environment. It consists of an optional
description, the resource environment reference name, and an indication
of the resource environment reference type expected by the enterprise
bean code.

Used in: entity, message-driven and session

Example:
<resource-env-ref>
    <resource-env-ref-name>jms/StockQueue</resource-env-ref-name>
    <resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
</resource-env-ref>

@author <a href="mailto:Scott_Stark@displayscape.com">Scott Stark</a>.
@version $Revision: 1.4.4.2 $
*/
public class ResourceEnvRefMetaData extends MetaData
{
    /** The ejb-jar/../resource-env-ref/resource-env-ref-name element.
    The resource-env-ref-name element specifies the name of a resource
    environment reference; its value is the environment entry name used in
    the enterprise bean code. The name is a JNDI name relative to the
    java:comp/env context and must be unique within an enterprise bean.
    */
	private String refName;
    /** The jboss/../resource-env-ref/jndi-name element value. This is the
      jndi name of the deployed resource.
     */
    private String jndiName;
    /** The ejb-jar/../resource-env-ref/resource-env-ref-type java element.
     The res-type element specifies the Java class or interface of a resource
     environment reference
     */
    private String type;
	
	public String getRefName() { return refName; }
    public String getJndiName() { return jndiName; }
	public String getType() { return type; }

    /** Parse the ejb-jar child element
     @param element, the resource-env-ref element
     */
    public void importEjbJarXml(Element element) throws DeploymentException
    {
		refName = getElementContent(getUniqueChild(element, "resource-env-ref-name"));
		type = getElementContent(getUniqueChild(element, "resource-env-ref-type"));
	}

    /** Parse the jboss child element
     @param element, the resource-env-ref element
     */
	public void importJbossXml(Element element) throws DeploymentException
    {
        jndiName = getElementContent(getUniqueChild(element, "jndi-name"));
	}
}
