001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.metadata;
023:
024: import org.w3c.dom.Element;
025:
026: import org.jboss.deployment.DeploymentException;
027:
028: /**
029: * The meta data information for a resource-env-ref element.
030: * The resource-env-ref element contains a declaration of an enterprise
031: * bean�s reference to an administered object associated with a resource
032: * in the enterprise bean�s environment. It consists of an optional
033: * description, the resource environment reference name, and an indication
034: * of the resource environment reference type expected by the enterprise
035: * bean code.
036: * <p/>
037: * Used in: entity, message-driven and session
038: * <p/>
039: * Example:
040: * <resource-env-ref>
041: * <resource-env-ref-name>jms/StockQueue</resource-env-ref-name>
042: * <resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
043: * </resource-env-ref>
044: *
045: * @author <a href="mailto:Scott_Stark@displayscape.com">Scott Stark</a>.
046: * @version $Revision: 57209 $
047: */
048: public class ResourceEnvRefMetaData extends MetaData {
049: /**
050: * The (application-client|ejb-jar|web-app)/../resource-env-ref/resource-env-ref-name
051: * element.
052: * The resource-env-ref-name element specifies the name of a resource
053: * environment reference; its value is the environment entry name used in
054: * the enterprise bean code. The name is a JNDI name relative to the
055: * java:comp/env context and must be unique within an enterprise bean.
056: */
057: private String refName;
058: /**
059: * The (jboss-client|jboss|jboss-web)/../resource-env-ref/jndi-name element
060: * value. This is the jndi name of the deployed resource.
061: */
062: private String jndiName;
063: /**
064: * The (application-client|ejb-jar|web-app)/../resource-env-ref/resource-env-ref-type
065: * java element. The res-type element specifies the Java class or interface
066: * of a resource environment reference
067: */
068: private String type;
069: /** The message-destination-ref-name/message-destination-link
070: */
071: private String link;
072:
073: public String getRefName() {
074: return refName;
075: }
076:
077: public String getJndiName() {
078: return jndiName;
079: }
080:
081: public String getType() {
082: return type;
083: }
084:
085: public String getLink() {
086: return link;
087: }
088:
089: /**
090: * Parse the application-client|ejb-jar|web-app child element
091: *
092: * @param element - the resource-env-ref or message-destination-ref element
093: */
094: public void importEjbJarXml(Element element)
095: throws DeploymentException {
096: String name = element.getLocalName();
097: if (name.equals("resource-env-ref")) {
098: refName = getElementContent(getUniqueChild(element,
099: "resource-env-ref-name"));
100: type = getElementContent(getUniqueChild(element,
101: "resource-env-ref-type"));
102: } else if (name.equals("message-destination-ref")) {
103: refName = getElementContent(getUniqueChild(element,
104: "message-destination-ref-name"));
105: type = getElementContent(getUniqueChild(element,
106: "message-destination-type"));
107: link = getElementContent(getOptionalChild(element,
108: "message-destination-link"));
109: // Don't care about the message-destination-usage
110: }
111: }
112:
113: /**
114: * Parse the jboss child element
115: *
116: * @param element - the resource-env-ref element
117: */
118: public void importJbossXml(Element element)
119: throws DeploymentException {
120: jndiName = getElementContent(getUniqueChild(element,
121: "jndi-name"));
122: }
123: }
|