KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfox > ioc > deploy > ComponentDescriptor


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
7 package org.jfox.ioc.deploy;
8
9 import java.util.ArrayList JavaDoc;
10 import java.util.Iterator JavaDoc;
11 import java.util.List JavaDoc;
12
13 import org.jfox.ioc.ComponentMeta;
14 import org.jfox.ioc.deployment.Descriptor;
15 import org.jfox.ioc.util.XMLUtils;
16 import org.w3c.dom.Element JavaDoc;
17 import org.w3c.dom.Node JavaDoc;
18
19 /**
20  * @author <a HREF="mailto:young_yy@hotmail.com">Young Yang</a>
21  */

22
23 public class ComponentDescriptor implements Descriptor {
24     private String JavaDoc desc;
25     private String JavaDoc implementation;
26     private String JavaDoc name = "";
27     private boolean singleton = ComponentMeta.DEFAULT_SINGLETON;
28     private boolean typeSingleton = ComponentMeta.DEFAULT_TYPE_SINGLETON;
29     private ConstructorDescriptor constructor;
30     private List JavaDoc properties = new ArrayList JavaDoc();
31
32     private ComponentModuleDescriptor componentModuleDescriptor;
33
34     public ComponentDescriptor(ComponentModuleDescriptor componentModuleDescriptor) {
35         this.componentModuleDescriptor = componentModuleDescriptor;
36     }
37
38     public void processXML(Node JavaDoc node) throws ComponentDescriptionException {
39         setDescription(XMLUtils.getChildNodeValueOf(node, "description"));
40         setName(XMLUtils.getChildNodeValueOf(node, "name"));
41         setImplementation(XMLUtils.getChildNodeValueOf(node, "implementation"));
42         setSingleton(XMLUtils.getChildNodeValueOf(node, "singleton"));
43         setTypeSingleton(XMLUtils.getChildNodeValueOf(node, "type-singleton"));
44         Node JavaDoc constructorNode = XMLUtils.getChildNodeOf(node, "constructor");
45         if(constructorNode != null) {
46             ConstructorDescriptor cd = new ConstructorDescriptor();
47             cd.processXML(constructorNode);
48             setConstructorDescriptor(cd);
49         }
50
51         Iterator JavaDoc it = XMLUtils.getElementsByTagName((Element JavaDoc) node, "property");
52         while(it.hasNext()) {
53             Node JavaDoc propertyNode = (Node JavaDoc) it.next();
54             PropertyDescriptor pd = new PropertyDescriptor();
55             pd.processXML(propertyNode);
56             addPropertyDescriptor(pd);
57         }
58     }
59
60     public String JavaDoc getDescription() {
61         return desc;
62     }
63
64     public void setDescription(String JavaDoc desc) {
65         this.desc = desc;
66     }
67
68     public String JavaDoc getImplementation() {
69         return implementation;
70     }
71
72     public void setImplementation(String JavaDoc componentImplementation) {
73         this.implementation = componentImplementation;
74     }
75
76     public String JavaDoc getName() {
77         return name;
78     }
79
80     public void setName(String JavaDoc name) {
81         if(name != null) this.name = name;
82     }
83
84     public boolean isSingleton() {
85         return singleton;
86     }
87
88     public void setSingleton(String JavaDoc singleton) {
89         if(singleton != null && !singleton.equals("")) {
90             if(singleton.equals("true") || singleton.equals("false")) {
91                 this.singleton = Boolean.valueOf(singleton).booleanValue();
92             }
93         }
94     }
95
96     public boolean isTypeSingleton() {
97         return typeSingleton;
98     }
99
100     public void setTypeSingleton(String JavaDoc typeSingleton) {
101         if(typeSingleton != null && !typeSingleton.equals("")) {
102             if(typeSingleton.equals("true") || typeSingleton.equals("false")) {
103                 this.typeSingleton = Boolean.valueOf(typeSingleton).booleanValue();
104             }
105         }
106     }
107
108     public int getPriority() {
109         return componentModuleDescriptor.getPriority();
110     }
111
112     public ConstructorDescriptor getConstructorDescriptor() {
113         return constructor;
114     }
115
116     public void setConstructorDescriptor(ConstructorDescriptor constructor) {
117         this.constructor = constructor;
118     }
119
120     public void addPropertyDescriptor(PropertyDescriptor pd) {
121         properties.add(pd);
122     }
123
124     public PropertyDescriptor[] getPropertyDescriptors() {
125         return (PropertyDescriptor[]) properties.toArray(new PropertyDescriptor[properties.size()]);
126     }
127
128     public String JavaDoc getModuleDescription() {
129         return componentModuleDescriptor.getDescription();
130     }
131
132     public static void main(String JavaDoc[] args) {
133
134     }
135
136 }
137
138
Popular Tags