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: * Message Destination Reference Metadata
030: *
031: * @author <a href="mailto:adrian@jboss.com">Adrian Brock</a>.
032: * @version $Revision: 57209 $
033: */
034: public class MessageDestinationRefMetaData extends MetaData {
035: // Constants -----------------------------------------------------
036:
037: public static final int CONSUMES = 1;
038: public static final int PRODUCES = 2;
039: public static final int CONSUMESPRODUCES = 3;
040:
041: // Attributes ----------------------------------------------------
042:
043: /** The reference name, it is unique by schema validation */
044: private String refName;
045:
046: /** The type of destination */
047: private String type;
048:
049: /** The usage of destination */
050: private int usage;
051:
052: /** The link */
053: private String link;
054:
055: /** The jndi name */
056: private String jndiName;
057:
058: // Static --------------------------------------------------------
059:
060: // Constructors --------------------------------------------------
061:
062: public MessageDestinationRefMetaData() {
063: }
064:
065: // Public --------------------------------------------------------
066:
067: public String getRefName() {
068: return refName;
069: }
070:
071: public String getType() {
072: return type;
073: }
074:
075: public int getUsage() {
076: return usage;
077: }
078:
079: public String getLink() {
080: return link;
081: }
082:
083: public String getJNDIName() {
084: return jndiName;
085: }
086:
087: public void importEjbJarXml(Element element)
088: throws DeploymentException {
089: refName = getElementContent(getUniqueChild(element,
090: "message-destination-ref-name"));
091:
092: type = getElementContent(getUniqueChild(element,
093: "message-destination-type"));
094:
095: String usageValue = getElementContent(getUniqueChild(element,
096: "message-destination-usage"));
097: usageValue = usageValue.trim();
098: if (usageValue.equalsIgnoreCase("Consumes"))
099: usage = CONSUMES;
100: else if (usageValue.equalsIgnoreCase("Produces"))
101: usage = PRODUCES;
102: else if (usageValue.equalsIgnoreCase("ConsumesProduces"))
103: usage = CONSUMESPRODUCES;
104: else
105: throw new DeploymentException(
106: "message-destination-usage should be one of Consumes, Produces, ConsumesProduces");
107:
108: Element child = getOptionalChild(element,
109: "message-destination-link");
110: if (child != null)
111: link = getElementContent(child);
112: }
113:
114: public void importJbossXml(Element element)
115: throws DeploymentException {
116: jndiName = getElementContent(getUniqueChild(element,
117: "jndi-name"));
118: }
119:
120: // Package protected ---------------------------------------------
121:
122: // Protected -----------------------------------------------------
123:
124: // Private -------------------------------------------------------
125:
126: // Inner classes -------------------------------------------------
127: }
|