KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfox > ejb > meta > ResourceRefDescriptor


1 /* JFox, the OpenSource J2EE Application Server
2  *
3  * Distributable under GNU LGPL license by gun.org
4  * more details please visit http://www.huihoo.org/jfox
5  */

6 package org.jfox.ejb.meta;
7
8 import org.jfox.ioc.util.XMLUtils;
9 import org.w3c.dom.Node JavaDoc;
10
11 /**
12  * @author <a HREF="mailto:young_yy@hotmail.com">Young Yang</a>
13  */

14
15 public class ResourceRefDescriptor extends Descriptor {
16
17     public static final String JavaDoc APPLICATION_AUTHORIZATION = "Application";
18     public static final String JavaDoc CONTAINER_AUTHORIZATION = "Container";
19     private String JavaDoc refName;
20     private String JavaDoc type;
21     private String JavaDoc auth;
22 // private String jndiName;
23

24     public ResourceRefDescriptor() {
25
26     }
27
28     public void processXML(Node JavaDoc node) throws EJBDescriptionException {
29         super.processXML(node);
30         setRefName(XMLUtils.getChildNodeValueOf(node, "res-ref-name"));
31         setType(XMLUtils.getChildNodeValueOf(node, "res-type"));
32         setAuthorization(XMLUtils.getChildNodeValueOf(node, "res-auth"));
33     }
34
35     public boolean equals(Object JavaDoc obj) {
36         if(obj instanceof ResourceRefDescriptor)
37             return refName.equals(((ResourceRefDescriptor) obj).refName);
38         else
39             return false;
40     }
41
42     public String JavaDoc getAuthorization() {
43         return auth;
44     }
45
46     /**
47      * use refName as the jndi name for simpty
48      *
49      * @return
50      */

51     public String JavaDoc getJndiName() {
52 /*
53     if (jndiName == null)
54       jndiName = "";
55     return jndiName;
56 */

57         return refName;
58     }
59
60     public String JavaDoc getRefName() {
61         return refName;
62     }
63
64     public String JavaDoc getType() {
65         return type;
66     }
67
68     public int hashCode() {
69         return refName.hashCode();
70     }
71
72     public boolean isResolved() {
73 // return jndiName != null && !"".equals(jndiName);
74
return refName != null && !"".equals(refName);
75     }
76
77     public void setAuthorization(String JavaDoc s) {
78         if(!"Application".equals(s) && !"Container".equals(s)) {
79             throw new IllegalArgumentException JavaDoc("res-auth must be one of \"Application\" and \"Container\"");
80         }
81         else {
82             auth = s;
83             return;
84         }
85     }
86
87 /*
88   public void setJndiName(String s) {
89     jndiName = s;
90   }
91 */

92
93     public void setRefName(String JavaDoc s) {
94         refName = s;
95     }
96
97     public void setType(String JavaDoc s) {
98         type = s;
99     }
100
101     public String JavaDoc toString() {
102         return "res-ref-name: " + getRefName() + "\n" + "res-type: " + getType() + "\n" + "jndi-name: " + getJndiName() + "\n";
103     }
104
105     public static void main(String JavaDoc[] args) {
106
107     }
108 }
109
110
Popular Tags