1 22 package org.jboss.ejb3.metamodel; 23 24 import java.io.IOException ; 25 import java.net.URL ; 26 27 import javax.management.ObjectName ; 28 29 import org.jboss.ejb3.KernelAbstraction; 30 import org.jboss.ejb3.KernelAbstractionFactory; 31 import org.jboss.logging.Logger; 32 import org.jboss.util.xml.JBossEntityResolver; 33 import org.jboss.xb.binding.JBossXBException; 34 import org.jboss.xb.binding.ObjectModelFactory; 35 import org.jboss.xb.binding.Unmarshaller; 36 import org.jboss.xb.binding.UnmarshallerFactory; 37 import org.jboss.xb.binding.UnmarshallingContext; 38 import org.xml.sax.Attributes ; 39 40 import org.jboss.metamodel.descriptor.DDObjectFactory; 41 import org.jboss.metamodel.descriptor.EjbLocalRef; 42 import org.jboss.metamodel.descriptor.EjbRef; 43 import org.jboss.metamodel.descriptor.EnvEntry; 44 import org.jboss.metamodel.descriptor.InjectionTarget; 45 import org.jboss.metamodel.descriptor.JndiRef; 46 import org.jboss.metamodel.descriptor.MessageDestinationRef; 47 import org.jboss.metamodel.descriptor.NameValuePair; 48 import org.jboss.metamodel.descriptor.ResourceEnvRef; 49 import org.jboss.metamodel.descriptor.ResourceRef; 50 import org.jboss.metamodel.descriptor.SecurityRole; 51 import org.jboss.metamodel.descriptor.ServiceRef; 52 53 59 public class JBossDDObjectFactory extends DDObjectFactory 60 { 61 private static final Logger log = Logger 62 .getLogger(JBossDDObjectFactory.class); 63 64 private EjbJarDD dd; 65 private Class ejbClass; 66 67 public static EjbJarDD parse(URL ddResource, EjbJarDD dd) 68 throws JBossXBException, IOException 69 { 70 ObjectModelFactory factory = null; 71 Unmarshaller unmarshaller = null; 72 73 if (ddResource != null) 74 { 75 log.debug("found jboss.xml " + ddResource); 76 77 if (dd == null) 78 dd = new EjbJarDD(); 79 80 factory = new JBossDDObjectFactory(dd); 81 UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance(); 82 unmarshallerFactory.setFeature(Unmarshaller.SCHEMA_VALIDATION, Boolean.TRUE); 83 unmarshaller = unmarshallerFactory.newUnmarshaller(); 84 JBossEntityResolver entityResolver = new JBossEntityResolver(); 85 unmarshaller.setEntityResolver(entityResolver); 86 87 dd = (EjbJarDD) unmarshaller.unmarshal(ddResource.openStream(), 88 factory, null); 89 } 90 91 return dd; 92 } 93 94 public JBossDDObjectFactory(EjbJarDD dd) 95 { 96 super(); 97 this.dd = dd; 98 } 99 100 103 public Object newRoot(Object root, UnmarshallingContext navigator, 104 String namespaceURI, String localName, Attributes attrs) 105 { 106 return dd; 107 } 108 109 public Object completeRoot(Object root, UnmarshallingContext ctx, 110 String uri, String name) 111 { 112 return root; 113 } 114 115 117 120 public Object newChild(EjbJarDD dd, UnmarshallingContext navigator, 121 String namespaceURI, String localName, Attributes attrs) 122 { 123 Object child = null; 124 125 if (localName.equals("enterprise-beans")) 126 { 127 child = dd.getEnterpriseBeans(); 128 if (child == null) 129 { 130 dd.setEnterpriseBeans(new EnterpriseBeans()); 131 child = dd.getEnterpriseBeans(); 132 } 133 } 134 else if (localName.equals("assembly-descriptor")) 135 { 136 child = dd.getAssemblyDescriptor(); 137 if (child == null) 138 { 139 dd.setAssemblyDescriptor(new AssemblyDescriptor()); 140 child = dd.getAssemblyDescriptor(); 141 } 142 } 143 else if (localName.equals("resource-manager")) 144 { 145 child = new ResourceManager(); 146 } 147 148 return child; 149 } 150 151 154 public Object newChild(Consumer consumer, UnmarshallingContext navigator, 155 String namespaceURI, String localName, Attributes attrs) 156 { 157 Object child = null; 158 159 if ((child = this.newEnvRefGroupChild(localName)) != null) 160 return child; 161 162 if (localName.equals("current-message")) 163 { 164 child = new CurrentMessage(); 165 } 166 else if (localName.equals("message-properties")) 167 { 168 child = new MessageProperties(); 169 } 170 else if (localName.equals("producer")) 171 { 172 child = new Producer(false); 173 } 174 else if (localName.equals("local-producer")) 175 { 176 child = new Producer(true); 177 } 178 else if (localName.equals("annotation")) 179 { 180 child = new XmlAnnotation(); 181 } 182 else if (localName.equals("ignore-dependency")) 183 { 184 child = new InjectionTarget(); 185 } 186 else if (localName.equals("remote-binding")) 187 { 188 child = new RemoteBinding(); 189 } 190 else if (localName.equals("pool-config")) 191 { 192 child = new PoolConfig(); 193 } 194 195 return child; 196 } 197 198 201 public Object newChild(Service service, UnmarshallingContext navigator, 202 String namespaceURI, String localName, Attributes attrs) 203 { 204 Object child = null; 205 206 if ((child = this.newEnvRefGroupChild(localName)) != null) 207 return child; 208 209 if (localName.equals("ignore-dependency")) 210 { 211 child = new InjectionTarget(); 212 } 213 else if (localName.equals("annotation")) 214 { 215 child = new XmlAnnotation(); 216 } 217 else if (localName.equals("remote-binding")) 218 { 219 child = new RemoteBinding(); 220 } 221 222 return child; 223 } 224 225 228 public Object newChild(CurrentMessage message, UnmarshallingContext navigator, 229 String namespaceURI, String localName, Attributes attrs) 230 { 231 Object child = null; 232 233 if (localName.equals("method")) 234 { 235 child = new Method(); 236 } 237 238 return child; 239 } 240 241 244 public Object newChild(MessageProperties properties, UnmarshallingContext navigator, 245 String namespaceURI, String localName, Attributes attrs) 246 { 247 Object child = null; 248 249 if (localName.equals("method")) 250 { 251 child = new Method(); 252 } 253 254 return child; 255 } 256 257 260 public Object newChild(MethodAttributes attributes, UnmarshallingContext navigator, 261 String namespaceURI, String localName, Attributes attrs) 262 { 263 Object child = null; 264 265 if (localName.equals("method")) 266 { 267 child = new Method(); 268 } 269 270 return child; 271 } 272 273 276 public Object newChild(AssemblyDescriptor descriptor, 277 UnmarshallingContext navigator, String namespaceURI, String localName, 278 Attributes attrs) 279 { 280 Object child = null; 281 282 if (localName.equals("message-destination")) 283 { 284 child = new MessageDestination(); 285 } 286 287 return child; 288 } 289 290 293 public Object newChild(EnterpriseBeans ejbs, UnmarshallingContext navigator, 294 String namespaceURI, String localName, Attributes attrs) 295 { 296 Object child = null; 297 298 if ((child = this.newEnvRefGroupChild(localName)) != null) 299 { 300 return child; 301 } 302 303 if (localName.equals("session")) 304 { 305 ejbClass = SessionEnterpriseBean.class; 306 child = ejbs; 307 } 308 else if (localName.equals("message-driven")) 309 { 310 ejbClass = MessageDrivenBean.class; 311 child = ejbs; 312 } 313 else if (localName.equals("service")) 314 { 315 child = new Service(); 316 } 317 else if (localName.equals("consumer")) 318 { 319 child = new Consumer(); 320 } 321 else if (localName.equals("method-attributes")) 322 { 323 child = new MethodAttributes(); 324 } 325 else if (localName.equals("annotation")) 326 { 327 child = new XmlAnnotation(); 328 } 329 else if (localName.equals("ignore-dependency")) 330 { 331 child = new InjectionTarget(); 332 } 333 else if (localName.equals("cluster-config")) 334 { 335 child = new ClusterConfig(); 336 } 337 else if (localName.equals("remote-binding")) 338 { 339 child = new RemoteBinding(); 340 } 341 else if (localName.equals("cache-config")) 342 { 343 child = new CacheConfig(); 344 } 345 else if (localName.equals("pool-config")) 346 { 347 child = new PoolConfig(); 348 } 349 else if (localName.equals("default-activation-config")) 350 { 351 child = new ActivationConfig(); 352 } 353 354 return child; 355 } 356 357 public Object newChild(ActivationConfig parent, 358 UnmarshallingContext navigator, String namespaceURI, String localName, 359 Attributes attrs) 360 { 361 Object child = null; 362 363 if (localName.equals("default-activation-config-property")) 364 { 365 child = new NameValuePair(); 366 } 367 368 return child; 369 } 370 371 public Object newChild(XmlAnnotation parent, 372 UnmarshallingContext navigator, String namespaceURI, String localName, 373 Attributes attrs) 374 { 375 Object child = null; 376 377 if (localName.equals("injection-target")) 378 { 379 child = new InjectionTarget(); 380 } 381 else if (localName.equals("property")) 382 { 383 child = new NameValuePair(); 384 } 385 386 return child; 387 } 388 389 public void addChild(XmlAnnotation parent, NameValuePair property, 390 UnmarshallingContext navigator, String namespaceURI, String localName) 391 { 392 parent.addProperty(property); 393 } 394 395 public void addChild(XmlAnnotation parent, InjectionTarget injectionTarget, 396 UnmarshallingContext navigator, String namespaceURI, String localName) 397 { 398 parent.setInjectionTarget(injectionTarget); 399 } 400 401 public void addChild(EnterpriseBeans parent, ActivationConfig config, 402 UnmarshallingContext navigator, String namespaceURI, String localName) 403 { 404 parent.setDefaultActivationConfig(config); 405 } 406 407 public void addChild(ActivationConfig parent, NameValuePair property, 408 UnmarshallingContext navigator, String namespaceURI, String localName) 409 { 410 parent.addActivationConfigProperty(property); 411 } 412 413 public void addChild(Consumer parent, Producer producer, 414 UnmarshallingContext navigator, String namespaceURI, String localName) 415 { 416 if (producer.isLocal()) 417 parent.addLocalProducer(producer); 418 else 419 parent.addProducer(producer); 420 } 421 422 public void addChild(Consumer parent, RemoteBinding binding, 423 UnmarshallingContext navigator, String namespaceURI, String localName) 424 { 425 parent.addRemoteBinding(binding); 426 } 427 428 public void addChild(AssemblyDescriptor parent, MessageDestination destination, 429 UnmarshallingContext navigator, String namespaceURI, String localName) 430 { 431 parent.addMessageDestination(destination); 432 } 433 434 435 438 public void addChild(EnterpriseBeans parent, CacheConfig config, 439 UnmarshallingContext navigator, String namespaceURI, String localName) 440 { 441 parent.setCacheConfig(config); 442 } 443 444 447 public void addChild(EnterpriseBeans parent, PoolConfig config, 448 UnmarshallingContext navigator, String namespaceURI, String localName) 449 { 450 parent.setPoolConfig(config); 451 } 452 453 456 public void addChild(EnterpriseBeans parent, MethodAttributes attributes, 457 UnmarshallingContext navigator, String namespaceURI, String localName) 458 { 459 parent.setMethodAttributes(attributes); 460 } 461 462 public void addChild(EnterpriseBeans parent, RemoteBinding binding, 463 UnmarshallingContext navigator, String namespaceURI, String localName) 464 { 465 parent.addRemoteBinding(binding); 466 } 467 468 public void addChild(EnterpriseBeans parent, InjectionTarget ignoreDependency, 469 UnmarshallingContext navigator, String namespaceURI, String localName) 470 { 471 parent.addIgnoreDependency(ignoreDependency); 472 } 473 474 public void addChild(EnterpriseBeans parent, XmlAnnotation xmlAnnotation, 475 UnmarshallingContext navigator, String namespaceURI, String localName) 476 { 477 parent.addXmlAnnotation(xmlAnnotation); 478 } 479 480 public void addChild(MethodAttributes parent, Method method, 481 UnmarshallingContext navigator, String namespaceURI, String localName) 482 { 483 parent.addMethod(method); 484 } 485 486 public void addChild(Consumer parent, CurrentMessage message, 487 UnmarshallingContext navigator, String namespaceURI, String localName) 488 { 489 parent.setCurrentMessage(message); 490 } 491 492 public void addChild(Consumer parent, PoolConfig config, 493 UnmarshallingContext navigator, String namespaceURI, String localName) 494 { 495 parent.setPoolConfig(config); 496 } 497 498 501 public void addChild(Consumer parent, MessageProperties message, 502 UnmarshallingContext navigator, String namespaceURI, String localName) 503 { 504 parent.setMessageProperties(message); 505 } 506 507 510 public void addChild(CurrentMessage parent, Method method, 511 UnmarshallingContext navigator, String namespaceURI, String localName) 512 { 513 parent.addMethod(method); 514 } 515 516 519 public void addChild(MessageProperties parent, Method method, 520 UnmarshallingContext navigator, String namespaceURI, String localName) 521 { 522 parent.addMethod(method); 523 } 524 525 528 public void addChild(EnterpriseBeans parent, Service service, 529 UnmarshallingContext navigator, String namespaceURI, String localName) 530 { 531 parent.addEnterpriseBean(service); 532 } 533 534 537 public void addChild(Service parent, EjbRef ref, 538 UnmarshallingContext navigator, String namespaceURI, String localName) 539 { 540 parent.addEjbRef(ref); 541 } 542 543 546 public void addChild(Service parent, RemoteBinding binding, 547 UnmarshallingContext navigator, String namespaceURI, String localName) 548 { 549 parent.addRemoteBinding(binding); 550 } 551 552 555 public void addChild(Service parent, EjbLocalRef ref, 556 UnmarshallingContext navigator, String namespaceURI, String localName) 557 { 558 parent.addEjbLocalRef(ref); 559 } 560 561 564 public void addChild(Service parent, ResourceRef ref, 565 UnmarshallingContext navigator, String namespaceURI, String localName) 566 { 567 parent.addResourceRef(ref); 568 } 569 570 573 public void addChild(Service parent, JndiRef ref, 574 UnmarshallingContext navigator, String namespaceURI, String localName) 575 { 576 parent.addJndiRef(ref); 577 } 578 579 582 public void addChild(Service parent, ResourceEnvRef ref, 583 UnmarshallingContext navigator, String namespaceURI, String localName) 584 { 585 parent.addResourceEnvRef(ref); 586 } 587 588 591 public void addChild(Consumer parent, EjbRef ref, 592 UnmarshallingContext navigator, String namespaceURI, String localName) 593 { 594 parent.addEjbRef(ref); 595 } 596 597 600 public void addChild(Consumer parent, EjbLocalRef ref, 601 UnmarshallingContext navigator, String namespaceURI, String localName) 602 { 603 parent.addEjbLocalRef(ref); 604 } 605 606 609 public void addChild(Consumer parent, ResourceRef ref, 610 UnmarshallingContext navigator, String namespaceURI, String localName) 611 { 612 parent.addResourceRef(ref); 613 } 614 615 618 public void addChild(Consumer parent, JndiRef ref, 619 UnmarshallingContext navigator, String namespaceURI, String localName) 620 { 621 parent.addJndiRef(ref); 622 } 623 624 627 public void addChild(Consumer parent, ResourceEnvRef ref, 628 UnmarshallingContext navigator, String namespaceURI, String localName) 629 { 630 parent.addResourceEnvRef(ref); 631 } 632 633 636 public void addChild(EnterpriseBeans parent, Consumer consumer, 637 UnmarshallingContext navigator, String namespaceURI, String localName) 638 { 639 parent.addEnterpriseBean(consumer); 640 } 641 642 645 public void addChild(EnterpriseBeans parent, JndiRef ref, 646 UnmarshallingContext navigator, String namespaceURI, String localName) 647 { 648 parent.addJndiRef(ref); 649 } 650 651 654 public void addChild(EjbJarDD parent, ResourceManager manager, 655 UnmarshallingContext navigator, String namespaceURI, String localName) 656 { 657 parent.addResourceManager(manager); 658 } 659 660 663 public void addChild(EnterpriseBeans parent, EnterpriseBeans ejbs, 664 UnmarshallingContext navigator, String namespaceURI, String localName) 665 { 666 667 } 668 669 672 public void addChild(EnterpriseBeans parent, EjbRef ref, 673 UnmarshallingContext navigator, String namespaceURI, String localName) 674 { 675 parent.updateEjbRef(ref); 676 } 677 678 681 public void addChild(EnterpriseBeans parent, EjbLocalRef ref, 682 UnmarshallingContext navigator, String namespaceURI, String localName) 683 { 684 parent.updateEjbLocalRef(ref); 685 } 686 687 690 public void addChild(EnterpriseBeans parent, ClusterConfig config, 691 UnmarshallingContext navigator, String namespaceURI, String localName) 692 { 693 parent.setClusterConfig(config); 694 } 695 696 699 public void addChild(EnterpriseBeans parent, ResourceRef ref, 700 UnmarshallingContext navigator, String namespaceURI, String localName) 701 { 702 parent.updateResourceRef(ref); 703 } 704 705 708 public void addChild(EnterpriseBeans parent, MessageDestinationRef ref, 709 UnmarshallingContext navigator, String namespaceURI, String localName) 710 { 711 parent.updateMessageDestinationRef(ref); 712 } 713 714 717 public void addChild(EnterpriseBeans parent, ServiceRef ref, 718 UnmarshallingContext navigator, String namespaceURI, String localName) 719 { 720 parent.addServiceRef(ref); 721 } 722 723 726 public void addChild(EnterpriseBeans parent, ResourceEnvRef ref, 727 UnmarshallingContext navigator, String namespaceURI, String localName) 728 { 729 parent.updateResourceEnvRef(ref); 730 } 731 732 public void setValue(XmlAnnotation xmlAnnotation, UnmarshallingContext navigator, 733 String namespaceURI, String localName, String value) 734 { 735 if (localName.equals("annotation-class")) 736 { 737 xmlAnnotation.setAnnotationClass(getValue(localName, value)); 738 } 739 else if (localName.equals("annotation-implementation-class")) 740 { 741 xmlAnnotation.setAnnotationImplementationClass(getValue(localName, value)); 742 } 743 } 744 745 public void setValue(NameValuePair property, UnmarshallingContext navigator, 746 String namespaceURI, String localName, String value) 747 { 748 if (localName.equals("activation-config-property-name") || localName.equals("message-driven-config-property-name") || localName.equals("property-name")) 749 { 750 property.setName(getValue(localName, value)); 751 } 752 else if (localName.equals("activation-config-property-value") || localName.equals("message-driven-config-property-value") || localName.equals("property-value")) 753 { 754 property.setValue(getValue(localName, value)); 755 } 756 } 757 758 public void setValue(ResourceManager manager, UnmarshallingContext navigator, 759 String namespaceURI, String localName, String value) 760 { 761 if (localName.equals("res-name")) 762 { 763 manager.setResourceName(getValue(localName, value)); 764 } 765 else if (localName.equals("res-jndi-name")) 766 { 767 manager.setResourceJndiName(getValue(localName, value)); 768 } 769 } 770 771 public void setValue(MessageDestination destination, UnmarshallingContext navigator, 772 String namespaceURI, String localName, String value) 773 { 774 if (localName.equals("message-destination-name")) 775 { 776 destination.setMessageDestinationName(getValue(localName, value)); 777 } 778 else if (localName.equals("jndi-name")) 779 { 780 destination.setJndiName(getValue(localName, value)); 781 } 782 } 783 784 public void setValue(EnterpriseBeans ejbs, UnmarshallingContext navigator, 785 String namespaceURI, String localName, String value) 786 { 787 if (localName.equals("ejb-name")) 788 { 789 ejbs.setCurrentEjbName(value, ejbClass); 790 } 791 else if (localName.equals("jndi-name")) 792 { 793 ejbs.setJndiName(getValue(localName, value)); 794 } 795 else if (localName.equals("local-jndi-name")) 796 { 797 ejbs.setLocalJndiName(getValue(localName, value)); 798 } 799 else if (localName.equals("security-domain")) 800 { 801 ejbs.setSecurityDomain(getValue(localName, value)); 802 } 803 else if (localName.equals("depends")) 804 { 805 ejbs.addDependency(getValue(localName, value)); 806 } 807 else if (localName.equals("run-as-principal")) 808 { 809 ejbs.setRunAsPrincipal(getValue(localName, value)); 810 } 811 else if (localName.equals("aop-domain-name")) 812 { 813 ejbs.setAopDomainName(getValue(localName, value)); 814 } 815 else if (localName.equals("resource-adapter-name")) 816 { 817 ejbs.setResourceAdapterName(getValue(localName, value)); 818 } 819 else if (localName.equals("destination-jndi-name")) 820 { 821 ejbs.setDestinationJndiName(getValue(localName, value)); 822 } 823 else if (localName.equals("mdb-user")) 824 { 825 ejbs.setMdbUser(getValue(localName, value)); 826 } 827 else if (localName.equals("mdb-passwd")) 828 { 829 ejbs.setMdbPassword(getValue(localName, value)); 830 } 831 else if (localName.equals("mdb-subscription-id")) 832 { 833 ejbs.setMdbSubscriptionId(getValue(localName, value)); 834 } 835 else if (localName.equals("clustered")) 836 { 837 ejbs.setClustered(getValue(localName, value)); 838 } 839 else if (localName.equals("concurrent")) 840 { 841 ejbs.setConcurrent(getValue(localName, value)); 842 } 843 } 844 845 848 public void setValue(Service service, UnmarshallingContext navigator, 849 String namespaceURI, String localName, String value) 850 { 851 if (localName.equals("ejb-name")) 852 { 853 service.setEjbName(getValue(localName, value)); 854 } 855 if (localName.equals("object-name")) 856 { 857 service.setObjectName(getValue(localName, value)); 858 } 859 else if (localName.equals("ejb-class")) 860 { 861 service.setEjbClass(getValue(localName, value)); 862 } 863 else if (localName.equals("local")) 864 { 865 service.setLocal(getValue(localName, value)); 866 } 867 else if (localName.equals("remote")) 868 { 869 service.setRemote(getValue(localName, value)); 870 } 871 else if (localName.equals("management")) 872 { 873 service.setManagement(getValue(localName, value)); 874 } 875 else if (localName.equals("jndi-name")) 876 { 877 service.setJndiName(getValue(localName, value)); 878 } 879 else if (localName.equals("local-jndi-name")) 880 { 881 service.setLocalJndiName(getValue(localName, value)); 882 } 883 else if (localName.equals("security-domain")) 884 { 885 service.setSecurityDomain(getValue(localName, value)); 886 } 887 else if (localName.equals("aop-domain-name")) 888 { 889 service.setAopDomainName(getValue(localName, value)); 890 } 891 else if (localName.equals("depends")) 892 { 893 service.addDependency(getValue(localName, value)); 894 } 895 } 896 897 900 public void setValue(Consumer consumer, UnmarshallingContext navigator, 901 String namespaceURI, String localName, String value) 902 { 903 if (localName.equals("message-destination")) 904 { 905 consumer.setDestination(getValue(localName, value)); 906 } 907 else if (localName.equals("message-destination-type")) 908 { 909 consumer.setDestinationType(getValue(localName, value)); 910 } 911 else if (localName.equals("ejb-class")) 912 { 913 consumer.setEjbClass(getValue(localName, value)); 914 consumer.setEjbName(getValue(localName, value)); 915 } 916 else if (localName.equals("local")) 917 { 918 consumer.setLocal(getValue(localName, value)); 919 } 920 else if (localName.equals("remote")) 921 { 922 consumer.setRemote(getValue(localName, value)); 923 } 924 else if (localName.equals("jndi-name")) 925 { 926 consumer.setJndiName(getValue(localName, value)); 927 } 928 else if (localName.equals("local-jndi-name")) 929 { 930 consumer.setLocalJndiName(getValue(localName, value)); 931 } 932 else if (localName.equals("security-domain")) 933 { 934 consumer.setSecurityDomain(getValue(localName, value)); 935 } 936 else if (localName.equals("run-as-principal")) 937 { 938 consumer.setRunAsPrincipal(getValue(localName, value)); 939 } 940 else if (localName.equals("aop-domain-name")) 941 { 942 consumer.setAopDomainName(getValue(localName, value)); 943 } 944 else if (localName.equals("depends")) 945 { 946 consumer.addDependency(getValue(localName, value)); 947 } 948 } 949 950 953 public void setValue(RemoteBinding binding, UnmarshallingContext navigator, 954 String namespaceURI, String localName, String value) 955 { 956 if (localName.equals("jndi-name")) 957 { 958 binding.setJndiName(getValue(localName, value)); 959 } 960 else if (localName.equals("client-bind-url")) 961 { 962 binding.setClientBindUrl(getValue(localName, value)); 963 } 964 else if (localName.equals("proxy-factory")) 965 { 966 binding.setProxyFactory(getValue(localName, value)); 967 } 968 else if (localName.equals("interceptor-stack")) 969 { 970 binding.setInterceptorStack(getValue(localName, value)); 971 } 972 } 973 974 977 public void setValue(MessageProperties properties, UnmarshallingContext navigator, 978 String namespaceURI, String localName, String value) 979 { 980 if (localName.equals("delivery")) 981 { 982 properties.setDelivery(getValue(localName, value)); 983 } 984 else if (localName.equals("class")) 985 { 986 properties.setClassName(getValue(localName, value)); 987 } 988 else if (localName.equals("priority")) 989 { 990 properties.setPriority(getValue(localName, value)); 991 } 992 } 993 994 997 public void setValue(ClusterConfig config, UnmarshallingContext navigator, 998 String namespaceURI, String localName, String value) 999 { 1000 if (localName.equals("load-balance-policy")) 1001 { 1002 config.setLoadBalancePolicy(getValue(localName, value)); 1003 } 1004 else if (localName.equals("partition-name")) 1005 { 1006 config.setPartition(getValue(localName, value)); 1007 } 1008 } 1009 1010 1013 public void setValue(CacheConfig config, UnmarshallingContext navigator, 1014 String namespaceURI, String localName, String value) 1015 { 1016 if (localName.equals("cache-class")) 1017 { 1018 config.setCacheClass(getValue(localName, value)); 1019 } 1020 else if (localName.equals("cache-max-size")) 1021 { 1022 config.setMaxSize(getValue(localName, value)); 1023 } 1024 else if (localName.equals("idle-timeout-seconds")) 1025 { 1026 config.setIdleTimeoutSeconds(getValue(localName, value)); 1027 } 1028 else if (localName.equals("cache-name")) 1029 { 1030 config.setName(getValue(localName, value)); 1031 } 1032 else if (localName.equals("persistence-manager")) 1033 { 1034 config.setPersistenceManager(getValue(localName, value)); 1035 } 1036 } 1037 1038 1041 public void setValue(PoolConfig config, UnmarshallingContext navigator, 1042 String namespaceURI, String localName, String value) 1043 { 1044 if (localName.equals("pool-class")) 1045 { 1046 config.setPoolClass(getValue(localName, value)); 1047 } 1048 else if (localName.equals("pool-max-size")) 1049 { 1050 config.setMaxSize(getValue(localName, value)); 1051 } 1052 else if (localName.equals("pool-timeout")) 1053 { 1054 config.setTimeout(getValue(localName, value)); 1055 } 1056 } 1057 1058 1059 1062 public void setValue(Method method, UnmarshallingContext navigator, 1063 String namespaceURI, String localName, String value) 1064 { 1065 if (localName.equals("method-name")) 1066 { 1067 method.setMethodName(getValue(localName, value)); 1068 } 1069 else if (localName.equals("transaction-timeout")) 1070 { 1071 method.setTransactionTimeout(getValue(localName, value)); 1072 } 1073 } 1074 1075 1078 public void setValue(EjbJarDD dd, UnmarshallingContext navigator, 1079 String namespaceURI, String localName, String value) 1080 { 1081 if (localName.equals("security-domain")) 1082 { 1083 dd.setSecurityDomain(getValue(localName, value)); 1084 } 1085 else if (localName.equals("unauthenticated-principal")) 1086 { 1087 dd.setUnauthenticatedPrincipal(getValue(localName, value)); 1088 } 1089 else if (localName.equals("jmx-name")) 1090 { 1091 dd.setJmxName(getValue(localName, value)); 1092 } 1093 } 1094 1095 1098 public void setValue(Producer producer, UnmarshallingContext navigator, 1099 String namespaceURI, String localName, String value) 1100 { 1101 if (localName.equals("class")) 1102 { 1103 producer.setClassName(getValue(localName, value)); 1104 } 1105 else if (localName.equals("connection-factory")) 1106 { 1107 producer.setConnectionFactory(getValue(localName, value)); 1108 } 1109 } 1110 1111 protected String getValue(String name, String value) 1112 { 1113 if (value.startsWith("${") && value.endsWith("}")) 1114 { 1115 try 1116 { 1117 String propertyName = value.substring(2, value.length()-1); 1118 ObjectName propertyServiceON = new ObjectName ("jboss:type=Service,name=SystemProperties"); 1119 KernelAbstraction kernelAbstraction = KernelAbstractionFactory.getInstance(); 1120 String propertyValue = (String )kernelAbstraction.invoke(propertyServiceON, "get", new Object []{propertyName}, new String []{"java.lang.String"}); 1121 log.debug("Replaced jboss.xml element " + name + " with value " + propertyValue); 1122 return propertyValue; 1123 } 1124 catch (Exception e) 1125 { 1126 log.warn("Unable to look up property service for jboss.xml element " + name + " with value " + value + ". Caused by " + e.getClass() + " " + e.getMessage()); 1127 } 1128 } 1129 1130 return value; 1131 } 1132 1133} 1134 | Popular Tags |