KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > deployment > JBossEjbObjectFactory


1 /*
2  * JBoss, Home of Professional Open Source
3  * Copyright 2006, Red Hat Middleware LLC, and individual contributors
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.deployment;
23
24
25 import javax.xml.parsers.DocumentBuilderFactory JavaDoc;
26 import javax.xml.parsers.DocumentBuilder JavaDoc;
27 import javax.xml.parsers.ParserConfigurationException JavaDoc;
28 import org.jboss.metadata.ApplicationMetaData;
29 import org.jboss.metadata.BeanMetaData;
30 import org.jboss.metadata.DDObjectFactory;
31 import org.jboss.metadata.InvokerProxyBindingMetaData;
32 import org.jboss.metadata.ConfigurationMetaData;
33 import org.jboss.metadata.ClusterConfigMetaData;
34 import org.jboss.metadata.EntityMetaData;
35 import org.jboss.metadata.MessageDrivenMetaData;
36 import org.jboss.metadata.EjbRefMetaData;
37 import org.jboss.metadata.SecurityIdentityMetaData;
38 import org.jboss.metadata.MethodAttributes;
39 import org.jboss.metadata.IorSecurityConfigMetaData;
40 import org.jboss.metadata.CacheInvalidationConfigMetaData;
41 import org.jboss.metadata.EjbPortComponentMetaData;
42 import org.jboss.metadata.SessionMetaData;
43 import org.jboss.metadata.ActivationConfigPropertyMetaData;
44 import org.jboss.metadata.AssemblyDescriptorMetaData;
45 import org.jboss.metadata.SecurityRoleMetaData;
46 import org.jboss.metadata.MessageDestinationMetaData;
47 import org.jboss.metadata.EjbLocalRefMetaData;
48 import org.jboss.metadata.ResourceRefMetaData;
49 import org.jboss.metadata.ResourceEnvRefMetaData;
50 import org.jboss.metadata.MessageDestinationRefMetaData;
51 import org.jboss.xb.binding.UnmarshallingContext;
52 import org.jboss.mx.util.ObjectNameFactory;
53 import org.jboss.webservice.metadata.serviceref.ServiceRefMetaData;
54 import org.xml.sax.Attributes JavaDoc;
55 import org.w3c.dom.Element JavaDoc;
56 import org.w3c.dom.Text JavaDoc;
57 import org.w3c.dom.Document JavaDoc;
58
59 /**
60  * ObjectFactory for translating jboss.xml into ApplicationMetaData instance
61  *
62  * @author Scott.Stark@jboss.org
63  * @author Alexey.Loubyansky@jboss.org
64  * @version $Revision:$
65  */

66 public class JBossEjbObjectFactory extends DDObjectFactory
67 {
68    private static DocumentBuilder JavaDoc DOC_BUILDER;
69
70    private ApplicationMetaData appMetaData;
71
72    static class BeanHolder
73    {
74       String JavaDoc ejbName;
75       BeanMetaData metaData;
76    }
77
78    public JBossEjbObjectFactory(ApplicationMetaData dd)
79    {
80       super();
81       this.appMetaData = dd;
82    }
83
84    /**
85     * Return the root.
86     */

87    public Object JavaDoc newRoot(Object JavaDoc root, UnmarshallingContext navigator,
88          String JavaDoc namespaceURI, String JavaDoc localName, Attributes attrs)
89    {
90       // If both the root and metaData are null the deployer is likely in the wrong order
91
if( root == null && appMetaData == null )
92          throw new IllegalStateException JavaDoc("No existing ApplicationMetaData, check the JBossEjbObjectFactory order");
93
94       return root == null ? appMetaData : root;
95    }
96
97    public Object JavaDoc completeRoot(Object JavaDoc root, UnmarshallingContext ctx,
98          String JavaDoc uri, String JavaDoc name)
99    {
100       ApplicationMetaData app = (ApplicationMetaData)root;
101       if(app.getUnauthenticatedPrincipal() == null)
102       {
103          app.setDefaultUnauthenticatedPrincipal();
104       }
105       return root;
106    }
107
108    /**
109     * Called when parsing of a new element started.
110     */

111    public Object JavaDoc newChild(ApplicationMetaData dd, UnmarshallingContext navigator,
112          String JavaDoc namespaceURI, String JavaDoc localName, Attributes attrs)
113    {
114       Object JavaDoc child = null;
115       if(localName.equals("loader-repository"))
116       {
117          // todo load-repository (it wasn't parsed in the ApplicationMetaData neither)
118
}
119       else if(localName.equals("invoker-proxy-bindings"))
120       {
121          child = dd;
122       }
123       else if(localName.equals("invoker-proxy-binding"))
124       {
125          child = new InvokerProxyBindingMetaData();
126       }
127       else if(localName.equals("container-configurations"))
128       {
129          child = dd;
130       }
131       else if(localName.equals("container-configuration"))
132       {
133          int extendsIndex = attrs.getIndex("extends");
134          if(extendsIndex != -1)
135          {
136             String JavaDoc extendName = attrs.getValue(extendsIndex);
137             ConfigurationMetaData extendConfig = dd.getConfigurationMetaDataByName(extendName);
138             if(extendConfig == null)
139             {
140                throw new IllegalStateException JavaDoc(
141                   "Parent container configuration couldn't be found: " + extendName
142                );
143             }
144
145             child = extendConfig.clone();
146          }
147          else
148          {
149             child = new ConfigurationMetaData();
150          }
151       }
152       else if(localName.equals("webservices"))
153       {
154          child = dd;
155       }
156       else if(localName.equals("webservice-description"))
157       {
158          child = new WsDescription();
159       }
160       else if(localName.equals("enterprise-beans"))
161       {
162          child = dd;
163       }
164       else if (localName.equals("entity") ||
165          localName.equals("session") ||
166          localName.equals("message-driven") )
167       {
168          child = new BeanHolder();
169       }
170       else if(localName.equals("resource-managers"))
171       {
172          child = dd;
173       }
174       else if(localName.equals("resource-manager"))
175       {
176          child = new ResourceManagerMetaData();
177       }
178       else if(localName.equals("assembly-descriptor"))
179       {
180          child = dd.getAssemblyDescriptor();
181       }
182       return child;
183    }
184
185    public Object JavaDoc newChild(BeanHolder bean, UnmarshallingContext navigator,
186          String JavaDoc namespaceURI, String JavaDoc localName, Attributes attrs)
187    {
188       Object JavaDoc child = null;
189       if ((child = newEnvRefGroupChild(localName)) != null)
190       {
191          return child;
192       }
193       else if(localName.equals("invoker-bindings"))
194       {
195          child = bean;
196       }
197       else if(localName.equals("invoker"))
198       {
199          child = new InvokerMetaData(bean.metaData);
200       }
201       else if(localName.equals("security-identity"))
202       {
203          child = bean.metaData.getSecurityIdentityMetaData();
204          if(child == null)
205          {
206             throw new IllegalStateException JavaDoc("security-identity in jboss.xml has no match in ejb-jar.xml for " + bean.metaData.getEjbName());
207          }
208       }
209       else if(localName.equals("ejb-timeout-identity"))
210       {
211          child = new SecurityIdentityMetaData();
212       }
213       else if(localName.equals("method-attributes"))
214       {
215          child = bean;
216       }
217       else if(localName.equals("method"))
218       {
219          child = new MethodAttributes();
220       }
221       else if(localName.equals("cluster-config"))
222       {
223          ClusterConfigMetaData cc = new ClusterConfigMetaData();
224          cc.init(bean.metaData);
225       }
226       else if(localName.equals("ior-security-config"))
227       {
228          child = new IorSecurityConfigMetaData();
229       }
230       else if(localName.equals("cache-invalidation-config"))
231       {
232          CacheInvalidationConfigMetaData config = new CacheInvalidationConfigMetaData();
233          config.init(bean.metaData);
234          child = config;
235       }
236       else if(localName.equals("port-component"))
237       {
238          child = new EjbPortComponentMetaData((SessionMetaData)bean.metaData);
239       }
240       else if(localName.equals("activation-config"))
241       {
242          child = bean;
243       }
244       else if(localName.equals("activation-config-property"))
245       {
246          return new ActivationConfigPropertyMetaData();
247       }
248       return child;
249    }
250
251    public Object JavaDoc newChild(InvokerProxyBindingMetaData md, UnmarshallingContext navigator,
252          String JavaDoc namespaceURI, String JavaDoc localName, Attributes attrs)
253    {
254       Object JavaDoc child = null;
255       if (localName.equals("proxy-factory-config"))
256       {
257          child = new DomElement(newDomElement(localName, attrs));
258       }
259       return child;
260    }
261
262    public Object JavaDoc newChild(ConfigurationMetaData md, UnmarshallingContext navigator,
263          String JavaDoc namespaceURI, String JavaDoc localName, Attributes attrs)
264    {
265       Object JavaDoc child = null;
266       if (localName.equals("cluster-config"))
267       {
268          child = new ClusterConfigMetaData();
269       }
270       else if(localName.equals("container-interceptors") ||
271          localName.equals("container-cache-conf") ||
272          localName.equals("container-pool-conf"))
273       {
274          child = new DomElement(newDomElement(localName, attrs));
275       }
276       return child;
277    }
278
279    public Object JavaDoc newChild(DomElement dom, UnmarshallingContext navigator,
280          String JavaDoc namespaceURI, String JavaDoc localName, Attributes attrs)
281    {
282       Element JavaDoc child = dom.element.getOwnerDocument().createElement(localName);
283       addAttributes(child, attrs);
284       return new DomElement(child);
285    }
286
287    public Object JavaDoc newChild(InvokerMetaData invoker, UnmarshallingContext navigator,
288          String JavaDoc namespaceURI, String JavaDoc localName, Attributes attrs)
289    {
290       if(localName.equals("ejb-ref"))
291       {
292          return new InvokerMetaData.EjbRef();
293       }
294       return null;
295    }
296
297    public Object JavaDoc newChild(IorSecurityConfigMetaData invoker, UnmarshallingContext navigator,
298          String JavaDoc namespaceURI, String JavaDoc localName, Attributes attrs)
299    {
300       if(localName.equals("transport-config"))
301       {
302          return new IorSecurityConfigMetaData.TransportConfig();
303       }
304       else if(localName.equals("as-context"))
305       {
306          return new IorSecurityConfigMetaData.AsContext();
307       }
308       else if(localName.equals("sas-context"))
309       {
310          return new IorSecurityConfigMetaData.SasContext();
311       }
312       return null;
313    }
314
315    public Object JavaDoc newChild(AssemblyDescriptorMetaData parent, UnmarshallingContext navigator,
316          String JavaDoc namespaceURI, String JavaDoc localName, Attributes attrs)
317    {
318       if(localName.equals("security-role"))
319       {
320          return new SecurityRoleMetaData();
321       }
322       else if(localName.equals("message-destination"))
323       {
324          return new MessageDestinationMetaData();
325       }
326       return null;
327    }
328
329    public void addChild(ApplicationMetaData parent, InvokerProxyBindingMetaData binding,
330          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
331    {
332       parent.addInvokerProxyBinding(binding);
333    }
334
335    public void addChild(ApplicationMetaData parent, ConfigurationMetaData container,
336          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
337    {
338       parent.addContainerConfiguration(container);
339    }
340
341    public void addChild(ApplicationMetaData parent, ResourceManagerMetaData child,
342          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
343    {
344       if(child.jndiName != null)
345       {
346          parent.mapResource(child.resName, child.jndiName);
347       }
348       else if(child.url != null)
349       {
350          parent.mapResource(child.resName, child.url);
351       }
352       else
353       {
354          throw new IllegalStateException JavaDoc(child.resName +" : expected res-url or res-jndi-name tag");
355       }
356    }
357
358    public void addChild(ApplicationMetaData parent, WsDescription child,
359          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
360    {
361       parent.setConfigName(child.configName);
362       parent.setConfigFile(child.configFile);
363       parent.getWsdlPublishLocations().put(child.name, child.location);
364    }
365
366    public void addChild(ConfigurationMetaData parent, ClusterConfigMetaData child,
367          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
368    {
369       parent.setClusterConfig(child);
370    }
371
372    public void addChild(ConfigurationMetaData parent, DomElement child,
373          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
374    {
375       if(localName.equals("container-interceptors"))
376       {
377          parent.setContainerInterceptorsConf(child.element);
378       }
379       else if(localName.equals("container-cache-conf"))
380       {
381          parent.setContainerCacheConf(child.element);
382       }
383       else if(localName.equals("container-pool-conf"))
384       {
385          parent.setContainerPoolConf(child.element);
386       }
387    }
388
389    public void addChild(InvokerProxyBindingMetaData parent, DomElement domElement,
390          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
391    {
392       if(localName.equals("proxy-factory-config"))
393       {
394          parent.setProxyFactoryConfig(domElement.element);
395       }
396    }
397
398    public void addChild(DomElement parent, DomElement child,
399          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
400    {
401       parent.element.appendChild(child.element);
402    }
403
404    public void addChild(BeanHolder parent, InvokerMetaData child,
405          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
406    {
407       String JavaDoc jndiName = child.jndiName;
408       if(jndiName == null)
409       {
410          jndiName = parent.metaData.getJndiName();
411       }
412       parent.metaData.addInvokerBinding(child.bindingName, jndiName);
413    }
414
415    public void addChild(BeanHolder parent, SecurityIdentityMetaData child,
416          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
417    {
418       if(localName.equals("ejb-timeout-identity"))
419       {
420          child.setRunAsRoleName("ejbTimeout");
421          if(child.getRunAsPrincipalName() == null)
422          {
423             child.getUseCallerIdentity();
424          }
425          parent.metaData.setEjbTimeoutIdentity(child);
426       }
427    }
428
429    public void addChild(BeanHolder parent, MethodAttributes child,
430          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
431    {
432       parent.metaData.getMethodAttributes().add(child);
433    }
434
435    public void addChild(BeanHolder parent, ClusterConfigMetaData child,
436          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
437    {
438       parent.metaData.setClusterConfig(child);
439    }
440
441    public void addChild(BeanHolder parent, IorSecurityConfigMetaData child,
442          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
443    {
444       parent.metaData.setIorSecurityConfig(child);
445    }
446
447    public void addChild(BeanHolder parent, CacheInvalidationConfigMetaData child,
448          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
449    {
450       ((EntityMetaData)parent.metaData).setCacheInvalidConfig(child);
451    }
452
453    public void addChild(BeanHolder parent, EjbPortComponentMetaData child,
454          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
455    {
456       ((SessionMetaData)parent.metaData).setPortComponent(child);
457    }
458
459    public void addChild(BeanHolder parent, ActivationConfigPropertyMetaData child,
460          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
461    {
462       ((MessageDrivenMetaData)parent.metaData).getActivationConfigProperties().put(child.getName(), child);
463    }
464
465    public void addChild(BeanHolder parent, EjbLocalRefMetaData child,
466          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
467    {
468       EjbLocalRefMetaData ref = parent.metaData.getEjbLocalRefByName(child.getName());
469       if(ref == null)
470       {
471          throw new IllegalStateException JavaDoc("ejb-local-ref " + child.getName() +
472             " found in jboss.xml in ejb " + parent.metaData.getEjbName() + " could not be found in the ejb-jar.xml");
473       }
474       ref.setJndiName(child.getJndiName());
475    }
476
477    public void addChild(BeanHolder parent, EjbRefMetaData child,
478          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
479    {
480       EjbRefMetaData ref = parent.metaData.getEjbRefByName(child.getName());
481       if(ref == null)
482       {
483          throw new IllegalStateException JavaDoc("ejb-ref " + child.getName() +
484             " found in jboss.xml in ejb " + parent.metaData.getEjbName() + " could not be found in the ejb-jar.xml");
485       }
486       ref.setJndiName(child.getJndiName());
487    }
488
489    public void addChild(BeanHolder parent, ResourceRefMetaData child,
490          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
491    {
492       ResourceRefMetaData ref = parent.metaData.getResourceReference(child.getRefName());
493       if(ref == null)
494       {
495          throw new IllegalStateException JavaDoc("resource-ref " + child.getRefName() +
496             " found in jboss.xml in ejb " + parent.metaData.getEjbName() + " could not be found in the ejb-jar.xml");
497       }
498
499       ref.setName(child.getName());
500       ref.setJndiName(child.getJndiName());
501       ref.setResURL(child.getResURL());
502    }
503
504    public void addChild(BeanHolder parent, ResourceEnvRefMetaData child,
505          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
506    {
507       ResourceEnvRefMetaData ref = parent.metaData.getResourceEnvReference(child.getRefName());
508       if(ref == null)
509       {
510          throw new IllegalStateException JavaDoc("resource-env-ref " + child.getRefName() +
511             " found in jboss.xml in ejb " + parent.metaData.getEjbName() + " could not be found in the ejb-jar.xml");
512       }
513       ref.setJndiName(child.getJndiName());
514    }
515
516    public void addChild(BeanHolder parent, MessageDestinationRefMetaData child,
517          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
518    {
519       MessageDestinationRefMetaData ref = parent.metaData.getMessageDestinationReference(child.getRefName());
520       if(ref == null)
521       {
522          throw new IllegalStateException JavaDoc("message-destination-ref " + child.getRefName() +
523             " found in jboss.xml in ejb " + parent.metaData.getEjbName() + " could not be found in the ejb-jar.xml");
524       }
525       ref.setJndiName(child.getJndiName());
526    }
527
528    public void addChild(BeanHolder parent, ServiceRefMetaData child,
529          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
530    {
531       // TODO merge/add service-ref
532
}
533
534    public void addChild(InvokerMetaData parent, InvokerMetaData.EjbRef child,
535          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
536    {
537       EjbRefMetaData ejbRef = parent.bean.getEjbRefByName(child.ejbRefName);
538       if(ejbRef == null)
539       {
540          throw new IllegalStateException JavaDoc("ejb-ref " + child.ejbRefName + " found in jboss.xml but not in ejb-jar.xml");
541       }
542       ejbRef.addInvokerBinding(parent.bindingName, child.jndiName);
543    }
544
545    public void addChild(IorSecurityConfigMetaData parent, IorSecurityConfigMetaData.TransportConfig child,
546          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
547    {
548       parent.setTransportConfig(child);
549    }
550
551    public void addChild(IorSecurityConfigMetaData parent, IorSecurityConfigMetaData.AsContext child,
552          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
553    {
554       parent.setAsContext(child);
555    }
556
557    public void addChild(IorSecurityConfigMetaData parent, IorSecurityConfigMetaData.SasContext child,
558          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
559    {
560       parent.setSasContext(child);
561    }
562
563    public void addChild(AssemblyDescriptorMetaData parent, SecurityRoleMetaData child,
564          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
565    {
566       SecurityRoleMetaData ejbjarRole = parent.getSecurityRoleByName(child.getRoleName());
567       if(ejbjarRole != null)
568       {
569          ejbjarRole.addPrincipalNames(child.getPrincipals());
570       }
571       else
572       {
573          parent.addSecurityRoleMetaData(child);
574       }
575    }
576
577    public void addChild(AssemblyDescriptorMetaData parent, MessageDestinationMetaData child,
578          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName)
579    {
580       MessageDestinationMetaData ejbjarDest = parent.getMessageDestinationMetaData(child.getName());
581       if(ejbjarDest == null)
582       {
583          throw new IllegalStateException JavaDoc("message-destination " + child.getName() + " found in jboss.xml but not in ejb-jar.xml");
584       }
585       ejbjarDest.setJNDIName(child.getJNDIName());
586    }
587
588    public void setValue(ApplicationMetaData amd,
589          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName,
590          String JavaDoc value)
591    {
592       if (localName.equals("jmx-name"))
593       {
594          amd.setJmxName(value);
595       }
596       else if(localName.equals("enforce-ejb-restrictions"))
597       {
598          amd.setEnforceEjbRestrictions(Boolean.parseBoolean(value));
599       }
600       else if(localName.equals("exception-on-rollback"))
601       {
602          boolean flag = Boolean.valueOf(value);
603          amd.setExceptionRollback(flag);
604       }
605       else if(localName.equals("security-domain"))
606       {
607          amd.setSecurityDomain(value);
608       }
609       else if(localName.equals("missing-method-permissions-excluded-mode"))
610       {
611          amd.setExcludeMissingMethods(Boolean.parseBoolean(value));
612       }
613       else if(localName.equals("unauthenticated-principal"))
614       {
615          amd.setUnauthenticatedPrincipal(value);
616       }
617       else if(localName.equals("context-root"))
618       {
619          amd.setWebServiceContextRoot(value);
620       }
621    }
622
623    public void setValue(InvokerProxyBindingMetaData md,
624          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName,
625          String JavaDoc value)
626    {
627       if(localName.equals("name"))
628       {
629          md.setName(value);
630       }
631       else if (localName.equals("invoker-mbean"))
632       {
633          md.setInvokerMBean(value);
634       }
635       else if (localName.equals("proxy-factory"))
636       {
637          md.setProxyFactory(value);
638       }
639    }
640
641    public void setValue(InvokerMetaData md,
642          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName,
643          String JavaDoc value)
644    {
645       if(localName.equals("invoker-proxy-binding-name"))
646       {
647          md.bindingName = value;
648       }
649       else if(localName.equals("jndi-name"))
650       {
651          md.jndiName = value;
652       }
653    }
654
655    public void setValue(InvokerMetaData.EjbRef md,
656          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName,
657          String JavaDoc value)
658    {
659       if(localName.equals("ejb-ref-name"))
660       {
661          md.ejbRefName = value;
662       }
663       else if(localName.equals("jndi-name"))
664       {
665          md.jndiName = value;
666       }
667    }
668
669    public void setValue(BeanHolder bean,
670          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName,
671          String JavaDoc value)
672    {
673       // common for entity, session and message-driven
674
if( localName.equals("ejb-name") )
675       {
676          bean.ejbName = value;
677          // Lookup the metadata
678
bean.metaData = appMetaData.getBeanByEjbName(value);
679          if(bean.metaData == null)
680          {
681             throw new IllegalStateException JavaDoc("Bean " + value + " not declared in the ejb-jar.xml");
682          }
683       }
684       else if( localName.equals("jndi-name") )
685       {
686          bean.metaData.setJndiName(value);
687       }
688       else if( localName.equals("local-jndi-name") )
689       {
690          bean.metaData.setLocalJndiName(value);
691       }
692       else if(localName.equals("exception-on-rollback"))
693       {
694          bean.metaData.setExceptionRollback(Boolean.parseBoolean(value));
695       }
696       else if(localName.equals("timer-persistence"))
697       {
698          bean.metaData.setTimerPersistence(Boolean.parseBoolean(value));
699       }
700       else if(localName.equals("configuration-name"))
701       {
702          bean.metaData.setConfigurationName(value);
703       }
704       else if(localName.equals("security-proxy"))
705       {
706          bean.metaData.setSecurityProxy(value);
707       }
708       else if(localName.equals("depends"))
709       {
710          bean.metaData.getDepends().add(ObjectNameFactory.create(value));
711       }
712       // session and entity elements
713
else if( localName.equals("call-by-value") )
714       {
715          boolean flag = Boolean.valueOf(value);
716          bean.metaData.setCallByValue(flag);
717       }
718       else if(localName.equals("clustered"))
719       {
720          bean.metaData.setClustered(Boolean.parseBoolean(value));
721       }
722       // entity elements
723
else if(localName.equals("read-only"))
724       {
725          ((EntityMetaData)bean.metaData).setReadOnly(Boolean.parseBoolean(value));
726       }
727       else if(localName.equals("cache-invalidation"))
728       {
729          ((EntityMetaData)bean.metaData).setDoDistCachInvalidations(Boolean.parseBoolean(value));
730       }
731       // message-driven elements
732
else if(localName.equals("destination-jndi-name"))
733       {
734          ((MessageDrivenMetaData)bean.metaData).setDestinationJndiName(value);
735       }
736       else if(localName.equals("mdb-user"))
737       {
738          ((MessageDrivenMetaData)bean.metaData).setUser(value);
739       }
740       else if(localName.equals("mdb-passwd"))
741       {
742          ((MessageDrivenMetaData)bean.metaData).setPasswd(value);
743       }
744       else if(localName.equals("mdb-client-id"))
745       {
746          ((MessageDrivenMetaData)bean.metaData).setClientId(value);
747       }
748       else if(localName.equals("mdb-subscription-id"))
749       {
750          ((MessageDrivenMetaData)bean.metaData).setSubscriptionId(value);
751       }
752       else if(localName.equals("resource-adapter-name"))
753       {
754          ((MessageDrivenMetaData)bean.metaData).setResourceAdapterName(value);
755       }
756    }
757
758    public void setValue(ConfigurationMetaData container,
759          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName,
760          String JavaDoc value)
761    {
762       if (localName.equals("container-name"))
763       {
764          container.setName(value);
765       }
766       else if(localName.equals("call-logging"))
767       {
768          container.setCallLogging(Boolean.valueOf(value));
769       }
770       else if(localName.equals("invoker-proxy-binding-name"))
771       {
772          // TODO: according to the DTD there could only be one
773
String JavaDoc[] invokers = container.getInvokers();
774          if(invokers == null)
775          {
776             container.setInvokerNames(new String JavaDoc[]{value});
777          }
778          else
779          {
780             String JavaDoc[] newInvokers = new String JavaDoc[invokers.length + 1];
781             System.arraycopy(invokers, 0, newInvokers, 0, invokers.length);
782             newInvokers[invokers.length] = value;
783             container.setInvokerNames(newInvokers);
784          }
785       }
786       else if(localName.equals("sync-on-commit-only"))
787       {
788          container.setSyncOnCommitOnly(Boolean.valueOf(value));
789       }
790       else if(localName.equals("insert-after-ejb-post-create"))
791       {
792          container.setInsertAfterEjbPostCreate(Boolean.valueOf(value));
793       }
794       else if(localName.equals("call-ejb-store-on-clean"))
795       {
796          container.setEjbStoreForClean(Boolean.valueOf(value));
797       }
798       else if(localName.equals("store-not-flushed"))
799       {
800          container.setStoreNotFlushed(Boolean.valueOf(value));
801       }
802       else if(localName.equals("instance-pool"))
803       {
804          container.setInstancePool(value);
805       }
806       else if(localName.equals("instance-cache"))
807       {
808          container.setInstanceCache(value);
809       }
810       else if(localName.equals("persistence-manager"))
811       {
812          container.setPersistenceManager(value);
813       }
814       else if(localName.equals("web-class-loader"))
815       {
816          container.setWebClassLoader(value);
817       }
818       else if(localName.equals("locking-policy"))
819       {
820          container.setLockClass(value);
821       }
822       else if(localName.equals("commit-option"))
823       {
824          container.setCommitOption(value);
825       }
826       else if(localName.equals("optiond-refresh-rate"))
827       {
828          container.setOptionDRefreshRate(Long.parseLong(value));
829       }
830       else if(localName.equals("security-domain"))
831       {
832          container.setSecurityDomain(value);;
833       }
834       else if(localName.equals("depends"))
835       {
836          container.getDepends().add(ObjectNameFactory.create(value));
837       }
838    }
839
840    public void setValue(ClusterConfigMetaData config,
841          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName,
842          String JavaDoc value)
843    {
844       if(localName.equals("partition-name"))
845       {
846          config.setPartitionName(value);
847       }
848       else if(localName.equals("home-load-balance-policy"))
849       {
850          config.setHomeLoadBalancePolicy(value);
851       }
852       else if(localName.equals("bean-load-balance-policy"))
853       {
854          config.setBeanLoadBalancePolicy(value);
855       }
856       else if(localName.equals("session-state-manager-jndi-name"))
857       {
858          config.setHaSessionStateName(value);
859       }
860    }
861
862    public void setValue(DomElement dom,
863          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName,
864          String JavaDoc value)
865    {
866       Document JavaDoc doc = dom.element.getOwnerDocument();
867       Text JavaDoc textNode = doc.createTextNode(value);
868       dom.element.appendChild(textNode);
869    }
870
871    public void setValue(SecurityIdentityMetaData id,
872          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName,
873          String JavaDoc value)
874    {
875       if(localName.equals("run-as-principal") && value != null)
876       {
877          id.setRunAsPrincipalName(value);
878       }
879    }
880
881    public void setValue(MethodAttributes method,
882          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName,
883          String JavaDoc value)
884    {
885       if(localName.equals("method-name"))
886       {
887          method.setPattern(value);
888       }
889       else if(localName.equals("read-only"))
890       {
891          method.setReadOnly(Boolean.parseBoolean(value));
892       }
893       else if(localName.equals("idempotent"))
894       {
895          method.setIdempotent(Boolean.parseBoolean(value));
896       }
897       else if(localName.equals("transaction-timeout"))
898       {
899          method.setTxTimeout(Integer.parseInt(value));
900       }
901    }
902
903    public void setValue(IorSecurityConfigMetaData.TransportConfig parent,
904          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName,
905          String JavaDoc value)
906    {
907       if(localName.equals("integrity"))
908       {
909          parent.setIntegrity(value);
910       }
911       else if(localName.equals("confidentiality"))
912       {
913          parent.setConfidentiality(value);
914       }
915       else if(localName.equals("establish-trust-in-target"))
916       {
917          parent.setEstablishTrustInTarget(value);
918       }
919       else if(localName.equals("establish-trust-in-client"))
920       {
921          parent.setEstablishTrustInClient(value);
922       }
923       else if(localName.equals("detect-misordering"))
924       {
925          parent.setDetectMisordering(value);
926       }
927       else if(localName.equals("detect-replay"))
928       {
929          parent.setDetectReplay(value);
930       }
931    }
932
933    public void setValue(IorSecurityConfigMetaData.AsContext parent,
934          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName,
935          String JavaDoc value)
936    {
937       if(localName.equals("auth-method"))
938       {
939          parent.setAuthMethod(value);
940       }
941       else if(localName.equals("realm"))
942       {
943          parent.setRealm(value);
944       }
945       else if(localName.equals("required"))
946       {
947          parent.setRequired(Boolean.parseBoolean(value));
948       }
949    }
950
951    public void setValue(IorSecurityConfigMetaData.SasContext parent,
952          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName,
953          String JavaDoc value)
954    {
955       if(localName.equals("caller-propagation"))
956       {
957          parent.setCallerPropagation(value);
958       }
959    }
960
961    public void setValue(CacheInvalidationConfigMetaData parent,
962          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName,
963          String JavaDoc value)
964    {
965       if(localName.equals("invalidation-group-name"))
966       {
967          parent.setInvalidationGroupName(value);
968       }
969       else if(localName.equals("invalidation-manager-name"))
970       {
971          parent.setInvalidationManagerName(value);
972       }
973    }
974
975    public void setValue(EjbPortComponentMetaData parent,
976          UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName,
977          String JavaDoc value)
978    {
979       if(localName.equals("port-component-name"))
980       {
981          parent.setPortComponentName(value);
982       }
983       else if(localName.equals("port-component-uri"))
984       {
985          parent.setPortComponentURI(value);
986       }
987       else if(localName.equals("auth-method"))
988       {
989          parent.setAuthMethod(value);
990       }
991       else if(localName.equals("transport-guarantee"))
992       {
993          parent.setTransportGuarantee(value);
994       }
995       else if(localName.equals("port-uri"))
996       {
997          new IllegalStateException JavaDoc("Deprecated element <port-uri>, use <port-component-uri> instead");
998       }
999    }
1000
1001   public void setValue(ActivationConfigPropertyMetaData parent,
1002         UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName,
1003         String JavaDoc value)
1004   {
1005      if(localName.equals("activation-config-property-name"))
1006      {
1007         parent.setName(value);
1008      }
1009      else if(localName.equals("activation-config-property-value"))
1010      {
1011         parent.setValue(value);
1012      }
1013   }
1014
1015   public void setValue(SecurityRoleMetaData parent,
1016         UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName,
1017         String JavaDoc value)
1018   {
1019      if(localName.equals("role-name"))
1020      {
1021         parent.setRoleName(value);
1022      }
1023      else if(localName.equals("principal-name"))
1024      {
1025         parent.addPrincipalName(value);
1026      }
1027   }
1028
1029   public void setValue(ResourceManagerMetaData parent,
1030         UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName,
1031         String JavaDoc value)
1032   {
1033      if(localName.equals("res-name"))
1034      {
1035         parent.resName = value;
1036      }
1037      else if(localName.equals("res-jndi-name"))
1038      {
1039         parent.jndiName = value;
1040      }
1041      else if(localName.equals("res-url"))
1042      {
1043         parent.url = value;
1044      }
1045   }
1046
1047   public void setValue(WsDescription parent,
1048         UnmarshallingContext navigator, String JavaDoc namespaceURI, String JavaDoc localName,
1049         String JavaDoc value)
1050   {
1051      if(localName.equals("webservice-description-name"))
1052      {
1053         parent.name = value;
1054      }
1055      else if(localName.equals("config-name"))
1056      {
1057         parent.configName = value;
1058      }
1059      else if(localName.equals("config-file"))
1060      {
1061         parent.configFile = value;
1062      }
1063      else if(localName.equals("wsdl-publish-location"))
1064      {
1065         parent.location = value;
1066      }
1067   }
1068
1069   // static
1070

1071   public static class DomElement
1072   {
1073      private final Element JavaDoc element;
1074
1075      public DomElement(Element JavaDoc element)
1076      {
1077         this.element = element;
1078      }
1079   }
1080
1081   private static Element JavaDoc newDomElement(String JavaDoc name, Attributes attrs)
1082   {
1083      if(DOC_BUILDER == null)
1084      {
1085         DocumentBuilderFactory JavaDoc factory = DocumentBuilderFactory.newInstance();
1086         try
1087         {
1088            DOC_BUILDER = factory.newDocumentBuilder();
1089         }
1090         catch(ParserConfigurationException JavaDoc e)
1091         {
1092            throw new IllegalStateException JavaDoc("Failed to create W3C DocumentBuilder", e);
1093         }
1094      }
1095
1096      Element JavaDoc element = DOC_BUILDER.newDocument().createElement(name);
1097      addAttributes(element, attrs);
1098
1099      return element;
1100   }
1101
1102   private static void addAttributes(Element JavaDoc e, Attributes attrs)
1103   {
1104      for(int i = 0; i < attrs.getLength(); ++i)
1105      {
1106         e.setAttribute(attrs.getQName(i), attrs.getValue(i));
1107      }
1108   }
1109
1110   // inner
1111

1112   public static class InvokerMetaData
1113   {
1114      public static class EjbRef
1115      {
1116         String JavaDoc ejbRefName;
1117         String JavaDoc jndiName;
1118      }
1119
1120      BeanMetaData bean;
1121      String JavaDoc bindingName;
1122      String JavaDoc jndiName;
1123
1124      public InvokerMetaData(BeanMetaData bean)
1125      {
1126         this.bean = bean;
1127      }
1128   }
1129
1130   public static class ResourceManagerMetaData
1131   {
1132      String JavaDoc resName;
1133      String JavaDoc jndiName;
1134      String JavaDoc url;
1135   }
1136
1137   public static class WsDescription
1138   {
1139      String JavaDoc name;
1140      String JavaDoc configName;
1141      String JavaDoc configFile;
1142      String JavaDoc location;
1143   }
1144}
1145
Popular Tags