001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.ejb3.metamodel;
023:
024: import java.io.IOException;
025: import java.net.URL;
026:
027: import org.jboss.logging.Logger;
028: import org.jboss.metamodel.descriptor.DDObjectFactory;
029: import org.jboss.metamodel.descriptor.EjbLocalRef;
030: import org.jboss.metamodel.descriptor.EjbRef;
031: import org.jboss.metamodel.descriptor.InjectionTarget;
032: import org.jboss.metamodel.descriptor.JndiRef;
033: import org.jboss.metamodel.descriptor.MessageDestinationRef;
034: import org.jboss.metamodel.descriptor.NameValuePair;
035: import org.jboss.metamodel.descriptor.ResourceEnvRef;
036: import org.jboss.metamodel.descriptor.ResourceRef;
037: import org.jboss.security.SecurityRoleMetaData;
038: import org.jboss.util.xml.JBossEntityResolver;
039: import org.jboss.ws.integration.ServiceRefMetaData;
040: import org.jboss.xb.binding.JBossXBException;
041: import org.jboss.xb.binding.ObjectModelFactory;
042: import org.jboss.xb.binding.Unmarshaller;
043: import org.jboss.xb.binding.UnmarshallerFactory;
044: import org.jboss.xb.binding.UnmarshallingContext;
045: import org.jboss.util.StringPropertyReplacer;
046: import org.xml.sax.Attributes;
047:
048: /**
049: * Represents the jboss.xml deployment descriptor for the 2.1 schema
050: *
051: * @author <a href="mailto:bdecoste@jboss.com">William DeCoste</a>
052: * @author Anil.Saldhana@jboss.com
053: * @version <tt>$Revision: 61624 $</tt>
054: */
055: public class JBossDDObjectFactory extends DDObjectFactory {
056: private static final Logger log = Logger
057: .getLogger(JBossDDObjectFactory.class);
058:
059: private EjbJarDD dd;
060: private Class ejbClass;
061:
062: public static EjbJarDD parse(URL ddResource, EjbJarDD dd)
063: throws JBossXBException, IOException {
064: ObjectModelFactory factory = null;
065: Unmarshaller unmarshaller = null;
066:
067: if (ddResource != null) {
068: log.debug("found jboss.xml " + ddResource);
069:
070: if (dd == null)
071: dd = new EjbJarDD();
072:
073: factory = new JBossDDObjectFactory(dd);
074: UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory
075: .newInstance();
076: unmarshaller = unmarshallerFactory.newUnmarshaller();
077: unmarshaller.setEntityResolver(new JBossEntityResolver());
078: unmarshaller.setNamespaceAware(true);
079: unmarshaller.setSchemaValidation(true);
080: unmarshaller.setValidation(true);
081:
082: dd = (EjbJarDD) unmarshaller.unmarshal(ddResource
083: .openStream(), factory, null);
084: }
085:
086: return dd;
087: }
088:
089: public JBossDDObjectFactory(EjbJarDD dd) {
090: super ();
091: this .dd = dd;
092: }
093:
094: /**
095: * Return the root.
096: */
097: public Object newRoot(Object root, UnmarshallingContext navigator,
098: String namespaceURI, String localName, Attributes attrs) {
099: return dd;
100: }
101:
102: public Object completeRoot(Object root, UnmarshallingContext ctx,
103: String uri, String name) {
104: return root;
105: }
106:
107: // Methods discovered by introspection
108:
109: /**
110: * Called when parsing of a new element started.
111: */
112: public Object newChild(EjbJarDD dd, UnmarshallingContext navigator,
113: String namespaceURI, String localName, Attributes attrs) {
114: Object child = null;
115:
116: if (localName.equals("enterprise-beans")) {
117: child = dd.getEnterpriseBeans();
118: if (child == null) {
119: dd.setEnterpriseBeans(new EnterpriseBeans());
120: child = dd.getEnterpriseBeans();
121: }
122: } else if (localName.equals("assembly-descriptor")) {
123: child = dd.getAssemblyDescriptor();
124: if (child == null) {
125: dd.setAssemblyDescriptor(new AssemblyDescriptor());
126: child = dd.getAssemblyDescriptor();
127: }
128: } else if (localName.equals("resource-manager")) {
129: child = new ResourceManager();
130: }
131:
132: return child;
133: }
134:
135: /**
136: * Called when parsing of a new element started.
137: */
138: public Object newChild(Consumer consumer,
139: UnmarshallingContext navigator, String namespaceURI,
140: String localName, Attributes attrs) {
141: Object child = null;
142:
143: if ((child = this .newEnvRefGroupChild(localName)) != null)
144: return child;
145:
146: if (localName.equals("current-message")) {
147: child = new CurrentMessage();
148: } else if (localName.equals("message-properties")) {
149: child = new MessageProperties();
150: } else if (localName.equals("producer")) {
151: child = new Producer(false);
152: } else if (localName.equals("local-producer")) {
153: child = new Producer(true);
154: } else if (localName.equals("annotation")) {
155: child = new XmlAnnotation();
156: } else if (localName.equals("ignore-dependency")) {
157: child = new InjectionTarget();
158: } else if (localName.equals("remote-binding")) {
159: child = new RemoteBinding();
160: } else if (localName.equals("pool-config")) {
161: child = new PoolConfig();
162: }
163:
164: return child;
165: }
166:
167: /**
168: * Called when parsing of a new element started.
169: */
170: public Object newChild(Service service,
171: UnmarshallingContext navigator, String namespaceURI,
172: String localName, Attributes attrs) {
173: Object child = null;
174:
175: if ((child = this .newEnvRefGroupChild(localName)) != null)
176: return child;
177:
178: if (localName.equals("ignore-dependency")) {
179: child = new InjectionTarget();
180: } else if (localName.equals("annotation")) {
181: child = new XmlAnnotation();
182: } else if (localName.equals("remote-binding")) {
183: child = new RemoteBinding();
184: }
185:
186: return child;
187: }
188:
189: /**
190: * Called when parsing of a new element started.
191: */
192: public Object newChild(CurrentMessage message,
193: UnmarshallingContext navigator, String namespaceURI,
194: String localName, Attributes attrs) {
195: Object child = null;
196:
197: if (localName.equals("method")) {
198: child = new Method();
199: }
200:
201: return child;
202: }
203:
204: /**
205: * Called when parsing of a new element started.
206: */
207: public Object newChild(MessageProperties properties,
208: UnmarshallingContext navigator, String namespaceURI,
209: String localName, Attributes attrs) {
210: Object child = null;
211:
212: if (localName.equals("method")) {
213: child = new Method();
214: }
215:
216: return child;
217: }
218:
219: /**
220: * Called when parsing of a new element started.
221: */
222: public Object newChild(MethodAttributes attributes,
223: UnmarshallingContext navigator, String namespaceURI,
224: String localName, Attributes attrs) {
225: Object child = null;
226:
227: if (localName.equals("method")) {
228: child = new Method();
229: }
230:
231: return child;
232: }
233:
234: /**
235: * Called when parsing of a new element started.
236: */
237: public Object newChild(AssemblyDescriptor descriptor,
238: UnmarshallingContext navigator, String namespaceURI,
239: String localName, Attributes attrs) {
240: Object child = null;
241:
242: if (localName.equals("message-destination")) {
243: child = new MessageDestination();
244: }
245: if (localName.equals("security-role")) {
246: child = new SecurityRoleMetaData(
247: "dummy_to_be_replaced_in_setValue");
248: }
249:
250: return child;
251: }
252:
253: /**
254: * Called when parsing of a new element started.
255: */
256: public Object newChild(EnterpriseBeans ejbs,
257: UnmarshallingContext navigator, String namespaceURI,
258: String localName, Attributes attrs) {
259: Object child = null;
260:
261: if ((child = this .newEnvRefGroupChild(localName)) != null) {
262: return child;
263: }
264:
265: if (localName.equals("session")) {
266: ejbClass = SessionEnterpriseBean.class;
267: child = ejbs;
268: } else if (localName.equals("message-driven")) {
269: ejbClass = MessageDrivenBean.class;
270: child = ejbs;
271: } else if (localName.equals("service")) {
272: child = new Service();
273: } else if (localName.equals("consumer")) {
274: child = new Consumer();
275: } else if (localName.equals("method-attributes")) {
276: child = new MethodAttributes();
277: } else if (localName.equals("annotation")) {
278: child = new XmlAnnotation();
279: } else if (localName.equals("ignore-dependency")) {
280: child = new InjectionTarget();
281: } else if (localName.equals("cluster-config")) {
282: child = new ClusterConfig();
283: } else if (localName.equals("remote-binding")) {
284: child = new RemoteBinding();
285: } else if (localName.equals("cache-config")) {
286: child = new CacheConfig();
287: } else if (localName.equals("pool-config")) {
288: child = new PoolConfig();
289: } else if (localName.equals("default-activation-config")) {
290: child = new ActivationConfig();
291: }
292:
293: return child;
294: }
295:
296: public Object newChild(ActivationConfig parent,
297: UnmarshallingContext navigator, String namespaceURI,
298: String localName, Attributes attrs) {
299: Object child = null;
300:
301: if (localName.equals("default-activation-config-property")) {
302: child = new NameValuePair();
303: }
304:
305: return child;
306: }
307:
308: public Object newChild(XmlAnnotation parent,
309: UnmarshallingContext navigator, String namespaceURI,
310: String localName, Attributes attrs) {
311: Object child = null;
312:
313: if (localName.equals("injection-target")) {
314: child = new InjectionTarget();
315: } else if (localName.equals("property")) {
316: child = new NameValuePair();
317: }
318:
319: return child;
320: }
321:
322: public void addChild(XmlAnnotation parent, NameValuePair property,
323: UnmarshallingContext navigator, String namespaceURI,
324: String localName) {
325: parent.addProperty(property);
326: }
327:
328: public void addChild(XmlAnnotation parent,
329: InjectionTarget injectionTarget,
330: UnmarshallingContext navigator, String namespaceURI,
331: String localName) {
332: parent.setInjectionTarget(injectionTarget);
333: }
334:
335: public void addChild(EnterpriseBeans parent,
336: ActivationConfig config, UnmarshallingContext navigator,
337: String namespaceURI, String localName) {
338: parent.setDefaultActivationConfig(config);
339: }
340:
341: public void addChild(ActivationConfig parent,
342: NameValuePair property, UnmarshallingContext navigator,
343: String namespaceURI, String localName) {
344: parent.addActivationConfigProperty(property);
345: }
346:
347: public void addChild(Consumer parent, Producer producer,
348: UnmarshallingContext navigator, String namespaceURI,
349: String localName) {
350: if (producer.isLocal())
351: parent.addLocalProducer(producer);
352: else
353: parent.addProducer(producer);
354: }
355:
356: public void addChild(Consumer parent, RemoteBinding binding,
357: UnmarshallingContext navigator, String namespaceURI,
358: String localName) {
359: parent.addRemoteBinding(binding);
360: }
361:
362: public void addChild(AssemblyDescriptor parent,
363: MessageDestination destination,
364: UnmarshallingContext navigator, String namespaceURI,
365: String localName) {
366: parent.addMessageDestination(destination);
367: }
368:
369: public void addChild(AssemblyDescriptor parent,
370: SecurityRoleMetaData srm, UnmarshallingContext navigator,
371: String namespaceURI, String localName) {
372: parent.addSecurityRoleMetaData(srm);
373: }
374:
375: /**
376: * Called when parsing character is complete.
377: */
378: public void addChild(EnterpriseBeans parent, CacheConfig config,
379: UnmarshallingContext navigator, String namespaceURI,
380: String localName) {
381: parent.setCacheConfig(config);
382: }
383:
384: /**
385: * Called when parsing character is complete.
386: */
387: public void addChild(EnterpriseBeans parent, PoolConfig config,
388: UnmarshallingContext navigator, String namespaceURI,
389: String localName) {
390: parent.setPoolConfig(config);
391: }
392:
393: /**
394: * Called when parsing character is complete.
395: */
396: public void addChild(EnterpriseBeans parent,
397: MethodAttributes attributes,
398: UnmarshallingContext navigator, String namespaceURI,
399: String localName) {
400: parent.setMethodAttributes(attributes);
401: }
402:
403: public void addChild(EnterpriseBeans parent, RemoteBinding binding,
404: UnmarshallingContext navigator, String namespaceURI,
405: String localName) {
406: parent.addRemoteBinding(binding);
407: }
408:
409: public void addChild(EnterpriseBeans parent,
410: InjectionTarget ignoreDependency,
411: UnmarshallingContext navigator, String namespaceURI,
412: String localName) {
413: parent.addIgnoreDependency(ignoreDependency);
414: }
415:
416: public void addChild(EnterpriseBeans parent,
417: XmlAnnotation xmlAnnotation,
418: UnmarshallingContext navigator, String namespaceURI,
419: String localName) {
420: parent.addXmlAnnotation(xmlAnnotation);
421: }
422:
423: public void addChild(MethodAttributes parent, Method method,
424: UnmarshallingContext navigator, String namespaceURI,
425: String localName) {
426: parent.addMethod(method);
427: }
428:
429: public void addChild(Consumer parent, CurrentMessage message,
430: UnmarshallingContext navigator, String namespaceURI,
431: String localName) {
432: parent.setCurrentMessage(message);
433: }
434:
435: public void addChild(Consumer parent, PoolConfig config,
436: UnmarshallingContext navigator, String namespaceURI,
437: String localName) {
438: parent.setPoolConfig(config);
439: }
440:
441: /**
442: * Called when parsing character is complete.
443: */
444: public void addChild(Consumer parent, MessageProperties message,
445: UnmarshallingContext navigator, String namespaceURI,
446: String localName) {
447: parent.setMessageProperties(message);
448: }
449:
450: /**
451: * Called when parsing character is complete.
452: */
453: public void addChild(CurrentMessage parent, Method method,
454: UnmarshallingContext navigator, String namespaceURI,
455: String localName) {
456: parent.addMethod(method);
457: }
458:
459: /**
460: * Called when parsing character is complete.
461: */
462: public void addChild(MessageProperties parent, Method method,
463: UnmarshallingContext navigator, String namespaceURI,
464: String localName) {
465: parent.addMethod(method);
466: }
467:
468: /**
469: * Called when parsing character is complete.
470: */
471: public void addChild(EnterpriseBeans parent, Service service,
472: UnmarshallingContext navigator, String namespaceURI,
473: String localName) {
474: parent.addEnterpriseBean(service);
475: }
476:
477: /**
478: * Called when parsing character is complete.
479: */
480: public void addChild(Service parent, EjbRef ref,
481: UnmarshallingContext navigator, String namespaceURI,
482: String localName) {
483: parent.addEjbRef(ref);
484: }
485:
486: /**
487: * Called when parsing character is complete.
488: */
489: public void addChild(Service parent, RemoteBinding binding,
490: UnmarshallingContext navigator, String namespaceURI,
491: String localName) {
492: parent.addRemoteBinding(binding);
493: }
494:
495: /**
496: * Called when parsing character is complete.
497: */
498: public void addChild(Service parent, EjbLocalRef ref,
499: UnmarshallingContext navigator, String namespaceURI,
500: String localName) {
501: parent.addEjbLocalRef(ref);
502: }
503:
504: /**
505: * Called when parsing character is complete.
506: */
507: public void addChild(Service parent, ResourceRef ref,
508: UnmarshallingContext navigator, String namespaceURI,
509: String localName) {
510: parent.addResourceRef(ref);
511: }
512:
513: /**
514: * Called when parsing character is complete.
515: */
516: public void addChild(Service parent, JndiRef ref,
517: UnmarshallingContext navigator, String namespaceURI,
518: String localName) {
519: parent.addJndiRef(ref);
520: }
521:
522: /**
523: * Called when parsing character is complete.
524: */
525: public void addChild(Service parent, ResourceEnvRef ref,
526: UnmarshallingContext navigator, String namespaceURI,
527: String localName) {
528: parent.addResourceEnvRef(ref);
529: }
530:
531: /**
532: * Called when parsing character is complete.
533: */
534: public void addChild(Consumer parent, EjbRef ref,
535: UnmarshallingContext navigator, String namespaceURI,
536: String localName) {
537: parent.addEjbRef(ref);
538: }
539:
540: /**
541: * Called when parsing character is complete.
542: */
543: public void addChild(Consumer parent, EjbLocalRef ref,
544: UnmarshallingContext navigator, String namespaceURI,
545: String localName) {
546: parent.addEjbLocalRef(ref);
547: }
548:
549: /**
550: * Called when parsing character is complete.
551: */
552: public void addChild(Consumer parent, ResourceRef ref,
553: UnmarshallingContext navigator, String namespaceURI,
554: String localName) {
555: parent.addResourceRef(ref);
556: }
557:
558: /**
559: * Called when parsing character is complete.
560: */
561: public void addChild(Consumer parent, JndiRef ref,
562: UnmarshallingContext navigator, String namespaceURI,
563: String localName) {
564: parent.addJndiRef(ref);
565: }
566:
567: /**
568: * Called when parsing character is complete.
569: */
570: public void addChild(Consumer parent, ResourceEnvRef ref,
571: UnmarshallingContext navigator, String namespaceURI,
572: String localName) {
573: parent.addResourceEnvRef(ref);
574: }
575:
576: /**
577: * Called when parsing character is complete.
578: */
579: public void addChild(EnterpriseBeans parent, Consumer consumer,
580: UnmarshallingContext navigator, String namespaceURI,
581: String localName) {
582: parent.addEnterpriseBean(consumer);
583: }
584:
585: /**
586: * Called when parsing character is complete.
587: */
588: public void addChild(EnterpriseBeans parent, JndiRef ref,
589: UnmarshallingContext navigator, String namespaceURI,
590: String localName) {
591: parent.addJndiRef(ref);
592: }
593:
594: /**
595: * Called when parsing character is complete.
596: */
597: public void addChild(EjbJarDD parent, ResourceManager manager,
598: UnmarshallingContext navigator, String namespaceURI,
599: String localName) {
600: parent.addResourceManager(manager);
601: }
602:
603: /**
604: * Called when parsing character is complete.
605: */
606: public void addChild(EnterpriseBeans parent, EnterpriseBeans ejbs,
607: UnmarshallingContext navigator, String namespaceURI,
608: String localName) {
609: }
610:
611: /**
612: * Called when parsing character is complete.
613: */
614: public void addChild(EnterpriseBeans parent, EjbRef ref,
615: UnmarshallingContext navigator, String namespaceURI,
616: String localName) {
617: parent.updateEjbRef(ref);
618: }
619:
620: /**
621: * Called when parsing character is complete.
622: */
623: public void addChild(EnterpriseBeans parent, EjbLocalRef ref,
624: UnmarshallingContext navigator, String namespaceURI,
625: String localName) {
626: parent.updateEjbLocalRef(ref);
627: }
628:
629: /**
630: * Called when parsing character is complete.
631: */
632: public void addChild(EnterpriseBeans parent, ClusterConfig config,
633: UnmarshallingContext navigator, String namespaceURI,
634: String localName) {
635: parent.setClusterConfig(config);
636: }
637:
638: /**
639: * Called when parsing character is complete.
640: */
641: public void addChild(EnterpriseBeans parent, ResourceRef ref,
642: UnmarshallingContext navigator, String namespaceURI,
643: String localName) {
644: parent.updateResourceRef(ref);
645: }
646:
647: /**
648: * Called when parsing character is complete.
649: */
650: public void addChild(EnterpriseBeans parent,
651: MessageDestinationRef ref, UnmarshallingContext navigator,
652: String namespaceURI, String localName) {
653: parent.updateMessageDestinationRef(ref);
654: }
655:
656: /**
657: * Called when parsing character is complete.
658: */
659: public void addChild(EnterpriseBeans parent,
660: ServiceRefMetaData ref, UnmarshallingContext navigator,
661: String namespaceURI, String localName) {
662: parent.addServiceRef(ref);
663: }
664:
665: /**
666: * Called when parsing character is complete.
667: */
668: public void addChild(EnterpriseBeans parent, ResourceEnvRef ref,
669: UnmarshallingContext navigator, String namespaceURI,
670: String localName) {
671: parent.updateResourceEnvRef(ref);
672: }
673:
674: public void setValue(XmlAnnotation xmlAnnotation,
675: UnmarshallingContext navigator, String namespaceURI,
676: String localName, String value) {
677: if (localName.equals("annotation-class")) {
678: xmlAnnotation
679: .setAnnotationClass(getValue(localName, value));
680: } else if (localName.equals("annotation-implementation-class")) {
681: xmlAnnotation.setAnnotationImplementationClass(getValue(
682: localName, value));
683: }
684: }
685:
686: public void setValue(NameValuePair property,
687: UnmarshallingContext navigator, String namespaceURI,
688: String localName, String value) {
689: if (localName.equals("activation-config-property-name")
690: || localName
691: .equals("message-driven-config-property-name")
692: || localName.equals("property-name")) {
693: property.setName(getValue(localName, value));
694: } else if (localName.equals("activation-config-property-value")
695: || localName
696: .equals("message-driven-config-property-value")
697: || localName.equals("property-value")) {
698: property.setValue(getValue(localName, value));
699: }
700: }
701:
702: public void setValue(ResourceManager manager,
703: UnmarshallingContext navigator, String namespaceURI,
704: String localName, String value) {
705: if (localName.equals("res-name")) {
706: manager.setResourceName(getValue(localName, value));
707: } else if (localName.equals("res-jndi-name")) {
708: manager.setResourceJndiName(getValue(localName, value));
709: }
710: }
711:
712: public void setValue(MessageDestination destination,
713: UnmarshallingContext navigator, String namespaceURI,
714: String localName, String value) {
715: if (localName.equals("message-destination-name")) {
716: destination.setMessageDestinationName(getValue(localName,
717: value));
718: } else if (localName.equals("jndi-name")) {
719: destination.setJndiName(getValue(localName, value));
720: }
721: }
722:
723: public void setValue(EnterpriseBeans ejbs,
724: UnmarshallingContext navigator, String namespaceURI,
725: String localName, String value) {
726: if (localName.equals("ejb-name")) {
727: ejbs.setCurrentEjbName(value, ejbClass);
728: } else if (localName.equals("jndi-name")) {
729: ejbs.setJndiName(getValue(localName, value));
730: } else if (localName.equals("home-jndi-name")) {
731: ejbs.setHomeJndiName(getValue(localName, value));
732: } else if (localName.equals("local-jndi-name")) {
733: ejbs.setLocalJndiName(getValue(localName, value));
734: } else if (localName.equals("local-home-jndi-name")) {
735: ejbs.setLocalHomeJndiName(getValue(localName, value));
736: } else if (localName.equals("security-domain")) {
737: ejbs.setSecurityDomain(getValue(localName, value));
738: } else if (localName.equals("depends")) {
739: ejbs.addDependency(getValue(localName, value));
740: } else if (localName.equals("run-as-principal")) {
741: ejbs.setRunAsPrincipal(getValue(localName, value));
742: } else if (localName.equals("aop-domain-name")) {
743: ejbs.setAopDomainName(getValue(localName, value));
744: } else if (localName.equals("resource-adapter-name")) {
745: ejbs.setResourceAdapterName(getValue(localName, value));
746: } else if (localName.equals("destination-jndi-name")) {
747: ejbs.setDestinationJndiName(getValue(localName, value));
748: } else if (localName.equals("mdb-user")) {
749: ejbs.setMdbUser(getValue(localName, value));
750: } else if (localName.equals("mdb-passwd")) {
751: ejbs.setMdbPassword(getValue(localName, value));
752: } else if (localName.equals("mdb-subscription-id")) {
753: ejbs.setMdbSubscriptionId(getValue(localName, value));
754: } else if (localName.equals("clustered")) {
755: ejbs.setClustered(getValue(localName, value));
756: } else if (localName.equals("concurrent")) {
757: ejbs.setConcurrent(getValue(localName, value));
758: }
759: }
760:
761: /**
762: * Called when a child element with simple content is read for DD.
763: */
764: public void setValue(Service service,
765: UnmarshallingContext navigator, String namespaceURI,
766: String localName, String value) {
767: if (localName.equals("ejb-name")) {
768: service.setEjbName(getValue(localName, value));
769: }
770: if (localName.equals("object-name")) {
771: service.setObjectName(getValue(localName, value));
772: } else if (localName.equals("ejb-class")) {
773: service.setEjbClass(getValue(localName, value));
774: }
775: if (localName.equals("xmbean")) {
776: service.setXMBean(getValue(localName, value));
777: } else if (localName.equals("local")) {
778: service.setLocal(getValue(localName, value));
779: } else if (localName.equals("remote")) {
780: service.setRemote(getValue(localName, value));
781: } else if (localName.equals("management")) {
782: service.setManagement(getValue(localName, value));
783: } else if (localName.equals("jndi-name")) {
784: service.setJndiName(getValue(localName, value));
785: } else if (localName.equals("local-jndi-name")) {
786: service.setLocalJndiName(getValue(localName, value));
787: } else if (localName.equals("security-domain")) {
788: service.setSecurityDomain(getValue(localName, value));
789: } else if (localName.equals("aop-domain-name")) {
790: service.setAopDomainName(getValue(localName, value));
791: } else if (localName.equals("depends")) {
792: service.addDependency(getValue(localName, value));
793: }
794: }
795:
796: /**
797: * Called when a child element with simple content is read for DD.
798: */
799: public void setValue(Consumer consumer,
800: UnmarshallingContext navigator, String namespaceURI,
801: String localName, String value) {
802: if (localName.equals("message-destination")) {
803: consumer.setDestination(getValue(localName, value));
804: } else if (localName.equals("message-destination-type")) {
805: consumer.setDestinationType(getValue(localName, value));
806: } else if (localName.equals("ejb-class")) {
807: consumer.setEjbClass(getValue(localName, value));
808: consumer.setEjbName(getValue(localName, value));
809: } else if (localName.equals("local")) {
810: consumer.setLocal(getValue(localName, value));
811: } else if (localName.equals("remote")) {
812: consumer.setRemote(getValue(localName, value));
813: } else if (localName.equals("jndi-name")) {
814: consumer.setJndiName(getValue(localName, value));
815: } else if (localName.equals("local-jndi-name")) {
816: consumer.setLocalJndiName(getValue(localName, value));
817: } else if (localName.equals("security-domain")) {
818: consumer.setSecurityDomain(getValue(localName, value));
819: } else if (localName.equals("run-as-principal")) {
820: consumer.setRunAsPrincipal(getValue(localName, value));
821: } else if (localName.equals("aop-domain-name")) {
822: consumer.setAopDomainName(getValue(localName, value));
823: } else if (localName.equals("depends")) {
824: consumer.addDependency(getValue(localName, value));
825: }
826: }
827:
828: /**
829: * Called when a child element with simple content is read for DD.
830: */
831: public void setValue(RemoteBinding binding,
832: UnmarshallingContext navigator, String namespaceURI,
833: String localName, String value) {
834: if (localName.equals("jndi-name")) {
835: binding.setJndiName(getValue(localName, value));
836: } else if (localName.equals("client-bind-url")) {
837: binding.setClientBindUrl(getValue(localName, value));
838: } else if (localName.equals("proxy-factory")) {
839: binding.setProxyFactory(getValue(localName, value));
840: } else if (localName.equals("interceptor-stack")) {
841: binding.setInterceptorStack(getValue(localName, value));
842: }
843: }
844:
845: /**
846: * Called when a child element with simple content is read for DD.
847: */
848: public void setValue(MessageProperties properties,
849: UnmarshallingContext navigator, String namespaceURI,
850: String localName, String value) {
851: if (localName.equals("delivery")) {
852: properties.setDelivery(getValue(localName, value));
853: } else if (localName.equals("class")) {
854: properties.setClassName(getValue(localName, value));
855: } else if (localName.equals("priority")) {
856: properties.setPriority(getValue(localName, value));
857: }
858: }
859:
860: /**
861: * Called when a child element with simple content is read for DD.
862: */
863: public void setValue(ClusterConfig config,
864: UnmarshallingContext navigator, String namespaceURI,
865: String localName, String value) {
866: if (localName.equals("load-balance-policy")) {
867: config.setLoadBalancePolicy(getValue(localName, value));
868: } else if (localName.equals("partition-name")) {
869: config.setPartition(getValue(localName, value));
870: }
871: }
872:
873: /**
874: * Called when a child element with simple content is read for DD.
875: */
876: public void setValue(CacheConfig config,
877: UnmarshallingContext navigator, String namespaceURI,
878: String localName, String value) {
879: if (localName.equals("cache-class")) {
880: config.setCacheClass(getValue(localName, value));
881: } else if (localName.equals("cache-max-size")) {
882: config.setMaxSize(getValue(localName, value));
883: } else if (localName.equals("idle-timeout-seconds")) {
884: config.setIdleTimeoutSeconds(getValue(localName, value));
885: } else if (localName.equals("remove-timeout-seconds")) {
886: config.setRemoveTimeoutSeconds(getValue(localName, value));
887: } else if (localName.equals("cache-name")) {
888: config.setName(getValue(localName, value));
889: } else if (localName.equals("persistence-manager")) {
890: config.setPersistenceManager(getValue(localName, value));
891: } else if (localName.equals("replication-is-passivation")) {
892: config.setReplicationIsPassivation(getValue(localName,
893: value));
894: }
895: }
896:
897: /**
898: * Called when a child element with simple content is read for DD.
899: */
900: public void setValue(PoolConfig config,
901: UnmarshallingContext navigator, String namespaceURI,
902: String localName, String value) {
903: if (localName.equals("pool-class")) {
904: config.setPoolClass(getValue(localName, value));
905: } else if (localName.equals("pool-max-size")) {
906: config.setMaxSize(getValue(localName, value));
907: } else if (localName.equals("pool-timeout")) {
908: config.setTimeout(getValue(localName, value));
909: }
910: }
911:
912: /**
913: * Called when a child element with simple content is read for DD.
914: */
915: public void setValue(Method method, UnmarshallingContext navigator,
916: String namespaceURI, String localName, String value) {
917: if (localName.equals("method-name")) {
918: method.setMethodName(getValue(localName, value));
919: } else if (localName.equals("transaction-timeout")) {
920: method.setTransactionTimeout(getValue(localName, value));
921: }
922: }
923:
924: /**
925: * Called when a child element with simple content is read for DD.
926: */
927: public void setValue(EjbJarDD dd, UnmarshallingContext navigator,
928: String namespaceURI, String localName, String value) {
929: if (localName.equals("security-domain")) {
930: dd.setSecurityDomain(getValue(localName, value));
931: } else if (localName.equals("unauthenticated-principal")) {
932: dd.setUnauthenticatedPrincipal(getValue(localName, value));
933: } else if (localName.equals("jmx-name")) {
934: dd.setJmxName(getValue(localName, value));
935: }
936: }
937:
938: /**
939: * Called when a child element with simple content is read for DD.
940: */
941: public void setValue(Producer producer,
942: UnmarshallingContext navigator, String namespaceURI,
943: String localName, String value) {
944: if (localName.equals("class")) {
945: producer.setClassName(getValue(localName, value));
946: } else if (localName.equals("connection-factory")) {
947: producer.setConnectionFactory(getValue(localName, value));
948: }
949: }
950:
951: /**
952: * Called when a child element with simple content is read for DD.
953: */
954: public void setValue(SecurityRoleMetaData srm,
955: UnmarshallingContext navigator, String namespaceURI,
956: String localName, String value) {
957: if (localName.equals("role-name")) {
958: // FIXME: NYI
959: // srm.setRoleName(getValue(localName, value));
960: throw new RuntimeException("NYI");
961: } else if (localName.equals("principal-name")) {
962: srm.addPrincipalName(getValue(localName, value));
963: }
964: }
965:
966: // may want to run StringPropertyReplacer on the whole descriptor at once
967: protected String getValue(String name, String value) {
968: if (value.startsWith("${") && value.endsWith("}")) {
969: String replacement = StringPropertyReplacer
970: .replaceProperties(value);
971: if (replacement != null)
972: value = replacement;
973: }
974: return value;
975: }
976: }
|