KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > metadata > ResourceEnvRefMetaData


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.metadata;
23
24 import org.w3c.dom.Element JavaDoc;
25
26 import org.jboss.deployment.DeploymentException;
27
28 /**
29  * The meta data information for a resource-env-ref element.
30  * The resource-env-ref element contains a declaration of an enterprise
31  * bean�s reference to an administered object associated with a resource
32  * in the enterprise bean�s environment. It consists of an optional
33  * description, the resource environment reference name, and an indication
34  * of the resource environment reference type expected by the enterprise
35  * bean code.
36  * <p/>
37  * Used in: entity, message-driven and session
38  * <p/>
39  * Example:
40  * <resource-env-ref>
41  * <resource-env-ref-name>jms/StockQueue</resource-env-ref-name>
42  * <resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
43  * </resource-env-ref>
44  *
45  * @author <a HREF="mailto:Scott_Stark@displayscape.com">Scott Stark</a>.
46  * @version $Revision: 57300 $
47  */

48 public class ResourceEnvRefMetaData extends Ref
49 {
50    /**
51     * The (application-client|ejb-jar|web-app)/../resource-env-ref/resource-env-ref-name
52     * element.
53     * The resource-env-ref-name element specifies the name of a resource
54     * environment reference; its value is the environment entry name used in
55     * the enterprise bean code. The name is a JNDI name relative to the
56     * java:comp/env context and must be unique within an enterprise bean.
57     */

58    private String JavaDoc refName;
59    /**
60     * The (jboss-client|jboss|jboss-web)/../resource-env-ref/jndi-name element
61     * value. This is the jndi name of the deployed resource.
62     */

63    private String JavaDoc jndiName;
64    /**
65     * The (application-client|ejb-jar|web-app)/../resource-env-ref/resource-env-ref-type
66     * java element. The res-type element specifies the Java class or interface
67     * of a resource environment reference
68     */

69    private String JavaDoc type;
70    /** The message-destination-ref-name/message-destination-link
71     */

72    private String JavaDoc link;
73    /** The resource-ref/res-auth value.
74    The res-auth element specifies whether the enterprise bean code signs
75    on programmatically to the resource manager, or whether the Container
76    will sign on to the resource manager on behalf of the enterprise bean.
77    In the latter case, the Container uses information that is supplied by
78    the Deployer.
79    The value of this element must be one of the following for EJB2.0,
80    Servlet 2.3:
81    <res-auth>Application</res-auth>
82    <res-auth>Container</res-auth>
83    */

84    private boolean containerAuth;
85    /** The resource-ref/res-sharing-scope value
86    The res-sharing-scope element specifies whether connections obtained
87    through the given resource manager connection factory reference can
88    be shared. The value of this element, if specified, must be one of the
89    two following:
90    <res-sharing-scope>Shareable</res-sharing-scope>
91    <res-sharing-scope>Unshareable</res-sharing-scope>
92    The default value is Shareable.
93    */

94   private boolean isShareable;
95
96    public String JavaDoc getJndiName()
97    {
98       return jndiName;
99    }
100
101    public void setJndiName(String JavaDoc jndiName)
102    {
103       this.jndiName = jndiName;
104    }
105
106    public String JavaDoc getLink()
107    {
108       return link;
109    }
110
111    public void setLink(String JavaDoc link)
112    {
113       this.link = link;
114    }
115
116    public String JavaDoc getRefName()
117    {
118       return refName;
119    }
120
121    public void setRefName(String JavaDoc refName)
122    {
123       this.refName = refName;
124    }
125
126    public String JavaDoc getType()
127    {
128       return type;
129    }
130
131    public void setType(String JavaDoc type)
132    {
133       this.type = type;
134    }
135
136    public boolean isContainerAuth()
137    {
138       return containerAuth;
139    }
140    public void setContainerAuth(boolean flag)
141    {
142       this.containerAuth = flag;
143    }
144    public void setContainerAuth(String JavaDoc value)
145    {
146       this.containerAuth = value.equalsIgnoreCase("Container");
147    }
148
149    public boolean isShareable()
150    {
151       return isShareable;
152    }
153    public void setSharable(String JavaDoc value)
154    {
155       this.isShareable = value.equalsIgnoreCase("Shareable");
156    }
157
158    /**
159     * Parse the application-client|ejb-jar|web-app child element
160     *
161     * @param element - the resource-env-ref or message-destination-ref element
162     */

163    public void importEjbJarXml(Element JavaDoc element) throws DeploymentException
164    {
165       String JavaDoc name = element.getLocalName();
166       if (name.equals("resource-env-ref"))
167       {
168          refName = MetaData.getElementContent(MetaData.getUniqueChild(element, "resource-env-ref-name"));
169          type = MetaData.getElementContent(MetaData.getUniqueChild(element, "resource-env-ref-type"));
170       }
171       else if( name.equals("message-destination-ref") )
172       {
173          refName = MetaData.getElementContent(MetaData.getUniqueChild(element, "message-destination-ref-name"));
174          type = MetaData.getElementContent(MetaData.getUniqueChild(element, "message-destination-type"));
175          link = MetaData.getElementContent(MetaData.getOptionalChild(element, "message-destination-link"));
176          // Don't care about the message-destination-usage
177
}
178    }
179
180    /**
181     * Parse the jboss child element
182     *
183     * @param element - the resource-env-ref element
184     */

185    public void importJbossXml(Element JavaDoc element) throws DeploymentException
186    {
187       jndiName = MetaData.getElementContent(MetaData.getUniqueChild(element, "jndi-name"));
188    }
189 }
190
Popular Tags