1 23 24 package com.sun.enterprise.deployment.util; 25 26 import java.util.*; 27 import java.util.logging.Level ; 28 import java.lang.reflect.Method ; 29 import java.lang.reflect.Field ; 30 import java.security.AccessController ; 31 import java.security.Principal ; 32 import java.security.PrivilegedAction ; 33 import javax.security.auth.Subject ; 34 import com.sun.enterprise.deployment.Application; 35 import com.sun.enterprise.deployment.ApplicationClientDescriptor; 36 import com.sun.enterprise.deployment.BundleDescriptor; 37 import com.sun.enterprise.deployment.ContainerTransaction; 38 import com.sun.enterprise.deployment.Descriptor; 39 import com.sun.enterprise.deployment.DynamicAttributesDescriptor; 40 import com.sun.enterprise.deployment.EjbDescriptor; 41 import com.sun.enterprise.deployment.EjbBundleDescriptor; 42 import com.sun.enterprise.deployment.EjbEntityDescriptor; 43 import com.sun.enterprise.deployment.EjbMessageBeanDescriptor; 44 import com.sun.enterprise.deployment.EjbReferenceDescriptor; 45 import com.sun.enterprise.deployment.InjectionCapable; 46 import com.sun.enterprise.deployment.JmsDestinationReferenceDescriptor; 47 import com.sun.enterprise.deployment.MethodDescriptor; 48 import com.sun.enterprise.deployment.MessageDestinationDescriptor; 49 import com.sun.enterprise.deployment.MessageDestinationReferenceDescriptor; 50 import com.sun.enterprise.deployment.PersistenceDescriptor; 51 import com.sun.enterprise.deployment.RelationshipDescriptor; 52 import com.sun.enterprise.deployment.ResourceReferenceDescriptor; 53 import com.sun.enterprise.deployment.RunAsIdentityDescriptor; 54 import com.sun.enterprise.deployment.WebBundleDescriptor; 55 import com.sun.enterprise.deployment.WebService; 56 import com.sun.enterprise.deployment.InterceptorBindingDescriptor; 57 import com.sun.enterprise.deployment.EjbInterceptor; 58 import com.sun.enterprise.deployment.InjectionTarget; 59 import com.sun.enterprise.deployment.types.EjbReference; 60 import com.sun.enterprise.deployment.interfaces.*; 61 import com.sun.enterprise.util.LocalStringManagerImpl; 62 import com.sun.enterprise.util.TypeUtil; 63 64 69 public class EjbBundleValidator extends ComponentValidator implements EjbBundleVisitor { 70 71 protected EjbBundleDescriptor ejbBundleDescriptor=null; 72 protected EjbDescriptor ejb = null; 73 private static LocalStringManagerImpl localStrings = 74 new LocalStringManagerImpl(EjbBundleValidator.class); 75 76 79 public void accept(EjbBundleDescriptor bundleDescriptor) { 80 this.ejbBundleDescriptor = bundleDescriptor; 81 if (bundleDescriptor.getEjbs().size() == 0) { 82 throw new IllegalArgumentException (localStrings.getLocalString( 83 "enterprise.deployment.util.no_ejb_in_ejb_jar", 84 "Invalid ejb jar {0}: it contains zero ejb. A valid ejb jar requires at least one session/entity/message driven bean.", 85 new Object [] {bundleDescriptor.getModuleDescriptor().getArchiveUri()})); 86 } 87 88 if (!bundleDescriptor.areResourceReferencesValid()) { 89 throw new RuntimeException ("Incorrectly resolved role references"); 90 } 91 92 handleOverloadedInterceptorMethodBindings(bundleDescriptor); 97 98 InterceptorBindingTranslator bindingTranslator = 99 new InterceptorBindingTranslator(bundleDescriptor); 100 101 for(Iterator iter = bundleDescriptor.getEjbs().iterator(); 102 iter.hasNext();) { 103 EjbDescriptor ejb = (EjbDescriptor) iter.next(); 104 if( ejb.getType() != EjbEntityDescriptor.TYPE ) { 105 ejb.applyInterceptors(bindingTranslator); 106 } 107 } 108 } 109 110 private void handleOverloadedInterceptorMethodBindings(EjbBundleDescriptor 111 bundleDesc) { 112 113 List<InterceptorBindingDescriptor> origBindings = 114 bundleDesc.getInterceptorBindings(); 115 116 if( origBindings.isEmpty() ) { 117 return; 118 } 119 120 ClassLoader cl = bundleDesc.getClassLoader(); 121 122 List<InterceptorBindingDescriptor> newBindings = 123 new LinkedList<InterceptorBindingDescriptor>(); 124 125 for(InterceptorBindingDescriptor next : origBindings) { 126 127 if( next.getNeedsOverloadResolution() ) { 128 129 MethodDescriptor overloadedMethodDesc = 130 next.getBusinessMethod(); 131 String methodName = overloadedMethodDesc.getName(); 132 String ejbName = next.getEjbName(); 134 135 EjbDescriptor ejbDesc = bundleDesc.getEjbByName(ejbName); 136 Class ejbClass = null; 137 138 try { 139 ejbClass = cl.loadClass(ejbDesc.getEjbClassName()); 140 } catch(Exception e) { 141 RuntimeException re = new RuntimeException 142 ("Error loading ejb class "+ejbDesc.getEjbClassName()); 143 re.initCause(e); 144 throw re; 145 } 146 147 for(Method ejbClassMethod : ejbClass.getDeclaredMethods()) { 148 149 if( ejbClassMethod.getName().equals(methodName) ) { 150 151 InterceptorBindingDescriptor newInterceptorBinding = 152 new InterceptorBindingDescriptor(); 153 154 MethodDescriptor newMethodDesc = new MethodDescriptor 155 (ejbClassMethod, MethodDescriptor.EJB_BEAN); 156 157 newInterceptorBinding.setEjbName(ejbName); 158 newInterceptorBinding.setBusinessMethod 159 (newMethodDesc); 160 for(String interceptorClass : 161 next.getInterceptorClasses()) { 162 newInterceptorBinding.appendInterceptorClass 163 (interceptorClass); 164 } 165 newInterceptorBinding.setIsTotalOrdering 166 (next.getIsTotalOrdering()); 167 newInterceptorBinding.setExcludeDefaultInterceptors 168 (next.getExcludeDefaultInterceptors()); 169 newInterceptorBinding.setExcludeClassInterceptors 170 (next.getExcludeClassInterceptors()); 171 172 newBindings.add(newInterceptorBinding); 173 174 } 175 176 } 177 178 179 } else { 180 181 newBindings.add(next); 182 183 } 184 185 } 186 187 bundleDesc.setInterceptorBindings(newBindings); 188 } 189 190 195 public void accept(InjectionCapable injectable) { 196 acceptWithCL(injectable); 197 acceptWithoutCL(injectable); 198 } 199 200 204 public void accept(EjbDescriptor ejb) { 205 206 this.ejb =ejb; 207 setDOLDefault(ejb); 208 computeRuntimeDefault(ejb); 209 210 try { 211 212 ClassLoader cl = ejb.getEjbBundleDescriptor().getClassLoader(); 213 Class ejbClass = cl.loadClass(ejb.getEjbClassName()); 214 215 if( !ejb.isTimedObject() ) { 218 219 if( javax.ejb.TimedObject .class.isAssignableFrom(ejbClass) ) { 220 MethodDescriptor timedObjectMethod = 221 new MethodDescriptor("ejbTimeout", 222 "TimedObject timeout method", 223 new String [] {"javax.ejb.Timer"}, 224 MethodDescriptor.EJB_BEAN); 225 ejb.setEjbTimeoutMethod(timedObjectMethod); 226 } 227 } else { 228 String timeoutMethodName = ejb.getEjbTimeoutMethod().getName(); 234 MethodDescriptor timeoutMethodDesc = null; 235 Class nextClass = ejbClass; 236 while((nextClass != Object .class) && (nextClass != null) 237 && (timeoutMethodDesc == null) ) { 238 Method [] methods = nextClass.getDeclaredMethods(); 239 for(Method m : methods) { 240 if( (m.getName().equals(timeoutMethodName)) ) { 241 Class [] params = m.getParameterTypes(); 242 if( (params.length == 1) && 243 (params[0] == javax.ejb.Timer .class) ) { 244 timeoutMethodDesc = new MethodDescriptor 245 (m, MethodDescriptor.EJB_BEAN); 246 ejb.setEjbTimeoutMethod(timeoutMethodDesc); 247 break; 248 } 249 } 250 } 251 nextClass = nextClass.getSuperclass(); 252 } 253 } 254 255 } catch(Exception e) { 256 RuntimeException re = new RuntimeException 257 ("Error processing EjbDescriptor"); 258 re.initCause(e); 259 throw re; 260 } 261 262 263 } 264 265 public void accept(WebService webService) { 266 } 267 268 272 public void accept(EjbReference ejbRef) { 273 DOLUtils.getDefaultLogger().fine("Visiting Ref" + ejbRef); 274 if (ejbRef.getEjbDescriptor()!=null) 275 return; 276 277 297 if (ejbRef.getJndiName()!=null && ejbRef.getJndiName().length()!=0) { 298 299 300 if (!ejbRef.isLocal() || (ejbRef.isLocal() && ejbRef.getLinkName()==null)) { 304 DOLUtils.getDefaultLogger().fine("Ref " + ejbRef.getName() + " is bound to Ejb with JNDI Name " + ejbRef.getJndiName()); 305 if (getEjbDescriptors() != null) { 306 for (Iterator iter = getEjbDescriptors().iterator(); iter.hasNext();) { 307 EjbDescriptor ejb = (EjbDescriptor)iter.next(); 308 309 if (ejbRef.getJndiName().equals(ejb.getJndiName())) { 310 ejbRef.setEjbDescriptor(ejb); 311 return; 312 } 313 } 314 } 315 } 316 } 317 318 if (( (ejbRef.getJndiName() == null) || 323 (ejbRef.getJndiName().length() == 0) ) 324 && 325 ( (ejbRef.getLinkName() == null) || 326 (ejbRef.getLinkName().length() == 0) )) { 327 328 Map<String , EjbIntfInfo> ejbIntfInfoMap = getEjbIntfMap(); 329 if ( ejbIntfInfoMap.size() > 0 ) { 330 331 String interfaceToMatch = ejbRef.isEJB30ClientView() ? 332 ejbRef.getEjbInterface() : ejbRef.getEjbHomeInterface(); 333 334 EjbIntfInfo intfInfo = ejbIntfInfoMap.get(interfaceToMatch); 335 336 if ( intfInfo != null ) { 338 int numMatches = intfInfo.ejbs.size(); 339 if( numMatches == 1 ) { 340 Iterator iter = intfInfo.ejbs.iterator(); 341 342 EjbDescriptor target = (EjbDescriptor)iter.next(); 343 344 BundleDescriptor targetModule = 345 target.getEjbBundleDescriptor(); 346 BundleDescriptor sourceModule = 347 ejbRef.getReferringBundleDescriptor(); 348 349 364 String ejbLinkName = target.getName(); 372 if( sourceModule != targetModule ) { 373 374 String relativeUri = getApplication(). 377 getRelativeUri(sourceModule, targetModule); 378 ejbLinkName = relativeUri + "#" + ejbLinkName; 379 } 380 381 ejbRef.setLinkName(ejbLinkName); 382 383 } else { 384 String msg = "Cannot resolve reference " + ejbRef + 385 " because there are " + numMatches + " ejbs " + 386 " in the application with interface " + 387 interfaceToMatch; 388 389 DOLUtils.getDefaultLogger().severe(msg); 390 throw new RuntimeException (msg); 391 } 392 } 393 } 394 } 395 396 if (ejbRef.getLinkName()==null) { 398 399 400 if (ejbRef.isLocal()) { 404 DOLUtils.getDefaultLogger().severe("Cannot resolve reference " + ejbRef); 405 throw new RuntimeException ("Cannot resolve reference " + ejbRef); 406 } else { 407 if (ejbRef.getJndiName() == null || 410 ejbRef.getJndiName().length() == 0) { 411 String jndiName = getDefaultEjbJndiName( 412 ejbRef.isEJB30ClientView() ? 413 ejbRef.getEjbInterface() : ejbRef.getEjbHomeInterface()); 414 ejbRef.setJndiName(jndiName); 415 DOLUtils.getDefaultLogger().fine("Applying default to ejb reference: " + ejbRef); 416 } 417 418 return; 419 } 420 } 421 422 424 String homeClassName = ejbRef.getEjbHomeInterface(); 426 String intfClassName = ejbRef.getEjbInterface(); 427 428 String type = ejbRef.getType(); 430 431 EjbDescriptor ejbReferee=null; 432 433 String linkName = ejbRef.getLinkName(); 434 int ind = linkName.lastIndexOf('#'); 435 if ( ind != -1 ) { 436 String ejbName = linkName.substring(ind+1); 439 String jarPath = linkName.substring(0, ind); 440 BundleDescriptor referringJar = ejbRef.getReferringBundleDescriptor(); 441 if (referringJar==null) { 442 ejbRef.setReferringBundleDescriptor(getBundleDescriptor()); 443 referringJar = getBundleDescriptor(); 444 } 445 446 if (getApplication()!=null) { 447 BundleDescriptor refereeJar = 448 getApplication().getRelativeBundle(referringJar, jarPath); 449 if( (refereeJar != null) && 450 refereeJar instanceof EjbBundleDescriptor ) { 451 ejbReferee = 453 ((EjbBundleDescriptor)refereeJar).getEjbByName(ejbName); 454 } 455 } 456 } 457 else { 458 459 461 if ( (getApplication() != null) && (ejbBundleDescriptor != null) 472 && ejbBundleDescriptor.hasEjbByName(linkName) ) { 473 474 ejbReferee = ejbBundleDescriptor.getEjbByName(linkName); 475 476 } else if ( (getApplication() != null) && 477 getApplication().hasEjbByName(linkName)) { 478 479 ejbReferee = 480 getApplication().getEjbByName(ejbRef.getLinkName()); 481 482 } else if (ejb!=null) { 483 try { 484 ejbReferee = ejb.getEjbBundleDescriptor().getEjbByName(ejbRef.getLinkName()); 485 } catch (IllegalArgumentException e) { 486 DOLUtils.getDefaultLogger().warning("Unresolved <ejb-link>: "+linkName); 490 return; 491 } 492 493 } 494 } 495 496 if (ejbReferee==null) 497 { 498 499 if (ejbRef.isLocal()) { 504 DOLUtils.getDefaultLogger().severe("Unresolved <ejb-link>: "+linkName); 505 throw new RuntimeException ("Error: Unresolved <ejb-link>: "+linkName); 506 } else { 507 DOLUtils.getDefaultLogger().warning("Unresolved <ejb-link>: "+linkName); 508 return; 509 } 510 } else { 511 512 if( ejbRef.isEJB30ClientView() ) { 513 514 BundleDescriptor referringBundle = 515 ejbRef.getReferringBundleDescriptor(); 516 517 if( ( (referringBundle == null) && (ejbBundleDescriptor == null) ) 521 || 522 (referringBundle instanceof ApplicationClientDescriptor) 523 || 524 ( (getApplication() == null) && 525 (referringBundle instanceof WebBundleDescriptor) ) ) { 526 527 ejbRef.setLocal(false); 528 529 535 if( !ejbReferee.getRemoteBusinessClassNames().contains 536 (intfClassName) ) { 537 String msg = "Target ejb " + ejbReferee.getName() + " for " + 538 " remote ejb 3.0 reference " + ejbRef.getName() + 539 " does not expose a remote business interface of type " + 540 intfClassName; 541 throw new RuntimeException (msg); 542 } 543 544 } else if(ejbReferee.getLocalBusinessClassNames(). 545 contains(intfClassName)) { 546 547 ejbRef.setLocal(true); 548 549 } else if(ejbReferee.getRemoteBusinessClassNames(). 550 contains(intfClassName)) { 551 552 ejbRef.setLocal(false); 553 554 } else { 555 String msg = "Warning : Unable to determine local " + 556 " business vs. remote business designation for " + 557 " EJB 3.0 ref " + ejbRef; 558 throw new RuntimeException (msg); 559 } 560 } 561 562 ejbRef.setEjbDescriptor(ejbReferee); 563 } 564 565 567 if(DOLUtils.getDefaultLogger().isLoggable(Level.FINE)) { 568 DOLUtils.getDefaultLogger().fine("Done Visiting " + ejb.getName() + " reference " + ejbRef); 569 } 570 571 if( ejbReferee != null ) { 574 575 if( ejbRef.isEJB30ClientView() ) { 576 577 Set<String > targetBusinessIntfs = ejbRef.isLocal() ? 578 ejbReferee.getLocalBusinessClassNames() : 579 ejbReferee.getRemoteBusinessClassNames(); 580 581 if( !targetBusinessIntfs.contains(intfClassName) ) { 582 583 DOLUtils.getDefaultLogger().log(Level.WARNING, 584 "enterprise.deployment.backend.ejbRefTypeMismatch", 585 new Object [] {ejbRef.getName() , intfClassName, 586 ejbReferee.getName(), ( ejbRef.isLocal() ? 587 "Local Business" : "Remote Business"), 588 targetBusinessIntfs.toString()}); 589 590 if( targetBusinessIntfs.size() == 1 ) { 593 Iterator iter = targetBusinessIntfs.iterator(); 594 ejbRef.setEjbInterface((String )iter.next()); 595 } 596 } 597 598 } else { 599 600 String targetHome = ejbRef.isLocal() ? 601 ejbReferee.getLocalHomeClassName() : 602 ejbReferee.getHomeClassName(); 603 604 if( !homeClassName.equals(targetHome) ) { 605 606 DOLUtils.getDefaultLogger().log(Level.WARNING, 607 "enterprise.deployment.backend.ejbRefTypeMismatch", 608 new Object [] {ejbRef.getName() , homeClassName, 609 ejbReferee.getName(), ( ejbRef.isLocal() ? 610 "Local Home" : "Remote Home"), targetHome}); 611 612 if( targetHome != null ) { 613 ejbRef.setEjbHomeInterface(targetHome); 614 } 615 } 616 617 String targetComponentIntf = ejbRef.isLocal() ? 618 ejbReferee.getLocalClassName() : 619 ejbReferee.getRemoteClassName(); 620 621 if( (intfClassName != null) && 625 !intfClassName.equals(targetComponentIntf) ) { 626 627 DOLUtils.getDefaultLogger().log(Level.WARNING, 628 "enterprise.deployment.backend.ejbRefTypeMismatch", 629 new Object [] {ejbRef.getName() , intfClassName, 630 ejbReferee.getName(), ( ejbRef.isLocal() ? 631 "Local" : "Remote"), targetComponentIntf}); 632 633 if( targetComponentIntf != null ) { 634 ejbRef.setEjbInterface(targetComponentIntf); 635 } 636 } 637 } 638 } 639 640 if (!type.equals(ejbRef.getType())) { 641 DOLUtils.getDefaultLogger().log(Level.WARNING, "enterprise.deployment.backend.invalidDescriptorMappingFailure", 642 new Object [] {linkName , ejbRef.getType()}); 643 644 ejbRef.setType(ejbRef.getType()); 645 646 } 647 } 648 649 public void accept(ResourceReferenceDescriptor resRef) { 650 computeRuntimeDefault(resRef); 651 } 652 653 public void accept(JmsDestinationReferenceDescriptor jmsDestRef) { 654 computeRuntimeDefault(jmsDestRef); 655 } 656 657 public void accept(MessageDestinationReferenceDescriptor msgDestRef) { 658 computeRuntimeDefault(msgDestRef); 659 } 660 661 public void accept(MessageDestinationDescriptor msgDest) { 662 computeRuntimeDefault(msgDest); 663 } 664 665 670 private Map<String , EjbIntfInfo> getEjbIntfMap() { 671 672 Collection ejbs = getEjbDescriptors(); 673 674 Map<String , EjbIntfInfo> intfInfoMap=new HashMap<String , EjbIntfInfo>(); 675 676 for(Iterator iter = ejbs.iterator(); iter.hasNext();) { 677 EjbDescriptor next = (EjbDescriptor) iter.next(); 678 679 if( next.isRemoteInterfacesSupported() ) { 680 addIntfInfo(intfInfoMap, next.getHomeClassName(), 681 EjbIntfType.REMOTE_HOME, next); 682 } 683 684 if( next.isRemoteBusinessInterfacesSupported() ) { 685 for(String nextIntf : next.getRemoteBusinessClassNames()) { 686 addIntfInfo(intfInfoMap, nextIntf, 687 EjbIntfType.REMOTE_BUSINESS, next); 688 } 689 } 690 691 if( next.isLocalInterfacesSupported() ) { 692 addIntfInfo(intfInfoMap, next.getLocalHomeClassName(), 693 EjbIntfType.LOCAL_HOME, next); 694 } 695 696 if( next.isLocalBusinessInterfacesSupported() ) { 697 for(String nextIntf : next.getLocalBusinessClassNames()) { 698 addIntfInfo(intfInfoMap, nextIntf, 699 EjbIntfType.LOCAL_BUSINESS, next); 700 } 701 } 702 703 } 704 705 return intfInfoMap; 706 } 707 708 private void addIntfInfo(Map<String , EjbIntfInfo> intfInfoMap, 709 String intf, EjbIntfType intfType, 710 EjbDescriptor ejbDesc) { 711 712 EjbIntfInfo intfInfo = intfInfoMap.get(intf); 713 if( intfInfo == null ) { 714 EjbIntfInfo newInfo = new EjbIntfInfo(); 715 newInfo.ejbs = new HashSet<EjbDescriptor>(); 716 newInfo.ejbs.add(ejbDesc); 717 newInfo.intfType = intfType; 718 intfInfoMap.put(intf, newInfo); 719 } else { 720 intfInfo.ejbs.add(ejbDesc); 721 intfInfo.intfType = EjbIntfType.NONE; 723 } 724 725 } 726 727 730 protected Collection getEjbDescriptors() { 731 if (getApplication() != null) { 732 return getApplication().getEjbDescriptors(); 733 } else if (ejbBundleDescriptor!=null) { 734 return ejbBundleDescriptor.getEjbs(); 735 } else { 736 return new HashSet(); 737 } 738 } 739 740 743 protected Application getApplication() { 744 return null; 745 } 746 747 750 protected BundleDescriptor getBundleDescriptor() { 751 return ejbBundleDescriptor; 752 } 753 754 761 protected void computeRunAsPrincipalDefault(RunAsIdentityDescriptor runAs, 762 Application application) { 763 764 if (runAs != null && 766 (runAs.getRoleName() == null || 767 runAs.getRoleName().length() == 0)) { 768 DOLUtils.getDefaultLogger().log(Level.WARNING, 769 "enterprise.deployment.backend.emptyRoleName"); 770 return; 771 } 772 773 if (runAs != null && 774 (runAs.getPrincipal() == null || 775 runAs.getPrincipal().length() == 0) && 776 application != null && application.getRoleMapper() != null) { 777 778 String principalName = null; 779 String roleName = runAs.getRoleName(); 780 781 final Subject fs = (Subject )application.getRoleMapper().getRoleToSubjectMapping().get(roleName); 782 if (fs != null) { 783 principalName = (String )AccessController.doPrivileged(new PrivilegedAction () { 784 public Object run() { 785 Set<Principal > pset = fs.getPrincipals(); 786 Principal prin = null; 787 if (pset.size() > 0) { 788 prin = (Principal )pset.iterator().next(); 789 DOLUtils.getDefaultLogger().log(Level.WARNING, 790 "enterprise.deployment.backend.computeRunAsPrincipal", 791 new Object [] { prin.getName() }); 792 } 793 return (prin != null) ? prin.getName() : null; 794 } 795 }); 796 } 797 798 if (principalName == null || principalName.length() == 0) { 799 throw new RuntimeException ("The RunAs role " + "\"" + roleName + "\"" + 800 " is not mapped to a principal."); 801 } 802 runAs.setPrincipal(principalName); 803 } 804 } 805 806 809 private void setDOLDefault(EjbDescriptor ejb) { 810 if (ejb.getUsesCallerIdentity() == null) { 811 if (ejb instanceof EjbMessageBeanDescriptor) { 812 ejb.setUsesCallerIdentity(false); 813 } else { 814 ejb.setUsesCallerIdentity(true); 815 } 816 } 817 if (ejb.getTransactionType() == null) { 819 ejb.setTransactionType(EjbDescriptor.CONTAINER_TRANSACTION_TYPE); 820 } 821 ejb.setUsesDefaultTransaction(); 822 } 823 824 827 private void computeRuntimeDefault(EjbDescriptor ejb) { 828 String intfName = null; 829 830 if ((ejb.getJndiName() == null) || (ejb.getJndiName().length() == 0)) { 831 if (ejb.isRemoteInterfacesSupported() && ejb.isRemoteBusinessInterfacesSupported()) { 832 } else if (ejb.isRemoteInterfacesSupported()) { 834 intfName = ejb.getHomeClassName(); 836 } else if (ejb.isRemoteBusinessInterfacesSupported()) { 837 Set<String > classNames = ejb.getRemoteBusinessClassNames(); 838 if (classNames.size() == 1) { 839 intfName = (String )classNames.iterator().next(); 840 } 841 } 842 } 843 844 if( intfName != null ) { 845 String jndiName = getDefaultEjbJndiName(intfName); 846 ejb.setJndiName(jndiName); 847 } 848 849 if (!ejb.getUsesCallerIdentity()) { 850 computeRunAsPrincipalDefault( 851 ejb.getRunAsIdentity(), ejb.getApplication()); 852 } 853 } 854 855 858 private void computeRuntimeDefault(ResourceReferenceDescriptor resRef) { 859 if (resRef.getJndiName() == null || 860 resRef.getJndiName().length() == 0) { 861 resRef.setJndiName(getDefaultResourceJndiName(resRef.getName())); 862 } 863 } 864 865 868 private void computeRuntimeDefault(JmsDestinationReferenceDescriptor jmsDestRef) { 869 if (jmsDestRef.getJndiName() == null || 870 jmsDestRef.getJndiName().length() == 0) { 871 jmsDestRef.setJndiName(getDefaultResourceJndiName(jmsDestRef.getName())); 872 } 873 } 874 875 878 private void computeRuntimeDefault(MessageDestinationReferenceDescriptor msgDestRef) { 879 if (msgDestRef.getJndiName() == null || 880 msgDestRef.getJndiName().length() == 0) { 881 msgDestRef.setJndiName(getDefaultResourceJndiName(msgDestRef.getName())); 882 } 883 } 884 885 888 private void computeRuntimeDefault(MessageDestinationDescriptor msgDest) { 889 if (msgDest.getJndiName() == null || 890 msgDest.getJndiName().length() == 0) { 891 msgDest.setJndiName(getDefaultResourceJndiName(msgDest.getName())); 892 } 893 } 894 895 899 private String getDefaultResourceJndiName(String resName) { 900 return resName; 901 } 902 903 907 private String getDefaultEjbJndiName(String intfName) { 910 return intfName; 911 } 912 913 private enum EjbIntfType { 914 NONE, 915 REMOTE_HOME, 916 REMOTE_BUSINESS, 917 LOCAL_HOME, 918 LOCAL_BUSINESS 919 } 920 921 private static class EjbIntfInfo { 922 923 Set<EjbDescriptor> ejbs; 924 925 EjbIntfType intfType; 928 } 929 930 } 931 | Popular Tags |