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 import javax.persistence.PersistenceContextType; 29 30 import org.jboss.ejb3.KernelAbstraction; 31 import org.jboss.ejb3.KernelAbstractionFactory; 32 import org.jboss.logging.Logger; 33 import org.jboss.util.xml.JBossEntityResolver; 34 import org.jboss.xb.binding.JBossXBException; 35 import org.jboss.xb.binding.ObjectModelFactory; 36 import org.jboss.xb.binding.Unmarshaller; 37 import org.jboss.xb.binding.UnmarshallerFactory; 38 import org.jboss.xb.binding.UnmarshallingContext; 39 import org.xml.sax.Attributes ; 40 41 import org.jboss.metamodel.descriptor.DDObjectFactory; 42 import org.jboss.metamodel.descriptor.EjbLocalRef; 43 import org.jboss.metamodel.descriptor.EjbRef; 44 import org.jboss.metamodel.descriptor.EnvEntry; 45 import org.jboss.metamodel.descriptor.MessageDestinationRef; 46 import org.jboss.metamodel.descriptor.PersistenceUnitRef; 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.RunAs; 51 import org.jboss.metamodel.descriptor.ServiceRef; 52 import org.jboss.metamodel.descriptor.SecurityRole; 53 import org.jboss.metamodel.descriptor.PersistenceContextRef; 54 55 62 public class EjbJarDDObjectFactory extends DDObjectFactory 63 { 64 65 private static final Logger log = Logger 66 .getLogger(EjbJarDDObjectFactory.class); 67 68 public static EjbJarDD parse(URL ddResource) 69 throws JBossXBException, IOException 70 { 71 ObjectModelFactory factory = null; 72 Unmarshaller unmarshaller = null; 73 EjbJarDD dd = null; 74 75 if (ddResource != null) 76 { 77 log.debug("found ejb-jar.xml " + ddResource); 78 79 factory = new EjbJarDDObjectFactory(); 80 UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory 81 .newInstance(); 82 unmarshallerFactory.setFeature(Unmarshaller.SCHEMA_VALIDATION, 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 Object newRoot(Object root, UnmarshallingContext navigator, 95 String namespaceURI, String localName, Attributes attrs) 96 { 97 98 final EjbJarDD dd; 99 if (root == null) 100 { 101 root = dd = new EjbJarDD(); 102 } 103 else 104 { 105 dd = (EjbJarDD) root; 106 } 107 108 if (attrs.getLength() > 0) 109 { 110 for (int i = 0; i < attrs.getLength(); ++i) 111 { 112 if (attrs.getLocalName(i).equals("version")) 113 { 114 dd.setVersion(attrs.getValue(i)); 115 } 116 } 117 } 118 119 return root; 120 } 121 122 public Object completeRoot(Object root, UnmarshallingContext ctx, 123 String uri, String name) 124 { 125 return root; 126 } 127 128 130 133 public Object newChild(EjbJarDD dd, UnmarshallingContext navigator, 134 String namespaceURI, String localName, Attributes attrs) 135 { 136 Object child = null; 137 138 if (localName.equals("enterprise-beans")) 139 { 140 child = new EnterpriseBeans(); 141 } 142 if (localName.equals("interceptors")) 143 { 144 child = new Interceptors(); 145 } 146 else if (localName.equals("relationships")) 147 { 148 child = new Relationships(); 149 } 150 else if (localName.equals("assembly-descriptor")) 151 { 152 child = new AssemblyDescriptor(); 153 } 154 155 return child; 156 } 157 158 161 public Object newChild(EnterpriseBeans ejbs, UnmarshallingContext navigator, 162 String namespaceURI, String localName, Attributes attrs) 163 { 164 Object child = null; 165 166 if (localName.equals("session")) 167 { 168 child = new SessionEnterpriseBean(); 169 } 170 else if (localName.equals("entity")) 171 { 172 child = new EntityEnterpriseBean(); 173 } 174 else if (localName.equals("message-driven")) 175 { 176 child = new MessageDrivenBean(); 177 } 178 179 return child; 180 } 181 182 185 private Object newEjbChild(EnterpriseBean parent, String localName) 186 { 187 Object child = null; 188 189 if ((child = super.newEnvRefGroupChild(localName)) != null) 190 return child; 191 return child; 192 } 193 194 195 private Object newEjbHasInterceptorsChild(EnterpriseBean parent, String localName) 196 { 197 Object child = null; 198 199 if (localName.equals("around-invoke")) 200 { 201 child = new Method(); 202 } 203 else if (localName.equals("post-construct")) 204 { 205 child = new Method(); 206 } 207 else if (localName.equals("pre-destroy")) 208 { 209 child = new Method(); 210 } 211 else if (localName.equals("post-activate")) 212 { 213 child = new Method(); 214 } 215 else if (localName.equals("pre-passivate")) 216 { 217 child = new Method(); 218 } 219 return child; 220 } 221 222 public Object newChild(MessageDrivenBean parent, 223 UnmarshallingContext navigator, String namespaceURI, String localName, 224 Attributes attrs) 225 { 226 Object child = newEjbChild(parent, localName); 227 if (child != null) return child; 228 229 child = newEjbHasInterceptorsChild(parent, localName); 230 if (child != null) return child; 231 232 if (localName.equals("message-driven-destination")) 233 { 234 child = new MessageDrivenDestination(); 235 } 236 else if (localName.equals("activation-config")) 237 { 238 child = new ActivationConfig(); 239 } 240 241 return child; 242 } 243 244 public Object newChild(ActivationConfig parent, 245 UnmarshallingContext navigator, String namespaceURI, String localName, 246 Attributes attrs) 247 { 248 Object child = null; 249 250 if (localName.equals("activation-config-property")) 251 { 252 child = new NameValuePair(); 253 } 254 255 return child; 256 } 257 258 261 public Object newChild(SessionEnterpriseBean parent, 262 UnmarshallingContext navigator, String namespaceURI, String localName, 263 Attributes attrs) 264 { 265 Object child = newEjbChild(parent, localName); 266 if (child != null) return child; 267 268 child = newEjbHasInterceptorsChild(parent, localName); 269 if (child != null) return child; 270 271 if (localName.equals("security-identity")) 272 { 273 child = new SecurityIdentity(); 274 } 275 else if (localName.equals("remove-method")) 276 { 277 RemoveMethod method = new RemoveMethod(); 278 parent.addRemoveMethod(method); 279 child = method; 280 } 281 else if (localName.equals("init-method")) 282 { 283 InitMethod method = new InitMethod(); 284 parent.addInitMethod(method); 285 child = method; 286 } 287 288 return child; 289 } 290 291 294 public Object newChild(EntityEnterpriseBean parent, 295 UnmarshallingContext navigator, String namespaceURI, String localName, 296 Attributes attrs) 297 { 298 Object child = null; 299 300 child = newEjbChild(parent, localName); 301 if (child == null) 302 { 303 if (localName.equals("cmp-field")) 304 { 305 child = new CmpField(); 306 } 307 else if (localName.equals("query")) 308 { 309 child = new Query(); 310 } 311 } 312 313 return child; 314 } 315 316 319 public Object newChild(SecurityIdentity parent, 320 UnmarshallingContext navigator, String namespaceURI, String localName, 321 Attributes attrs) 322 { 323 Object child = null; 324 325 if (localName.equals("run-as")) 326 { 327 child = new RunAs(); 328 } 329 else if (localName.equals("use-caller-identity")) 330 { 331 parent.setUseCallerIdentity(true); 332 } 333 334 return child; 335 } 336 337 340 public Object newChild(RemoveMethod parent, 341 UnmarshallingContext navigator, String namespaceURI, String localName, 342 Attributes attrs) 343 { 344 Object child = null; 345 346 if (localName.equals("bean-method")) 347 { 348 parent.setBeanMethod(new Method()); 349 child = parent.getBeanMethod(); 350 } 351 352 return child; 353 } 354 355 358 public Object newChild(InitMethod parent, 359 UnmarshallingContext navigator, String namespaceURI, String localName, 360 Attributes attrs) 361 { 362 Object child = null; 363 364 if (localName.equals("bean-method")) 365 { 366 parent.setBeanMethod(new Method()); 367 child = parent.getBeanMethod(); 368 } 369 370 return child; 371 } 372 373 376 public void setValue(RemoveMethod dd, UnmarshallingContext navigator, 377 String namespaceURI, String localName, String value) 378 { 379 if (localName.equals("retain-if-exception")) 380 { 381 dd.setRetainIfException(Boolean.parseBoolean(getValue(localName, value))); 382 } 383 } 384 385 388 public Object newChild(Relationships relationships, 389 UnmarshallingContext navigator, String namespaceURI, String localName, 390 Attributes attrs) 391 { 392 Object child = null; 393 394 if (localName.equals("ejb-relation")) 395 { 396 child = new EjbRelation(); 397 } 398 399 return child; 400 } 401 402 405 public Object newChild(EjbRelation relation, UnmarshallingContext navigator, 406 String namespaceURI, String localName, Attributes attrs) 407 { 408 Object child = null; 409 410 if (localName.equals("ejb-relationship-role")) 411 { 412 child = new EjbRelationshipRole(); 413 } 414 415 return child; 416 } 417 418 421 public Object newChild(EjbRelationshipRole parent, 422 UnmarshallingContext navigator, String namespaceURI, String localName, 423 Attributes attrs) 424 { 425 Object child = null; 426 427 if (localName.equals("cascade-delete")) 428 { 429 parent.setCascadeDelete(true); 430 } 431 else if (localName.equals("relationship-role-source")) 432 { 433 child = new RelationshipRoleSource(); 434 } 435 else if (localName.equals("cmr-field")) 436 { 437 child = new CmrField(); 438 } 439 440 return child; 441 } 442 443 public Object newChild(Interceptors interceptors, 444 UnmarshallingContext navigator, String namespaceURI, String localName, 445 Attributes attrs) 446 { 447 Object child = null; 448 449 if (localName.equals("interceptor")) 450 { 451 return new Interceptor(); 452 } 453 454 return child; 455 } 456 457 public Object newChild(Interceptor interceptor, 458 UnmarshallingContext navigator, String namespaceURI, String localName, 459 Attributes attrs) 460 { 461 Object child = null; 462 463 if ((child = this.newEnvRefGroupChild(localName)) != null) 464 return child; 465 466 if (localName.equals("around-invoke")) 467 { 468 return new Method(); 469 } 470 else if (localName.equals("post-construct")) 471 { 472 return new Method(); 473 } 474 else if (localName.equals("pre-destroy")) 475 { 476 return new Method(); 477 } 478 else if (localName.equals("post-activate")) 479 { 480 return new Method(); 481 } 482 else if (localName.equals("pre-passivate")) 483 { 484 return new Method(); 485 } 486 487 return child; 488 } 489 490 493 public Object newChild(AssemblyDescriptor relationships, 494 UnmarshallingContext navigator, String namespaceURI, String localName, 495 Attributes attrs) 496 { 497 Object child = null; 498 499 if (localName.equals("security-role")) 500 { 501 child = new SecurityRole(); 502 } 503 else if (localName.equals("method-permission")) 504 { 505 child = new MethodPermission(); 506 } 507 if (localName.equals("container-transaction")) 508 { 509 child = new ContainerTransaction(); 510 } 511 else if (localName.equals("inject")) 512 { 513 child = new Inject(); 514 } 515 else if (localName.equals("exclude-list")) 516 { 517 child = new ExcludeList(); 518 } 519 else if (localName.equals("application-exception")) 520 { 521 child = new ApplicationException(); 522 } 523 else if (localName.equals("interceptor-binding")) 524 { 525 child = new InterceptorBinding(); 526 } 527 528 return child; 529 } 530 531 534 public Object newChild(Inject inject, 535 UnmarshallingContext navigator, String namespaceURI, String localName, 536 Attributes attrs) 537 { 538 Object child = null; 539 540 if (localName.equals("method")) 541 { 542 child = new Method(); 543 } 544 545 return child; 546 } 547 548 551 public Object newChild(MethodPermission permission, 552 UnmarshallingContext navigator, String namespaceURI, String localName, 553 Attributes attrs) 554 { 555 Object child = null; 556 557 if (localName.equals("method")) 558 { 559 child = new Method(); 560 } 561 else if (localName.equals("unchecked")) 562 { 563 permission.setUnchecked(true); 564 } 565 566 return child; 567 } 568 569 572 public Object newChild(ExcludeList list, 573 UnmarshallingContext navigator, String namespaceURI, String localName, 574 Attributes attrs) 575 { 576 Object child = null; 577 578 if (localName.equals("method")) 579 { 580 child = new Method(); 581 } 582 583 return child; 584 } 585 586 589 public Object newChild(InitList list, 590 UnmarshallingContext navigator, String namespaceURI, String localName, 591 Attributes attrs) 592 { 593 Object child = null; 594 595 if (localName.equals("method")) 596 { 597 child = new Method(); 598 } 599 600 return child; 601 } 602 603 606 public Object newChild(ContainerTransaction transaction, 607 UnmarshallingContext navigator, String namespaceURI, String localName, 608 Attributes attrs) 609 { 610 Object child = null; 611 612 if (localName.equals("method")) 613 { 614 child = new Method(); 615 } 616 617 return child; 618 } 619 620 public Object newChild(Method method, 621 UnmarshallingContext navigator, String namespaceURI, String localName, 622 Attributes attrs) 623 { 624 Object child = null; 625 626 if (localName.equals("method-params")) 627 { 628 method.setHasParameters(); 629 } 630 631 return child; 632 } 633 634 635 public Object newChild(InterceptorBinding binding, 636 UnmarshallingContext navigator, String namespaceURI, String localName, 637 Attributes attrs) 638 { 639 Object child = null; 640 641 if (localName.equals("interceptor-order")) 642 { 643 child = new InterceptorOrder(); 644 } 645 else if (localName.equals("exclude-default-interceptors")) 646 { 647 child = new ExcludeDefaultInterceptors(); 648 } 649 else if (localName.equals("exclude-class-interceptors")) 650 { 651 child = new ExcludeClassInterceptors(); 652 } 653 else if (localName.equals("method-params")) 654 { 655 binding.setHasParameters(); 656 } 657 658 659 return child; 660 } 661 662 663 666 public void addChild(MessageDrivenBean parent, ActivationConfig config, 667 UnmarshallingContext navigator, String namespaceURI, String localName) 668 { 669 parent.setActivationConfig(config); 670 } 671 672 675 public void addChild(MessageDrivenBean parent, EjbRef ref, 676 UnmarshallingContext navigator, String namespaceURI, String localName) 677 { 678 parent.addEjbRef(ref); 679 } 680 681 684 public void addChild(MessageDrivenBean parent, EjbLocalRef ref, 685 UnmarshallingContext navigator, String namespaceURI, String localName) 686 { 687 parent.addEjbLocalRef(ref); 688 } 689 690 693 public void addChild(MessageDrivenBean parent, EnvEntry entry, 694 UnmarshallingContext navigator, String namespaceURI, String localName) 695 { 696 parent.addEnvEntry(entry); 697 } 698 699 702 public void addChild(MessageDrivenBean parent, ResourceEnvRef envRef, 703 UnmarshallingContext navigator, String namespaceURI, String localName) 704 { 705 parent.addResourceEnvRef(envRef); 706 } 707 708 711 public void addChild(MessageDrivenBean parent, ResourceRef envRef, 712 UnmarshallingContext navigator, String namespaceURI, String localName) 713 { 714 parent.addResourceRef(envRef); 715 } 716 717 public void addChild(MessageDrivenBean parent, ServiceRef envRef, 718 UnmarshallingContext navigator, String namespaceURI, String localName) 719 { 720 parent.addServiceRef(envRef); 721 } 722 723 public void addChild(MessageDrivenBean parent, MessageDestinationRef ref, 724 UnmarshallingContext navigator, String namespaceURI, String localName) 725 { 726 parent.addMessageDestinationRef(ref); 727 } 728 729 public void addChild(ActivationConfig parent, NameValuePair property, 730 UnmarshallingContext navigator, String namespaceURI, String localName) 731 { 732 parent.addActivationConfigProperty(property); 733 } 734 735 public void addChild(EjbJarDD parent, EnterpriseBeans ejbs, 736 UnmarshallingContext navigator, String namespaceURI, String localName) 737 { 738 parent.setEnterpriseBeans(ejbs); 739 } 740 741 744 public void addChild(EnterpriseBeans parent, EnterpriseBean ejb, 745 UnmarshallingContext navigator, String namespaceURI, String localName) 746 { 747 parent.addEnterpriseBean(ejb); 748 } 749 750 public void addChild(SessionEnterpriseBean parent, SecurityIdentity si, 751 UnmarshallingContext navigator, String namespaceURI, String localName) 752 { 753 parent.setSecurityIdentity(si); 754 } 755 756 public void addChild(SecurityIdentity parent, RunAs runAs, 757 UnmarshallingContext navigator, String namespaceURI, String localName) 758 { 759 parent.setRunAs(runAs); 760 } 761 762 public void addChild(SessionEnterpriseBean parent, EjbLocalRef ref, 763 UnmarshallingContext navigator, String namespaceURI, String localName) 764 { 765 parent.addEjbLocalRef(ref); 766 } 767 768 public void addChild(SessionEnterpriseBean parent, EjbRef ref, 769 UnmarshallingContext navigator, String namespaceURI, String localName) 770 { 771 parent.addEjbRef(ref); 772 } 773 774 public void addChild(SessionEnterpriseBean parent, PersistenceContextRef ref, 775 UnmarshallingContext navigator, String namespaceURI, String localName) 776 { 777 parent.addPersistenceContextRef(ref); 778 } 779 780 783 public void addChild(SessionEnterpriseBean parent, PersistenceUnitRef ref, 784 UnmarshallingContext navigator, String namespaceURI, String localName) 785 { 786 parent.addPersistenceUnitRef(ref); 787 } 788 789 792 public void addChild(SessionEnterpriseBean parent, MessageDestinationRef ref, 793 UnmarshallingContext navigator, String namespaceURI, String localName) 794 { 795 parent.addMessageDestinationRef(ref); 796 } 797 798 801 public void addChild(SessionEnterpriseBean parent, EnvEntry entry, 802 UnmarshallingContext navigator, String namespaceURI, String localName) 803 { 804 parent.addEnvEntry(entry); 805 } 806 807 810 public void addChild(SessionEnterpriseBean parent, ResourceEnvRef envRef, 811 UnmarshallingContext navigator, String namespaceURI, String localName) 812 { 813 parent.addResourceEnvRef(envRef); 814 } 815 816 819 public void addChild(SessionEnterpriseBean parent, ResourceRef envRef, 820 UnmarshallingContext navigator, String namespaceURI, String localName) 821 { 822 parent.addResourceRef(envRef); 823 } 824 825 828 public void addChild(SessionEnterpriseBean parent, ServiceRef envRef, 829 UnmarshallingContext navigator, String namespaceURI, String localName) 830 { 831 parent.addServiceRef(envRef); 832 } 833 834 837 public void addChild(SessionEnterpriseBean parent, Method method, 838 UnmarshallingContext navigator, String namespaceURI, String localName) 839 { 840 if (localName.equals("around-invoke")) 841 { 842 parent.setAroundInvoke(method); 843 } 844 else if (localName.equals("post-construct")) 845 { 846 parent.setPostConstruct(method); 847 } 848 else if (localName.equals("pre-destroy")) 849 { 850 parent.setPreDestroy(method); 851 } 852 else if (localName.equals("post-activate")) 853 { 854 parent.setPostActivate(method); 855 } 856 else if (localName.equals("pre-passivate")) 857 { 858 parent.setPrePassivate(method); 859 } 860 } 861 862 865 public void addChild(EntityEnterpriseBean parent, CmpField field, 866 UnmarshallingContext navigator, String namespaceURI, String localName) 867 { 868 parent.addCmpField(field); 869 } 870 871 874 public void addChild(EntityEnterpriseBean parent, Query query, 875 UnmarshallingContext navigator, String namespaceURI, String localName) 876 { 877 parent.addQuery(query); 878 } 879 880 883 public void addChild(EjbJarDD parent, Relationships relationships, 884 UnmarshallingContext navigator, String namespaceURI, String localName) 885 { 886 parent.setRelationships(relationships); 887 } 888 889 892 public void addChild(Relationships parent, EjbRelation relation, 893 UnmarshallingContext navigator, String namespaceURI, String localName) 894 { 895 parent.addEjbRelation(relation); 896 } 897 898 901 public void addChild(EjbRelation parent, EjbRelationshipRole role, 902 UnmarshallingContext navigator, String namespaceURI, String localName) 903 { 904 parent.addEjbRelationshipRole(role); 905 } 906 907 910 public void addChild(EjbRelationshipRole parent, 911 RelationshipRoleSource source, UnmarshallingContext navigator, 912 String namespaceURI, String localName) 913 { 914 parent.setRelationshipRoleSource(source); 915 } 916 917 920 public void addChild(EjbRelationshipRole parent, CmrField field, 921 UnmarshallingContext navigator, String namespaceURI, String localName) 922 { 923 parent.setCmrField(field); 924 } 925 926 929 public void addChild(EjbJarDD parent, AssemblyDescriptor descriptor, 930 UnmarshallingContext navigator, String namespaceURI, String localName) 931 { 932 parent.setAssemblyDescriptor(descriptor); 933 } 934 935 938 public void addChild(AssemblyDescriptor parent, SecurityRole role, 939 UnmarshallingContext navigator, String namespaceURI, String localName) 940 { 941 parent.addSecurityRole(role); 942 } 943 944 947 public void addChild(AssemblyDescriptor parent, MethodPermission permission, 948 UnmarshallingContext navigator, String namespaceURI, String localName) 949 { 950 parent.addMethodPermission(permission); 951 } 952 953 956 public void addChild(AssemblyDescriptor parent, ExcludeList list, 957 UnmarshallingContext navigator, String namespaceURI, String localName) 958 { 959 parent.setExcludeList(list); 960 } 961 962 965 public void addChild(AssemblyDescriptor parent, ApplicationException exception, 966 UnmarshallingContext navigator, String namespaceURI, String localName) 967 { 968 parent.addApplicationException(exception); 969 } 970 971 974 public void addChild(AssemblyDescriptor parent, InitList list, 975 UnmarshallingContext navigator, String namespaceURI, String localName) 976 { 977 parent.setInitList(list); 978 } 979 980 983 public void addChild(AssemblyDescriptor parent, Inject inject, 984 UnmarshallingContext navigator, String namespaceURI, String localName) 985 { 986 parent.addInject(inject); 987 } 988 989 992 public void addChild(AssemblyDescriptor parent, InterceptorBinding binding, 993 UnmarshallingContext navigator, String namespaceURI, String localName) 994 { 995 parent.addInterceptorBinding(binding); 996 } 997 998 1001 public void addChild(ExcludeList parent, Method method, 1002 UnmarshallingContext navigator, String namespaceURI, String localName) 1003 { 1004 parent.addMethod(method); 1005 } 1006 1007 1010 public void addChild(InitList parent, Method method, 1011 UnmarshallingContext navigator, String namespaceURI, String localName) 1012 { 1013 parent.addMethod(method); 1014 } 1015 1016 1019 public void addChild(MethodPermission parent, Method method, 1020 UnmarshallingContext navigator, String namespaceURI, String localName) 1021 { 1022 parent.addMethod(method); 1023 } 1024 1025 1028 public void addChild(Inject parent, Method method, 1029 UnmarshallingContext navigator, String namespaceURI, String localName) 1030 { 1031 parent.addMethod(method); 1032 } 1033 1034 public void addChild(EjbJarDD parent, Interceptors interceptors, 1035 UnmarshallingContext navigator, String namespaceURI, String localName) 1036 { 1037 parent.setInterceptors(interceptors); 1038 } 1039 1040 public void addChild(Interceptors parent, Interceptor interceptor, 1041 UnmarshallingContext navigator, String namespaceURI, String localName) 1042 { 1043 parent.addInterceptor(interceptor); 1044 } 1045 1046 1049 public void addChild(Interceptor parent, EjbLocalRef ref, 1050 UnmarshallingContext navigator, String namespaceURI, String localName) 1051 { 1052 parent.addEjbLocalRef(ref); 1053 } 1054 1055 1058 public void addChild(Interceptor parent, EjbRef ref, 1059 UnmarshallingContext navigator, String namespaceURI, String localName) 1060 { 1061 parent.addEjbRef(ref); 1062 } 1063 1064 1067 public void addChild(Interceptor parent, PersistenceContextRef ref, 1068 UnmarshallingContext navigator, String namespaceURI, String localName) 1069 { 1070 parent.addPersistenceContextRef(ref); 1071 } 1072 1073 1076 public void addChild(Interceptor parent, PersistenceUnitRef ref, 1077 UnmarshallingContext navigator, String namespaceURI, String localName) 1078 { 1079 parent.addPersistenceUnitRef(ref); 1080 } 1081 1082 1085 public void addChild(Interceptor parent, MessageDestinationRef ref, 1086 UnmarshallingContext navigator, String namespaceURI, String localName) 1087 { 1088 parent.addMessageDestinationRef(ref); 1089 } 1090 1091 1094 public void addChild(Interceptor parent, EnvEntry entry, 1095 UnmarshallingContext navigator, String namespaceURI, String localName) 1096 { 1097 parent.addEnvEntry(entry); 1098 } 1099 1100 1103 public void addChild(Interceptor parent, ResourceEnvRef ref, 1104 UnmarshallingContext navigator, String namespaceURI, String localName) 1105 { 1106 parent.addResourceEnvRef(ref); 1107 } 1108 1109 1112 public void addChild(Interceptor parent, ResourceRef ref, 1113 UnmarshallingContext navigator, String namespaceURI, String localName) 1114 { 1115 parent.addResourceRef(ref); 1116 } 1117 1118 1121 public void addChild(Interceptor parent, ServiceRef ref, 1122 UnmarshallingContext navigator, String namespaceURI, String localName) 1123 { 1124 parent.addServiceRef(ref); 1125 } 1126 1127 public void addChild(Interceptor parent, Method method, 1128 UnmarshallingContext navigator, String namespaceURI, String localName) 1129 { 1130 if (localName.equals("around-invoke")) 1131 { 1132 parent.setAroundInvoke(method); 1133 } 1134 else if (localName.equals("post-construct")) 1135 { 1136 parent.setPostConstruct(method); 1137 } 1138 else if (localName.equals("pre-destroy")) 1139 { 1140 parent.setPreDestroy(method); 1141 } 1142 else if (localName.equals("post-activate")) 1143 { 1144 parent.setPostActivate(method); 1145 } 1146 else if (localName.equals("pre-passivate")) 1147 { 1148 parent.setPrePassivate(method); 1149 } 1150 } 1151 1152 1155 public void addChild(InterceptorBinding parent, 1156 InterceptorOrder order, UnmarshallingContext navigator, 1157 String namespaceURI, String localName) 1158 { 1159 parent.setOrderedInterceptorClasses(order); 1160 } 1161 1162 1165 public void addChild(InterceptorBinding parent, 1166 ExcludeDefaultInterceptors exclude, UnmarshallingContext navigator, 1167 String namespaceURI, String localName) 1168 { 1169 parent.setExcludeDefaultInterceptors(true); 1170 } 1171 1172 1175 public void addChild(InterceptorBinding parent, 1176 ExcludeClassInterceptors exclude, UnmarshallingContext navigator, 1177 String namespaceURI, String localName) 1178 { 1179 parent.setExcludeClassInterceptors(true); 1180 } 1181 1182 1185 public void addChild(ContainerTransaction parent, Method method, 1186 UnmarshallingContext navigator, String namespaceURI, String localName) 1187 { 1188 parent.setMethod(method); 1189 } 1190 1191 1194 public void addChild(MessageDrivenBean parent, MessageDrivenDestination destination, 1195 UnmarshallingContext navigator, String namespaceURI, String localName) 1196 { 1197 parent.setMessageDrivenDestination(destination); 1198 } 1199 1200 1203 public void addChild(MessageDrivenBean parent, Method method, 1204 UnmarshallingContext navigator, String namespaceURI, String localName) 1205 { 1206 if (localName.equals("around-invoke")) 1207 { 1208 parent.setAroundInvoke(method); 1209 } 1210 else if (localName.equals("post-construct")) 1211 { 1212 parent.setPostConstruct(method); 1213 } 1214 else if (localName.equals("pre-destroy")) 1215 { 1216 parent.setPreDestroy(method); 1217 } 1218 } 1219 1220 1223 public void addChild(AssemblyDescriptor parent, 1224 ContainerTransaction transaction, UnmarshallingContext navigator, 1225 String namespaceURI, String localName) 1226 { 1227 parent.addContainerTransaction(transaction); 1228 } 1229 1230 1233 public void setValue(EjbJarDD dd, UnmarshallingContext navigator, 1234 String namespaceURI, String localName, String value) 1235 { 1236 if (localName.equals("display-name")) 1237 { 1238 dd.setDisplayName(getValue(localName, value)); 1239 } 1240 } 1241 1242 1245 public void setValue(NameValuePair property, UnmarshallingContext navigator, 1246 String namespaceURI, String localName, String value) 1247 { 1248 if (localName.equals("activation-config-property-name")) 1249 { 1250 property.setName(getValue(localName, value)); 1251 } 1252 else if (localName.equals("activation-config-property-value")) 1253 { 1254 property.setValue(getValue(localName, value)); 1255 } 1256 } 1257 1258 1261 private boolean isEjbParentName(EnterpriseBean ejb, String localName, 1262 String value) 1263 { 1264 if (localName.equals("ejb-name")) 1265 { 1266 ejb.setEjbName(getValue(localName, value)); 1267 return true; 1268 } 1269 else if (localName.equals("home")) 1270 { 1271 ejb.setHome(getValue(localName, value)); 1272 return true; 1273 } 1274 else if (localName.equals("remote")) 1275 { 1276 ejb.setRemote(getValue(localName, value)); 1277 return true; 1278 } 1279 else if (localName.equals("local-home")) 1280 { 1281 ejb.setLocalHome(getValue(localName, value)); 1282 return true; 1283 } 1284 else if (localName.equals("local")) 1285 { 1286 ejb.setLocal(getValue(localName, value)); 1287 return true; 1288 } 1289 else if (localName.equals("ejb-class")) 1290 { 1291 ejb.setEjbClass(getValue(localName, value)); 1292 return true; 1293 } 1294 1295 return false; 1296 } 1297 1298 1301 public void setValue(MessageDrivenBean ejb, 1302 UnmarshallingContext navigator, String namespaceURI, String localName, 1303 String value) 1304 { 1305 if (!isEjbParentName(ejb, localName, value)) 1306 { 1307 if (localName.equals("acknowledge-mode")) 1308 { 1309 ejb.setAcknowledgeMode(getValue(localName, value)); 1310 } 1311 else if (localName.equals("transaction-type")) 1312 { 1313 ejb.setTransactionType(getValue(localName, value)); 1314 } 1315 else if (localName.equals("messaging-type")) 1316 { 1317 ejb.setMessagingType(getValue(localName, value)); 1318 } 1319 else if (localName.equals("message-destination-type")) 1320 { 1321 MessageDrivenDestination destination = ejb.getMessageDrivenDestination(); 1322 if (destination == null) 1323 { 1324 destination = new MessageDrivenDestination(); 1325 ejb.setMessageDrivenDestination(destination); 1326 } 1327 1328 destination.setDestinationType(getValue(localName, value)); 1329 } 1330 } 1331 } 1332 1333 1336 public void setValue(MessageDrivenDestination destination, 1337 UnmarshallingContext navigator, String namespaceURI, String localName, 1338 String value) 1339 { 1340 if (localName.equals("destination-type")) 1341 { 1342 destination.setDestinationType(getValue(localName, value)); 1343 } 1344 else if (localName.equals("subscription-durability")) 1345 { 1346 destination.setSubscriptionDurability(getValue(localName, value)); 1347 } 1348 } 1349 1350 1353 public void setValue(SessionEnterpriseBean ejb, 1354 UnmarshallingContext navigator, String namespaceURI, String localName, 1355 String value) 1356 { 1357 if (!isEjbParentName(ejb, localName, value)) 1358 { 1359 if (localName.equals("session-type")) 1360 { 1361 ejb.setSessionType(getValue(localName, value)); 1362 } 1363 else if (localName.equals("transaction-type")) 1364 { 1365 ejb.setTransactionManagementType(getValue(localName, value)); 1366 } 1367 } 1368 } 1369 1370 1373 public void setValue(ApplicationException exception, 1374 UnmarshallingContext navigator, String namespaceURI, String localName, 1375 String value) 1376 { 1377 if (localName.equals("exception-class")) 1378 { 1379 exception.setExceptionClass(getValue(localName, value)); 1380 } 1381 else if (localName.equals("rollback")) 1382 { 1383 exception.setRollback(Boolean.valueOf(getValue(localName, value))); 1384 } 1385 } 1386 1387 1390 public void setValue(EntityEnterpriseBean ejb, 1391 UnmarshallingContext navigator, String namespaceURI, String localName, 1392 String value) 1393 { 1394 if (!isEjbParentName(ejb, localName, value)) 1395 { 1396 if (localName.equals("persistence-type")) 1397 { 1398 ejb.setPersistenceType(getValue(localName, value)); 1399 } 1400 } 1401 } 1402 1403 1406 public void setValue(SecurityIdentity si, UnmarshallingContext navigator, 1407 String namespaceURI, String localName, String value) 1408 { 1409 if (localName.equals("use-caller-identity")) 1410 { 1411 si.setUseCallerIdentity(true); 1412 } 1413 } 1414 1415 public void setValue(Interceptor interceptor, UnmarshallingContext navigator, 1416 String namespaceURI, String localName, String value) 1417 { 1418 if (localName.equals("interceptor-class")) 1419 { 1420 interceptor.setInterceptorClass(getValue(localName, value)); 1421 } 1422 } 1423 1424 1427 public void setValue(EjbRelation relation, UnmarshallingContext navigator, 1428 String namespaceURI, String localName, String value) 1429 { 1430 if (localName.equals("ejb-relation-name")) 1431 { 1432 relation.setEjbRelationName(getValue(localName, value)); 1433 } 1434 } 1435 1436 1439 public void setValue(EjbRelationshipRole role, 1440 UnmarshallingContext navigator, String namespaceURI, String localName, 1441 String value) 1442 { 1443 if (localName.equals("ejb-relationship-role-name")) 1444 { 1445 role.setEjbRelationshipRoleName(getValue(localName, value)); 1446 } 1447 else if (localName.equals("multiplicity")) 1448 { 1449 role.setMultiplicity(getValue(localName, value)); 1450 } 1451 } 1452 1453 1456 public void setValue(RelationshipRoleSource source, 1457 UnmarshallingContext navigator, String namespaceURI, String localName, 1458 String value) 1459 { 1460 if (localName.equals("ejb-name")) 1461 { 1462 source.setEjbName(getValue(localName, value)); 1463 } 1464 } 1465 1466 1469 public void setValue(CmrField field, UnmarshallingContext navigator, 1470 String namespaceURI, String localName, String value) 1471 { 1472 if (localName.equals("cmr-field-name")) 1473 { 1474 field.setCmrFieldName(getValue(localName, value)); 1475 } 1476 else if (localName.equals("cmr-field-type")) 1477 { 1478 field.setCmrFieldType(getValue(localName, value)); 1479 } 1480 } 1481 1482 1485 public void setValue(SecurityRole role, UnmarshallingContext navigator, 1486 String namespaceURI, String localName, String value) 1487 { 1488 if (localName.equals("role-name")) 1489 { 1490 role.setRoleName(getValue(localName, value)); 1491 } 1492 } 1493 1494 1497 public void setValue(MethodPermission permission, 1498 UnmarshallingContext navigator, String namespaceURI, String localName, 1499 String value) 1500 { 1501 if (localName.equals("role-name")) 1502 { 1503 permission.addRoleName(getValue(localName, value)); 1504 } 1505 else if (localName.equals("unchecked")) 1506 { 1507 permission.setUnchecked(true); 1508 } 1509 } 1510 1511 1514 public void setValue(ContainerTransaction transaction, 1515 UnmarshallingContext navigator, String namespaceURI, String localName, 1516 String value) 1517 { 1518 if (localName.equals("trans-attribute")) 1519 { 1520 transaction.setTransAttribute(getValue(localName, value)); 1521 } 1522 } 1523 1524 1527 public void setValue(Method method, UnmarshallingContext navigator, 1528 String namespaceURI, String localName, String value) 1529 { 1530 if (localName.equals("ejb-name")) 1531 { 1532 method.setEjbName(getValue(localName, value)); 1533 } 1534 else if (localName.equals("method-name")) 1535 { 1536 method.setMethodName(getValue(localName, value)); 1537 } 1538 else if (localName.equals("method-param")) 1539 { 1540 method.addMethodParam(getValue(localName, value)); 1541 } 1542 else if (localName.equals("lifecycle-callback-method")) 1543 { 1544 method.setMethodName(getValue(localName, value)); 1545 } 1546 } 1547 1548 1551 public void setValue(Inject inject, UnmarshallingContext navigator, 1552 String namespaceURI, String localName, String value) 1553 { 1554 if (localName.equals("jndi-name")) 1555 { 1556 inject.setJndiName(getValue(localName, value)); 1557 } 1558 } 1559 1560 public void setValue(InterceptorBinding binding, UnmarshallingContext navigator, 1561 String namespaceURI, String localName, String value) 1562 { 1563 if (localName.equals("ejb-name")) 1564 { 1565 binding.setEjbName(getValue(localName, value)); 1566 } 1567 else if (localName.equals("interceptor-class")) 1568 { 1569 binding.addInterceptorClass(getValue(localName, value)); 1570 } 1571 else if (localName.equals("method-name")) 1572 { 1573 binding.setMethodName(getValue(localName, value)); 1574 } 1575 else if (localName.equals("method-param")) 1576 { 1577 binding.addMethodParam(getValue(localName, value)); 1578 } 1579 else if (localName.equals("exclude-default-interceptors")) 1580 { 1581 binding.setExcludeDefaultInterceptors(true); 1582 } 1583 else if (localName.equals("exclude-class-interceptors")) 1584 { 1585 binding.setExcludeClassInterceptors(true); 1586 } 1587 } 1588 1589 public void setValue(InterceptorOrder order, UnmarshallingContext navigator, 1590 String namespaceURI, String localName, String value) 1591 { 1592 if (localName.equals("interceptor-class")) 1593 { 1594 order.addInterceptorClass(getValue(localName, value)); 1595 } 1596 } 1597 1598 protected String getValue(String name, String value) 1599 { 1600 if (value.startsWith("${") && value.endsWith("}")) 1601 { 1602 try 1603 { 1604 String propertyName = value.substring(2, value.length()-1); 1605 ObjectName propertyServiceON = new ObjectName ("jboss:type=Service,name=SystemProperties"); 1606 KernelAbstraction kernelAbstraction = KernelAbstractionFactory.getInstance(); 1607 String propertyValue = (String )kernelAbstraction.invoke(propertyServiceON, "get", new Object []{propertyName}, new String []{"java.lang.String"}); 1608 log.debug("Replaced ejb-jar.xml element " + name + " with value " + propertyValue); 1609 return propertyValue; 1610 } 1611 catch (Exception e) 1612 { 1613 log.warn("Unable to look up property service for ejb-jar.xml element " + name + " with value " + value + ". Caused by " + e.getClass() + " " + e.getMessage()); 1614 } 1615 } 1616 1617 return value; 1618 } 1619 1620} 1621 | Popular Tags |