1 22 package org.jboss.deployment; 23 24 25 import java.util.List ; 26 import java.util.ArrayList ; 27 import org.jboss.logging.Logger; 28 import org.jboss.metadata.ApplicationMetaData; 29 import org.jboss.metadata.DDObjectFactory; 30 import org.jboss.metadata.EntityMetaData; 31 import org.jboss.metadata.IconMetaData; 32 import org.jboss.metadata.MessageDestinationMetaData; 33 import org.jboss.metadata.MessageDrivenMetaData; 34 import org.jboss.metadata.MethodMetaData; 35 import org.jboss.metadata.QueryMetaData; 36 import org.jboss.metadata.RelationMetaData; 37 import org.jboss.metadata.RelationshipRoleMetaData; 38 import org.jboss.metadata.SecurityIdentityMetaData; 39 import org.jboss.metadata.SecurityRoleMetaData; 40 import org.jboss.metadata.SessionMetaData; 41 import org.jboss.metadata.BeanMetaData; 42 import org.jboss.metadata.ActivationConfigPropertyMetaData; 43 import org.jboss.metadata.EjbLocalRefMetaData; 44 import org.jboss.metadata.EjbRefMetaData; 45 import org.jboss.metadata.ResourceRefMetaData; 46 import org.jboss.metadata.ResourceEnvRefMetaData; 47 import org.jboss.metadata.EnvEntryMetaData; 48 import org.jboss.metadata.MessageDestinationRefMetaData; 49 import org.jboss.xb.binding.ObjectModelFactory; 50 import org.jboss.xb.binding.UnmarshallingContext; 51 import org.jboss.webservice.metadata.serviceref.ServiceRefMetaData; 52 import org.xml.sax.Attributes ; 53 54 55 63 public class EjbJarObjectFactory extends DDObjectFactory 64 implements ObjectModelFactory 65 { 66 private static Logger log = Logger.getLogger(EjbJarObjectFactory.class); 67 private int ejbVersion = 2; 68 private int ejbMinorVersion = 0; 69 70 public void startDTD(String name, String publicId, String systemId) 71 { 72 if (publicId.startsWith("-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0")) 74 { 75 ejbVersion = 2; 76 } 77 else if (publicId.startsWith("-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1")) 78 { 79 ejbVersion = 1; 80 } 81 } 82 83 public ApplicationMetaData newRoot(Object root, UnmarshallingContext navigator, 84 String namespaceURI, String localName, Attributes attrs) 85 { 86 ApplicationMetaData metaData = null; 87 if (root != null) 88 metaData = (ApplicationMetaData) root; 89 else 90 metaData = new ApplicationMetaData(); 91 92 String version = attrs.getValue(namespaceURI, "version"); 93 if(version == null) 95 version = attrs.getValue("", "version"); 96 if(version != null) 97 { 98 if(version.equals("3.0")) 99 { 100 metaData.setEjbVersion(3); 101 metaData.setEjbMinorVersion(0); 102 ejbVersion = 3; 104 ejbMinorVersion = 0; 105 } 106 } 107 108 return metaData; 109 } 110 111 public Object completeRoot(Object root, UnmarshallingContext ctx, 112 String uri, String name) 113 { 114 return root; 115 } 116 117 127 public Object newChild(ApplicationMetaData dd, UnmarshallingContext navigator, 128 String namespaceURI, String localName, Attributes attrs) 129 { 130 Object child = null; 131 132 String version = attrs.getValue(namespaceURI, "version"); 139 if( version != null ) 140 { 141 if( version.equals("2.1") ) 142 { 143 dd.setEjbVersion(2); 144 dd.setEjbMinorVersion(1); 145 } 146 } 147 else 148 { 149 dd.setEjbVersion(ejbVersion); 151 dd.setEjbMinorVersion(ejbMinorVersion); 152 } 153 154 if (localName.equals("enterprise-beans")) 156 child = dd; 157 else if(localName.equals("entity")) 158 child = new EntityMetaData(dd); 159 else if(localName.equals("session")) 160 child = new SessionMetaData(dd); 161 else if(localName.equals("message-driven")) 162 child = new MessageDrivenMetaData(dd); 163 else if(localName.equals("relationships")) 164 child = dd; 165 else if (localName.equals("ejb-relation")) 166 child = new RelationMetaData(); 167 else if( localName.equals("assembly-descriptor")) 168 child = new AssemblyDescriptor(dd); 169 else if(localName.equals("icon")) 170 child = new IconMetaData(); 171 else if (log.isTraceEnabled()) 172 { 173 log.trace("Ignoring: " + localName); 174 } 175 return child; 176 } 177 178 public Object newChild(EntityMetaData entity, UnmarshallingContext navigator, 179 String namespaceURI, String localName, Attributes attrs) 180 { 181 Object child = null; 182 if ((child = newEnvRefGroupChild(localName)) != null) 184 { 185 return child; 186 } 187 else if (localName.equals("security-identity")) 188 { 189 child = new SecurityIdentityMetaData(); 190 } 191 else if(localName.equals("cmp-field")) 192 { 193 child = new CMPFieldMetaData(); 194 } 195 else if (localName.equals("query")) 196 { 197 child = new QueryMetaData(); 198 } 199 else if(log.isTraceEnabled()) 200 { 201 log.trace("Ignoring child of entity: " + localName); 202 } 203 return child; 204 } 205 206 public Object newChild(MessageDrivenMetaData mdb, UnmarshallingContext navigator, 207 String namespaceURI, String localName, Attributes attrs) 208 { 209 Object child = null; 210 if ((child = newEnvRefGroupChild(localName)) != null) 212 return child; 213 else if (localName.equals("security-identity")) 214 child = new SecurityIdentityMetaData(); 215 else if(localName.equals("message-driven-destination")) 216 child = mdb; 217 else if(localName.equals("activation-config")) 218 child = mdb; 219 else if(localName.equals("activation-config-property")) 220 child = new ActivationConfigPropertyMetaData(); 221 else if(log.isTraceEnabled()) 222 { 223 log.trace("Ignoring child of message-driven: " + localName); 224 } 225 return child; 226 } 227 228 public Object newChild(SessionMetaData session, UnmarshallingContext navigator, 229 String namespaceURI, String localName, Attributes attrs) 230 { 231 Object child = null; 232 if ((child = newEnvRefGroupChild(localName)) != null) 234 return child; 235 else if (localName.equals("security-identity")) 236 child = new SecurityIdentityMetaData(); 237 else if(log.isTraceEnabled()) 238 { 239 log.trace("Ignoring child of session: " + localName); 240 } 241 return child; 242 } 243 244 public Object newChild(RelationMetaData relation, UnmarshallingContext navigator, 245 String namespaceURI, String localName, Attributes attrs) 246 { 247 Object child = null; 248 249 if( localName.equals("ejb-relationship-role") ) 251 { 252 child = new RelationshipRoleMetaData(relation); 253 } 254 else if(log.isTraceEnabled()) 255 { 256 log.trace("Ignoring child of relation: " + localName); 257 } 258 return child; 259 } 260 261 public Object newChild(RelationshipRoleMetaData role, UnmarshallingContext navigator, 262 String namespaceURI, String localName, Attributes attrs) 263 { 264 Object child = null; 265 if(localName.equals("cascade-delete")) 266 { 267 role.setCascadeDelete(true); 268 } 269 else if(localName.equals("relationship-role-source") || 270 localName.equals("cmr-field")) 271 { 272 child = role; 273 } 274 return child; 275 } 276 277 public Object newChild(AssemblyDescriptor ad, UnmarshallingContext navigator, 278 String namespaceURI, String localName, Attributes attrs) 279 { 280 if(localName.equals("security-role")) 281 { 282 return ad; 283 } 284 else if(localName.equals("method-permission")) 285 { 286 return new MethodPermission(ad); 287 } 288 else if(localName.equals("container-transaction")) 289 { 290 return new ContainerTransaction(); 291 } 292 else if(localName.equals("exclude-list")) 293 { 294 return ad; 295 } 296 else if(localName.equals("method")) 297 { 298 MethodMetaData method = new MethodMetaData(); 299 method.setExcluded(); 300 return method; 301 } 302 else if(localName.equals("message-destination")) 303 { 304 MessageDestinationMetaData mdmd = new MessageDestinationMetaData(); 305 return mdmd; 306 } 307 return null; 308 } 309 310 public Object newChild(MethodMetaData method, UnmarshallingContext navigator, 311 String namespaceURI, String localName, Attributes attrs) 312 { 313 if(localName.equals("method") || 314 localName.equals("method-params")) 315 { 316 return method; 317 } 318 else if(localName.equals("unchecked")) 319 { 320 method.setUnchecked(); 321 } 322 return null; 323 } 324 325 public Object newChild(QueryMetaData query, UnmarshallingContext navigator, 326 String namespaceURI, String localName, Attributes attrs) 327 { 328 if(localName.equals("query-method") || localName.equals("method-params")) 329 { 330 return query; 331 } 332 return null; 333 } 334 335 public Object newChild(SecurityIdentityMetaData parent, UnmarshallingContext navigator, 336 String namespaceURI, String localName, Attributes attrs) 337 { 338 if(localName.equals("run-as")) 339 { 340 return parent; 341 } 342 else if(localName.equals("use-caller-identity")) 343 { 344 parent.setUseCallerIdentity(true); 345 } 346 return null; 347 } 348 349 public Object newChild(MethodPermission parent, UnmarshallingContext navigator, 350 String namespaceURI, String localName, Attributes attrs) 351 { 352 if(localName.equals("method")) 353 { 354 return new MethodMetaData(); 355 } 356 return null; 357 } 358 359 public Object newChild(ContainerTransaction parent, UnmarshallingContext navigator, 360 String namespaceURI, String localName, Attributes attrs) 361 { 362 if(localName.equals("method")) 363 { 364 MethodMetaData method = new MethodMetaData(); 365 parent.methods.add(method); 366 return method; 367 } 368 return null; 369 } 370 371 public void addChild(ApplicationMetaData parent, EntityMetaData entity, 372 UnmarshallingContext navigator, String namespaceURI, String localName) 373 { 374 if(parent.isEJB1x() && entity.isCMP()) 375 { 376 entity.setCmpVersion(1); 377 } 378 parent.addBeanMetaData(entity); 379 } 380 381 public void addChild(ApplicationMetaData parent, SessionMetaData session, 382 UnmarshallingContext navigator, String namespaceURI, String localName) 383 { 384 parent.addBeanMetaData(session); 385 } 386 387 public void addChild(ApplicationMetaData parent, MessageDrivenMetaData mdb, 388 UnmarshallingContext navigator, String namespaceURI, String localName) 389 { 390 parent.addBeanMetaData(mdb); 391 } 392 393 public void addChild(ApplicationMetaData parent, RelationMetaData relation, 394 UnmarshallingContext navigator, String namespaceURI, String localName) 395 { 396 if(relation.getRelationName() == null) 397 { 398 relation.setDefaultRelationName(); 399 } 400 parent.addRelationship(relation); 401 } 402 403 public void addChild(EntityMetaData parent, SecurityIdentityMetaData child, 404 UnmarshallingContext navigator, String namespaceURI, String localName) 405 { 406 parent.setSecurityIdentityMetaData(child); 407 } 408 409 public void addChild(EntityMetaData parent, CMPFieldMetaData field, 410 UnmarshallingContext navigator, String namespaceURI, String localName) 411 { 412 parent.getCmpFields().add(field.name); 413 } 414 415 public void addChild(EntityMetaData parent, QueryMetaData query, 416 UnmarshallingContext navigator, String namespaceURI, String localName) 417 { 418 parent.addQuery(query); 419 } 420 421 public void addChild(EntityMetaData parent, EjbLocalRefMetaData child, 422 UnmarshallingContext navigator, String namespaceURI, String localName) 423 { 424 parent.addEjbLocalReference(child); 425 } 426 427 public void addChild(EntityMetaData parent, EjbRefMetaData child, 428 UnmarshallingContext navigator, String namespaceURI, String localName) 429 { 430 parent.addEjbReference(child); 431 } 432 433 public void addChild(EntityMetaData parent, ResourceRefMetaData child, 434 UnmarshallingContext navigator, String namespaceURI, String localName) 435 { 436 parent.addResourceReference(child); 437 } 438 439 public void addChild(EntityMetaData parent, ResourceEnvRefMetaData child, 440 UnmarshallingContext navigator, String namespaceURI, String localName) 441 { 442 parent.addResourceEnvReference(child); 443 } 444 445 public void addChild(EntityMetaData parent, EnvEntryMetaData child, 446 UnmarshallingContext navigator, String namespaceURI, String localName) 447 { 448 parent.addEnvironmentEntry(child); 449 } 450 451 public void addChild(EntityMetaData parent, MessageDestinationRefMetaData child, 452 UnmarshallingContext navigator, String namespaceURI, String localName) 453 { 454 parent.addMessageDestinationReference(child); 455 } 456 457 public void addChild(EntityMetaData parent, ServiceRefMetaData child, 458 UnmarshallingContext navigator, String namespaceURI, String localName) 459 { 460 parent.addServiceReference(child); 461 } 462 463 public void addChild(SessionMetaData parent, SecurityIdentityMetaData child, 464 UnmarshallingContext navigator, String namespaceURI, String localName) 465 { 466 parent.setSecurityIdentityMetaData(child); 467 } 468 469 public void addChild(SessionMetaData parent, EjbLocalRefMetaData child, 470 UnmarshallingContext navigator, String namespaceURI, String localName) 471 { 472 parent.addEjbLocalReference(child); 473 } 474 475 public void addChild(SessionMetaData parent, EjbRefMetaData child, 476 UnmarshallingContext navigator, String namespaceURI, String localName) 477 { 478 parent.addEjbReference(child); 479 } 480 481 public void addChild(SessionMetaData parent, ResourceRefMetaData child, 482 UnmarshallingContext navigator, String namespaceURI, String localName) 483 { 484 parent.addResourceReference(child); 485 } 486 487 public void addChild(SessionMetaData parent, ResourceEnvRefMetaData child, 488 UnmarshallingContext navigator, String namespaceURI, String localName) 489 { 490 parent.addResourceEnvReference(child); 491 } 492 493 public void addChild(SessionMetaData parent, EnvEntryMetaData child, 494 UnmarshallingContext navigator, String namespaceURI, String localName) 495 { 496 parent.addEnvironmentEntry(child); 497 } 498 499 public void addChild(SessionMetaData parent, MessageDestinationRefMetaData child, 500 UnmarshallingContext navigator, String namespaceURI, String localName) 501 { 502 parent.addMessageDestinationReference(child); 503 } 504 505 public void addChild(SessionMetaData parent, ServiceRefMetaData child, 506 UnmarshallingContext navigator, String namespaceURI, String localName) 507 { 508 parent.addServiceReference(child); 509 } 510 511 public void addChild(RelationMetaData relation, RelationshipRoleMetaData role, 512 UnmarshallingContext ctx, String namespaceURI, String localName) 513 { 514 if(role.getRelationshipRoleName() == null) 515 { 516 role.setRelationshipRoleName( 517 role.getEntityName() + (role.getCMRFieldName() == null ? "" : "_" + role.getCMRFieldName()) 518 ); 519 } 520 521 if(relation.getLeftRelationshipRole() == null) 522 { 523 relation.setLeftRelationshipRole(role); 524 } 525 else 526 { 527 relation.setRightRelationshipRole(role); 528 } 529 } 530 531 public void addChild(AssemblyDescriptor ad, MessageDestinationMetaData mdmd, 532 UnmarshallingContext ctx, String namespaceURI, String localName) 533 { 534 ad.app.getAssemblyDescriptor().addMessageDestinationMetaData(mdmd); 535 } 536 537 public void addChild(AssemblyDescriptor parent, ContainerTransaction child, 538 UnmarshallingContext ctx, String namespaceURI, String localName) 539 { 540 for(int i = 0; i < child.methods.size(); ++i) 541 { 542 MethodMetaData method = (MethodMetaData)child.methods.get(i); 543 BeanMetaData bean = getBeanForMethod(parent, method); 544 545 method.setTransactionType(child.transAttr); 546 bean.addTransactionMethod(method); 547 } 548 } 549 550 public void addChild(AssemblyDescriptor parent, MethodMetaData child, 551 UnmarshallingContext ctx, String namespaceURI, String localName) 552 { 553 BeanMetaData bean = getBeanForMethod(parent, child); 554 bean.addExcludedMethod(child); 555 } 556 557 public void addChild(MessageDrivenMetaData parent, SecurityIdentityMetaData child, 558 UnmarshallingContext navigator, String namespaceURI, String localName) 559 { 560 parent.setSecurityIdentityMetaData(child); 561 } 562 563 public void addChild(MessageDrivenMetaData mdb, ActivationConfigPropertyMetaData child, 564 UnmarshallingContext ctx, String namespaceURI, String localName) 565 { 566 mdb.getActivationConfigProperties().put(child.getName(), child); 567 } 568 569 public void addChild(MessageDrivenMetaData parent, EjbLocalRefMetaData child, 570 UnmarshallingContext navigator, String namespaceURI, String localName) 571 { 572 parent.addEjbLocalReference(child); 573 } 574 575 public void addChild(MessageDrivenMetaData parent, EjbRefMetaData child, 576 UnmarshallingContext navigator, String namespaceURI, String localName) 577 { 578 parent.addEjbReference(child); 579 } 580 581 public void addChild(MessageDrivenMetaData parent, ResourceRefMetaData child, 582 UnmarshallingContext navigator, String namespaceURI, String localName) 583 { 584 parent.addResourceReference(child); 585 } 586 587 public void addChild(MessageDrivenMetaData parent, ResourceEnvRefMetaData child, 588 UnmarshallingContext navigator, String namespaceURI, String localName) 589 { 590 parent.addResourceEnvReference(child); 591 } 592 593 public void addChild(MessageDrivenMetaData parent, EnvEntryMetaData child, 594 UnmarshallingContext navigator, String namespaceURI, String localName) 595 { 596 parent.addEnvironmentEntry(child); 597 } 598 599 public void addChild(MessageDrivenMetaData parent, MessageDestinationRefMetaData child, 600 UnmarshallingContext navigator, String namespaceURI, String localName) 601 { 602 parent.addMessageDestinationReference(child); 603 } 604 605 public void addChild(MessageDrivenMetaData parent, ServiceRefMetaData child, 606 UnmarshallingContext navigator, String namespaceURI, String localName) 607 { 608 parent.addServiceReference(child); 609 } 610 611 public void addChild(MethodPermission parent, MethodMetaData child, 612 UnmarshallingContext navigator, String namespaceURI, String localName) 613 { 614 BeanMetaData bean = getBeanForMethod(parent.ad, child); 615 616 if(parent.roles == null) 617 { 618 child.setUnchecked(); 619 } 620 else 621 { 622 child.getRoles().addAll(parent.roles); 623 } 624 625 bean.addPermissionMethod(child); 626 } 627 628 636 public void setValue(ApplicationMetaData dd, 637 UnmarshallingContext navigator, String namespaceURI, String localName, 638 String value) 639 { 640 if( localName.equals("display-name") ) 641 dd.setDisplayName(value); 642 else if( localName.equals("description") ) 643 dd.setDescription(value); 644 else if(localName.equals("ejb-client-jar")) 645 dd.setClientJar(value); 646 } 647 648 656 public void setValue(EntityMetaData entity, 657 UnmarshallingContext navigator, String namespaceURI, String localName, 658 String value) 659 { 660 if( localName.equals("display-name") ) 661 entity.setDisplayName(value); 662 else if( localName.equals("description") ) 663 entity.setDescription(value); 664 else if( localName.equals("ejb-name") ) 665 entity.setEjbName(value); 666 else if( localName.equals("home") ) 667 entity.setHome(value); 668 else if( localName.equals("remote") ) 669 entity.setRemote(value); 670 else if( localName.equals("local-home") ) 671 entity.setLocalHome(value); 672 else if( localName.equals("local") ) 673 entity.setLocal(value); 674 else if( localName.equals("ejb-class") ) 675 entity.setEjbClass(value); 676 else if( localName.equals("persistence-type") ) 677 { 678 boolean cmp = false; 679 if( value.equals("Bean") ) 680 { 681 cmp = false; 682 } 683 else if( value.equals("Container") ) 684 { 685 cmp = true; 686 } 687 else 688 { 689 throw new IllegalStateException ( entity.getEjbName() + ": " + 690 "persistence-type must be 'Bean' or 'Container'!" ); 691 } 692 entity.setCmp(cmp); 693 } 694 else if( localName.equals("prim-key-class") ) 695 entity.setPrimaryKeyClass(value); 696 else if( localName.equals("reentrant") ) 697 { 698 boolean flag = Boolean.valueOf(value); 699 entity.setReentrant(flag); 700 } 701 else if( localName.equals("cmp-version") ) 702 { 703 int cmpVersion = 2; 704 if( "1.x".equals(value) ) 705 { 706 cmpVersion = 1; 707 } 708 else if( "2.x".equals(value) ) 709 { 710 cmpVersion = 2; 711 } 712 entity.setCmpVersion(cmpVersion); 713 } 714 else if( localName.equals("abstract-schema-name") ) 715 entity.setAbstractSchemaName(value); 716 else if( localName.equals("primkey-field") ) 717 entity.setPrimKeyField(value); 718 } 719 720 728 public void setValue(SessionMetaData bean, 729 UnmarshallingContext navigator, String namespaceURI, String localName, 730 String value) 731 { 732 if( localName.equals("display-name") ) 733 bean.setDisplayName(value); 734 else if( localName.equals("description") ) 735 bean.setDescription(value); 736 else if( localName.equals("ejb-name") ) 737 bean.setEjbName(value); 738 else if( localName.equals("home") ) 739 bean.setHome(value); 740 else if( localName.equals("remote") ) 741 bean.setRemote(value); 742 else if( localName.equals("local-home") ) 743 bean.setLocalHome(value); 744 else if( localName.equals("local") ) 745 bean.setLocal(value); 746 else if( localName.equals("ejb-class") ) 747 bean.setEjbClass(value); 748 else if( localName.equals("session-type") ) 749 { 750 if( value.equals("Stateful") ) 751 { 752 bean.setStateful(true); 753 } 754 else if( value.equals("Stateless") ) 755 { 756 bean.setStateful(false); 757 } 758 else 759 { 760 throw new IllegalStateException ( bean.getEjbName() + ": " + 761 "session-type must be 'Stateful' or 'Stateless' but was " + value ); 762 } 763 } 764 else if(localName.equals("transaction-type")) 765 { 766 if("Bean".equals(value)) 767 { 768 bean.setContainerManagedTx(false); 769 } 770 else if("Container".equals(value)) 771 { 772 bean.setContainerManagedTx(true); 773 } 774 else 775 { 776 throw new IllegalStateException ("Unexpected value for transaction-type: " + value); 777 } 778 } 779 } 780 781 public void setValue(MessageDrivenMetaData mdb, 782 UnmarshallingContext navigator, String namespaceURI, String localName, 783 String value) 784 { 785 if( localName.equals("display-name") ) 786 mdb.setDisplayName(value); 787 else if( localName.equals("description") ) 788 mdb.setDescription(value); 789 else if( localName.equals("ejb-name") ) 790 mdb.setEjbName(value); 791 else if(localName.equals("ejb-class")) 792 mdb.setEjbClass(value); 793 else if(localName.equals("transaction-type")) 794 { 795 if("Bean".equals(value)) 796 { 797 mdb.setContainerManagedTx(false); 798 } 799 else if("Container".equals(value)) 800 { 801 mdb.setContainerManagedTx(true); 802 } 803 else 804 { 805 throw new IllegalStateException ("Unexpected value for transaction-type: " + value); 806 } 807 } 808 else if(localName.equals("message-selector")) 809 { 810 mdb.setMessageSelector(value); 811 } 812 else if(localName.equals("messaging-type")) 813 { 814 mdb.setMessagingType(value); 815 } 816 else if(localName.equals("message-destination-type") || localName.equals("destination-type")) 817 { 818 mdb.setDestinationType(value); 819 } 820 else if(localName.equals("message-destination-type")) 821 { 822 mdb.setDestinationType(value); 823 } 824 else if(localName.equals("message-destination-link")) 825 { 826 mdb.setDestinationLink(value); 827 } 828 else if(localName.equals("acknowledge-mode")) 829 { 830 mdb.setAcknowledgeMode(value); 831 } 832 else if(localName.equals("subscription-durability")) 833 { 834 mdb.setSubscriptionDurability(value); 835 } 836 } 837 838 public void setValue(IconMetaData icon, 839 UnmarshallingContext navigator, String namespaceURI, String localName, 840 String value) 841 { 842 if( localName.equals("small-icon") ) 843 icon.setSmallIcon(value); 844 if( localName.equals("large-icon") ) 845 icon.setLargeIcon(value); 846 } 847 848 public void setValue(RelationMetaData relation, 849 UnmarshallingContext navigator, String namespaceURI, String localName, 850 String value) 851 { 852 if( localName.equals("description") ) 853 { 854 relation.setDescription(value); 855 } 856 else if( localName.equals("display-name") ) 857 { 858 relation.setDisplayName(value); 859 } 860 else if( localName.equals("ejb-relation-name") ) 861 { 862 relation.setRelationName(value); 863 } 864 else if( localName.equals("ejb-relation-name") ) 865 { 866 relation.setRelationName(value); 867 } 868 } 869 870 public void setValue(RelationshipRoleMetaData role, 871 UnmarshallingContext navigator, String namespaceURI, String localName, 872 String value) 873 { 874 if(localName.equals("ejb-relationship-role-name")) 875 { 876 role.setRelationshipRoleName(value); 877 } 878 else if(localName.equals("multiplicity")) 879 { 880 role.setMultiplicity(value); 881 } 882 else if(localName.equals("ejb-name")) 883 { 884 role.setEntityName(value); 885 } 886 else if(localName.equals("cmr-field-name")) 887 { 888 role.setCmrFieldName(value); 889 } 890 else if(localName.equals("cmr-field-type")) 891 { 892 role.setCmrFieldType(value); 893 } 894 } 895 896 public void setValue(CMPFieldMetaData field, 897 UnmarshallingContext navigator, String namespaceURI, String localName, 898 String value) 899 { 900 if(localName.equals("field-name")) 901 { 902 field.name = value; 903 } 904 } 905 906 public void setValue(AssemblyDescriptor ad, 907 UnmarshallingContext navigator, String namespaceURI, String localName, 908 String value) 909 { 910 if(localName.equals("role-name")) 911 { 912 ad.app.getAssemblyDescriptor().addSecurityRoleMetaData(new SecurityRoleMetaData(value)); 913 } 914 } 915 916 public void setValue(MethodPermission method, 917 UnmarshallingContext navigator, String namespaceURI, String localName, 918 String value) 919 { 920 if(localName.equals("role-name")) 921 { 922 method.addRole(value); 923 } 924 } 925 926 public void setValue(ContainerTransaction parent, 927 UnmarshallingContext navigator, String namespaceURI, String localName, 928 String value) 929 { 930 if(localName.equals("trans-attribute")) 931 { 932 parent.transAttr = MethodMetaData.getTransactionAttribute(value); 933 } 934 } 935 936 public void setValue(MethodMetaData method, 937 UnmarshallingContext navigator, String namespaceURI, String localName, 938 String value) 939 { 940 if(localName.equals("ejb-name")) 941 { 942 method.setEjbName(value); 943 } 944 else if(localName.equals("method-intf")) 945 { 946 method.setInterfaceType(value); 947 } 948 else if(localName.equals("method-name")) 949 { 950 method.setMethodName(value); 951 } 952 else if(localName.equals("method-param")) 953 { 954 method.addParam(value); 955 } 956 } 957 958 public void setValue(QueryMetaData query, 959 UnmarshallingContext navigator, String namespaceURI, String localName, 960 String value) 961 { 962 if(localName.equals("result-type-mapping")) 963 { 964 query.setResultTypeMapping(value); 965 } 966 else if(localName.equals("ejb-ql")) 967 { 968 query.setEjbQl(value); 969 } 970 else if(localName.equals("method-name")) 971 { 972 query.setMethodName(value); 973 } 974 else if(localName.equals("method-param")) 975 { 976 query.addMethodParam(value); 977 } 978 } 979 980 public void setValue(ActivationConfigPropertyMetaData prop, 981 UnmarshallingContext navigator, String namespaceURI, String localName, 982 String value) 983 { 984 if(localName.equals("activation-config-property-name")) 985 { 986 prop.setName(value); 987 } 988 else if(localName.equals("activation-config-property-value")) 989 { 990 prop.setValue(value); 991 } 992 } 993 994 997 public void setValue(SecurityIdentityMetaData parent, 998 UnmarshallingContext navigator, String namespaceURI, String localName, 999 String value) 1000 { 1001 if(localName.equals("role-name")) 1002 { 1003 parent.setRunAsRoleName(value); 1004 } 1005 } 1006 1007 public void setValue(MessageDestinationMetaData mdmd, 1008 UnmarshallingContext navigator, String namespaceURI, String localName, 1009 String value) 1010 { 1011 if(localName.equals("message-destination-name")) 1012 { 1013 mdmd.setName(value); 1014 } 1015 } 1016 1017 1019 private BeanMetaData getBeanForMethod(AssemblyDescriptor parent, MethodMetaData child) 1020 { 1021 if(child.getEjbName() == null) 1022 { 1023 throw new IllegalStateException ("Method permission without ejb-name!"); 1024 } 1025 1026 BeanMetaData bean = parent.app.getBeanByEjbName(child.getEjbName()); 1027 if(bean == null) 1028 { 1029 throw new IllegalStateException ("Bean " + child.getEjbName() + " not found in the application."); 1030 } 1031 return bean; 1032 } 1033 1034 1036 public static class CMPFieldMetaData 1037 { 1038 String name; 1039 } 1040 1041 public static class AssemblyDescriptor 1042 { 1043 ApplicationMetaData app; 1044 1045 public AssemblyDescriptor(ApplicationMetaData app) 1046 { 1047 this.app = app; 1048 } 1049 } 1050 1051 public static class MethodPermission 1052 { 1053 AssemblyDescriptor ad; 1054 List roles; 1055 1056 public MethodPermission(AssemblyDescriptor ad) 1057 { 1058 this.ad = ad; 1059 } 1060 1061 void addRole(String role) 1062 { 1063 if(roles == null) 1064 { 1065 roles = new ArrayList (); 1066 } 1067 roles.add(role); 1068 } 1069 } 1070 1071 public static class ContainerTransaction 1072 { 1073 List methods = new ArrayList (); 1074 byte transAttr; 1075 } 1076} 1077 | Popular Tags |