KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > dd > JBossDDObjectFactory


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.ejb3.dd;
8
9 import org.xml.sax.Attributes JavaDoc;
10 import org.jboss.logging.Logger;
11 import org.jboss.xb.binding.UnmarshallingContext;
12 import org.jboss.xb.binding.ObjectModelFactory;
13
14 /**
15  * Represents the jboss.xml deployment descriptor for the 2.1 schema
16  *
17  * @author <a HREF="mailto:bdecoste@jboss.com">William DeCoste</a>
18  * @version <tt>$Revision: 1.5.2.3 $</tt>
19  */

20 public class JBossDDObjectFactory implements ObjectModelFactory
21 {
22    private static final Logger log = Logger
23          .getLogger(JBossDDObjectFactory.class);
24
25    private EjbJarDD dd;
26
27    public JBossDDObjectFactory(EjbJarDD dd)
28    {
29       super();
30       this.dd = dd;
31    }
32
33    /**
34     * Return the root.
35     */

36    public Object JavaDoc newRoot(Object JavaDoc root, UnmarshallingContext navigator,
37          String JavaDoc namespaceURI, String JavaDoc localName, Attributes JavaDoc attrs)
38    {
39       return dd;
40    }
41
42    public Object JavaDoc completeRoot(Object JavaDoc root, UnmarshallingContext ctx,
43          String JavaDoc uri, String JavaDoc name)
44    {
45       return root;
46    }
47
48    // Methods discovered by introspection
49

50    /**
51     * Called when parsing of a new element started.
52     */

53    public Object JavaDoc newChild(EjbJarDD dd, UnmarshallingContext navigator,
54          String JavaDoc namespaceURI, String JavaDoc localName, Attributes JavaDoc attrs)
55    {
56       Object JavaDoc child = null;
57
58       if (localName.equals("enterprise-beans"))
59       {
60          child = dd.getEnterpriseBeans();
61       } else if (localName.equals("loader-repository"))
62       {
63          child = new LoaderRepository();
64          for (int i = 0 ; i < attrs.getLength() ;++i)
65          {
66             if (attrs.getLocalName(i).equals("loaderRepositoryClass"))
67                ((LoaderRepository)child).setLoaderRepositoryClass(attrs.getValue(i));
68          }
69       }
70
71       return child;
72    }
73    
74    /**
75     * Called when parsing of a new element started.
76     */

77    public Object JavaDoc newChild(LoaderRepository repository, UnmarshallingContext navigator,
78          String JavaDoc namespaceURI, String JavaDoc localName, Attributes JavaDoc attrs)
79    {
80       Object JavaDoc child = null;
81
82       if (localName.equals("loader-repository-config"))
83       {
84          child = new LoaderRepositoryConfig();
85          for (int i = 0 ; i < attrs.getLength() ;++i)
86          {
87             if (attrs.getLocalName(i).equals("configParserClass"))
88                ((LoaderRepositoryConfig)child).setConfigParserClass(attrs.getValue(i));
89          }
90       }
91
92       return child;
93    }
94    
95    /**
96     * Called when parsing of a new element started.
97     */

98    public Object JavaDoc newChild(LoaderRepositoryConfig condig, UnmarshallingContext navigator,
99          String JavaDoc namespaceURI, String JavaDoc localName, Attributes JavaDoc attrs)
100    {
101       Object JavaDoc child = null;
102
103       return child;
104    }
105
106    /**
107     * Called when parsing of a new element started.
108     */

109    public Object JavaDoc newChild(EnterpriseBeans ejbs, UnmarshallingContext navigator,
110          String JavaDoc namespaceURI, String JavaDoc localName, Attributes JavaDoc attrs)
111    {
112       Object JavaDoc child = null;
113
114       if (localName.equals("session"))
115       {
116          child = ejbs;
117       } else if (localName.equals("ejb-ref"))
118       {
119          child = new EjbRef();
120       } else if (localName.equals("ejb-local-ref"))
121       {
122          child = new EjbLocalRef();
123       } else if (localName.equals("resource-ref"))
124       {
125          child = new ResourceRef();
126       } else if (localName.equals("call-by-value"))
127       {
128          ejbs.setCallByValue(true);
129       } else if (localName.equals("clustered"))
130       {
131          child = new ClusterConfig();
132       }
133
134       return child;
135    }
136
137    /**
138     * Called when parsing character is complete.
139     */

140    public void addChild(EjbJarDD parent, LoaderRepository repository,
141          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
142    {
143       parent.setLoaderRepository(repository);
144    }
145    
146    /**
147     * Called when parsing character is complete.
148     */

149    public void addChild(LoaderRepository parent, LoaderRepositoryConfig config,
150          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
151    {
152       parent.setLoaderRepositoryConfig(config);
153    }
154    
155    /**
156     * Called when parsing character is complete.
157     */

158    public void addChild(EnterpriseBeans parent, EnterpriseBeans ejbs,
159          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
160    {
161       
162    }
163    
164    /**
165     * Called when parsing character is complete.
166     */

167    public void addChild(EnterpriseBeans parent, EjbRef ref,
168          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
169    {
170       parent.updateEjbRef(ref);
171    }
172    
173    /**
174     * Called when parsing character is complete.
175     */

176    public void addChild(EnterpriseBeans parent, EjbLocalRef ref,
177          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
178    {
179       parent.updateEjbLocalRef(ref);
180    }
181    
182    /**
183     * Called when parsing character is complete.
184     */

185    public void addChild(EnterpriseBeans parent, ResourceRef ref,
186          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
187    {
188       parent.updateResourceRef(ref);
189    }
190    
191    /**
192     * Called when parsing character is complete.
193     */

194    public void addChild(EnterpriseBeans parent, ClusterConfig config,
195          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
196    {
197       parent.setClusterConfig(config);
198    }
199
200    /**
201     * Called when a child element with simple content is read for DD.
202     */

203    public void setValue(EnterpriseBeans ejbs, UnmarshallingContext navigator,
204          String JavaDoc namespaceURI, String JavaDoc localName, String JavaDoc value)
205    {
206       if (localName.equals("ejb-name"))
207       {
208          ejbs.setCurrentEjbName(value);
209       } else if (localName.equals("jndi-name"))
210       {
211          ejbs.setJndiName(value);
212       } else if (localName.equals("local-jndi-name"))
213       {
214          ejbs.setLocalJndiName(value);
215       } else if (localName.equals("security-domain"))
216       {
217          ejbs.setSecurityDomain(value);
218       } else if (localName.equals("call-by-value"))
219       {
220          ejbs.setCallByValue(true);
221       } else if (localName.equals("run-as-principal"))
222       {
223          ejbs.setRunAsPrincipal(value);
224       } else if (localName.equals("aop-domain-name"))
225       {
226          ejbs.setAopDomainName(value);
227       }
228    }
229    
230    /**
231     * Called when a child element with simple content is read for DD.
232     */

233    public void setValue(ClusterConfig config, UnmarshallingContext navigator,
234          String JavaDoc namespaceURI, String JavaDoc localName, String JavaDoc value)
235    {
236       if (localName.equals("load-balance-policy"))
237       {
238          config.setLoadBalancePolicy(value);
239       } else if (localName.equals("partition-name"))
240       {
241          config.setPartition(value);
242       }
243    }
244    
245    /**
246     * Called when a child element with simple content is read for DD.
247     */

248    public void setValue(EjbRef ref, UnmarshallingContext navigator,
249          String JavaDoc namespaceURI, String JavaDoc localName, String JavaDoc value)
250    {
251       if (localName.equals("ejb-ref-name"))
252       {
253          ref.setEjbRefName(value);
254       } else if (localName.equals("jndi-name"))
255       {
256          ref.setJndiName(value);
257       }
258    }
259    
260    /**
261     * Called when a child element with simple content is read for DD.
262     */

263    public void setValue(EjbLocalRef ref, UnmarshallingContext navigator,
264          String JavaDoc namespaceURI, String JavaDoc localName, String JavaDoc value)
265    {
266       if (localName.equals("ejb-ref-name"))
267       {
268          ref.setEjbRefName(value);
269       } else if (localName.equals("jndi-name"))
270       {
271          ref.setJndiName(value);
272       }
273    }
274    
275    /**
276     * Called when a child element with simple content is read for DD.
277     */

278    public void setValue(ResourceRef ref, UnmarshallingContext navigator,
279          String JavaDoc namespaceURI, String JavaDoc localName, String JavaDoc value)
280    {
281       if (localName.equals("res-ref-name"))
282       {
283          ref.setResRefName(value);
284       } else if (localName.equals("jndi-name"))
285       {
286          ref.setJndiName(value);
287       } else if (localName.equals("resource-name"))
288       {
289          ref.setResourceName(value);
290       }
291    }
292
293    /**
294     * Called when a child element with simple content is read for DD.
295     */

296    public void setValue(EjbJarDD dd, UnmarshallingContext navigator,
297          String JavaDoc namespaceURI, String JavaDoc localName, String JavaDoc value)
298    {
299       if (localName.equals("security-domain"))
300       {
301          dd.setSecurityDomain(value);
302       }
303          
304    }
305    
306    /**
307     * Called when a child element with simple content is read for DD.
308     */

309    public void setValue(LoaderRepository repository, UnmarshallingContext navigator,
310          String JavaDoc namespaceURI, String JavaDoc localName, String JavaDoc value)
311    {
312       if (localName.equals("value"))
313       {
314          repository.setValue(value);
315       } else if (localName.equals("loader-repository"))
316       {
317          repository.setValue(value);
318       }
319    }
320    
321    /**
322     * Called when a child element with simple content is read for DD.
323     */

324    public void setValue(LoaderRepositoryConfig config, UnmarshallingContext navigator,
325          String JavaDoc namespaceURI, String JavaDoc localName, String JavaDoc value)
326    {
327       if (localName.equals("value"))
328       {
329          config.setValue(value);
330       } else if (localName.equals("loader-repository-config"))
331       {
332          config.setValue(value);
333       }
334    }
335   
336 }
337
Popular Tags