1 25 26 package org.objectweb.jonas_ejb.container; 27 28 import java.io.File ; 29 import java.lang.reflect.Method ; 30 import java.util.Collections ; 31 import java.util.Enumeration ; 32 import java.util.HashMap ; 33 import java.util.HashSet ; 34 import java.util.Iterator ; 35 import java.util.Properties ; 36 import java.util.Set ; 37 38 import javax.ejb.AccessLocalException ; 39 import javax.ejb.EJBException ; 40 import javax.naming.Context ; 41 import javax.naming.InitialContext ; 42 import javax.naming.LinkRef ; 43 import javax.naming.NamingException ; 44 import javax.naming.NameNotFoundException ; 45 import javax.naming.Reference ; 46 import javax.naming.StringRefAddr ; 47 import javax.resource.spi.ActivationSpec ; 48 import javax.resource.spi.work.WorkManager ; 49 import javax.security.jacc.PolicyContext ; 50 51 import org.objectweb.jonas.common.JProp; 52 import org.objectweb.jonas.resource.Rar; 53 import org.objectweb.jonas.ws.JServiceFactory; 54 import org.objectweb.jonas.ws.JServiceFactoryFinder; 55 import org.objectweb.jonas_ejb.container.jorm.RdbFactory; 56 import org.objectweb.jonas_ejb.deployment.api.BeanDesc; 57 import org.objectweb.jonas_ejb.deployment.api.EntityBmpDesc; 58 import org.objectweb.jonas_ejb.deployment.api.EntityCmpDesc; 59 import org.objectweb.jonas_ejb.deployment.api.EntityDesc; 60 import org.objectweb.jonas_ejb.deployment.api.EntityJdbcCmp1Desc; 61 import org.objectweb.jonas_ejb.deployment.api.EntityJdbcCmp2Desc; 62 import org.objectweb.jonas_ejb.deployment.api.MessageDrivenDesc; 63 import org.objectweb.jonas_ejb.deployment.api.SessionStatefulDesc; 64 import org.objectweb.jonas_ejb.deployment.api.SessionStatelessDesc; 65 import org.objectweb.jonas_ejb.lib.EJBInvocation; 66 67 import org.objectweb.jonas_lib.deployment.api.EjbLocalRefDesc; 68 import org.objectweb.jonas_lib.deployment.api.EjbRefDesc; 69 import org.objectweb.jonas_lib.deployment.api.EnvEntryDesc; 70 import org.objectweb.jonas_lib.deployment.api.MessageDestinationRefDesc; 71 import org.objectweb.jonas_lib.deployment.api.ResourceEnvRefDesc; 72 import org.objectweb.jonas_lib.deployment.api.ResourceRefDesc; 73 import org.objectweb.jonas_lib.naming.ContainerNaming; 74 import org.objectweb.jonas_lib.security.PermissionManagerException; 75 76 import org.objectweb.jonas_jms.api.JmsManager; 77 78 import org.objectweb.jonas_ws.deployment.api.ServiceRefDesc; 79 80 import org.objectweb.transaction.jta.TransactionManager; 81 82 import org.objectweb.carol.rmi.exception.NamingExceptionHelper; 83 84 import org.objectweb.util.monolog.api.BasicLevel; 85 86 100 101 public class JContainer implements Container { 102 103 106 public static final String DEFAULT_FACTORY_CLASS_NAME = "org.objectweb.jonas_ejb.container.JEntityFactory"; 107 108 111 private static WorkManager workManager = null; 112 113 116 private HashMap beanList = new HashMap (); 117 118 121 private String earFileName = null; 122 123 126 private String fileName; 127 128 131 private String externalFileName; 132 133 136 private JmsManager jms = null; 137 138 141 private ClassLoader loader = null; 142 143 146 private String myname; 147 148 151 private ContainerNaming naming = null; 152 153 156 private PermissionManager permissionManager = null; 157 158 161 private PrincipalFactory principalFactory = null; 162 163 166 private boolean securityFlag = true; 167 168 171 private Swapper swapper; 172 173 176 private TransactionManager tm = null; 177 178 private String tmpDirName = null; 179 180 184 private static final String DEFAULT_ACTIVATION_SPEC_NAME = "joramActivationSpec"; 185 186 193 public JContainer(String name, String extFileName, String file, ClassLoader ld) { 194 myname = name; 195 externalFileName = extFileName; 196 fileName = file; 197 loader = ld; 198 swapper = new Swapper(this); 199 swapper.start(); 200 if (TraceEjb.isDebugIc()) { 201 TraceEjb.interp.log(BasicLevel.DEBUG, "New Container extFN= " + externalFileName + " filename=" + fileName); 202 } 203 tmpDirName = JProp.getJonasBase() + File.separator + "tmp"; 204 File d = new File (tmpDirName); 205 d.mkdir(); 206 } 207 208 public String getTmpDirName() { 209 return tmpDirName; 210 } 211 212 216 225 public synchronized BeanFactory addBean(BeanDesc dd) { 226 BeanFactory bf = null; 227 String beanName = dd.getEjbName(); 228 if (dd instanceof SessionStatefulDesc) { 229 if (TraceEjb.isDebugIc()) { 230 TraceEjb.interp.log(BasicLevel.DEBUG, "add SessionStatefulBean " + beanName); 231 } 232 bf = new JStatefulFactory((SessionStatefulDesc) dd, this); 233 } else if (dd instanceof SessionStatelessDesc) { 234 if (TraceEjb.isDebugIc()) { 235 TraceEjb.interp.log(BasicLevel.DEBUG, "add SessionStatelessBean " + beanName); 236 } 237 bf = new JStatelessFactory((SessionStatelessDesc) dd, this); 238 } else if (dd instanceof MessageDrivenDesc) { 239 if (TraceEjb.isDebugIc()) { 240 TraceEjb.interp.log(BasicLevel.DEBUG, "add MessageDrivenBean " + beanName); 241 } 242 Object obj = null; 243 InitialContext ictx = null; 244 String destJName = ((MessageDrivenDesc) dd).getDestinationJndiName(); 245 try { 246 ictx = naming.getInitialContext(); 247 obj = ictx.lookup(destJName); 248 } catch (NamingException ex) { 249 if (ex instanceof NameNotFoundException || ex.getCause() instanceof NameNotFoundException ) { 251 if (TraceEjb.isDebugIc()) { 252 TraceEjb.interp.log(BasicLevel.DEBUG, "Can not find destination JNDI name " + destJName, ex); 253 } 254 } else { 255 throw new EJBException (ex); 256 } 257 } 258 if (obj != null && obj instanceof ActivationSpec ) { 259 bf = new JMdbEndpointFactory((MessageDrivenDesc) dd, this, (ActivationSpec ) obj); 260 } else if (getJmsManager() == null) { 261 if (((MessageDrivenDesc) dd).getDestination() != null) { 264 if (TraceEjb.isDebugIc()) { 265 TraceEjb.interp.log(BasicLevel.DEBUG, "JMS service not started and specified ActivationSpec(" + destJName + ") not deployed"); 266 } 267 throw new EJBException ("JMS service not started and specified ActivationSpec(" + destJName + ") not deployed"); 268 } 269 270 String dest = Rar.getDefaultAS(); if (dest == null) { 273 dest = DEFAULT_ACTIVATION_SPEC_NAME; } 275 276 try { 277 obj = ictx.lookup(dest); 278 } catch (Exception ex) { 279 if (TraceEjb.isDebugIc()) { 280 TraceEjb.interp.log(BasicLevel.DEBUG, "JMS service not started and default ActivationSpec(" + dest + ") not deployed"); 281 } 282 throw new EJBException ("JMS service not started and default ActivationSpec(" + dest + ") not deployed", ex); 283 } 284 if (obj != null && obj instanceof ActivationSpec ) { 285 bf = new JMdbEndpointFactory((MessageDrivenDesc) dd, dest, this, (ActivationSpec ) obj); 286 } else { 287 if (TraceEjb.isDebugIc()) { 288 TraceEjb.interp.log(BasicLevel.DEBUG, "Invalid destination: No ActivationSpec deployed matching " + dest); 289 } 290 throw new EJBException ("Invalid destination: No ActivationSpec deployed matching " + dest); 291 } 292 } else { 293 if (((MessageDrivenDesc) dd).getDestination() != null) { 295 if (TraceEjb.isDebugIc()) { 296 TraceEjb.interp.log(BasicLevel.DEBUG, "JMS service started and specified ActivationSpec(" + destJName + ") not deployed"); 297 } 298 throw new EJBException ("JMS service started and specified ActivationSpec(" + destJName + ") not deployed"); 299 } 300 bf = new JMdbFactory((MessageDrivenDesc) dd, this); 301 } 302 } else if (dd instanceof EntityJdbcCmp2Desc) { 303 EntityJdbcCmp2Desc ecd = (EntityJdbcCmp2Desc) dd; 304 if (TraceEjb.isDebugIc()) { 306 TraceEjb.interp.log(BasicLevel.DEBUG, "add CMP2 EntityBean " + beanName); 307 } 308 String cn = null; 310 try { 311 String dsn = ecd.getDatasourceJndiName(); 312 326 InitialContext ictx = naming.getInitialContext(); 327 String mapperName = null; 328 try { 332 Object cls = ictx.lookup(dsn); 333 Method meth = cls.getClass().getMethod("getMapperName", (Class []) null); 334 mapperName = (String ) meth.invoke(cls, (Object []) null); 335 } catch (Exception e1) { 336 if (TraceEjb.isDebugIc()) { 337 TraceEjb.interp.log(BasicLevel.DEBUG, "Cannot read mapper name", e1); 338 } 339 } 340 if (mapperName == null || mapperName.trim().length() == 0) { 341 try { 344 JProp dsProps = JProp.getInstance("mapper"); 345 mapperName = dsProps.getValue(dsn, ""); 346 } catch (Exception e2) { 347 throw new EJBException ("Unable to retrieve mapperName for " + dsn, e2); 348 } 349 if (mapperName == null) { 350 throw new EJBException ("Unable to retrieve mapperName for " + dsn + ". mappername is null."); 351 } 352 } 353 354 cn = ecd.getFactoryClassName(); 355 bf = (JEntityFactory) loader.loadClass(cn).newInstance(); 356 ((RdbFactory) bf).init(ecd, this, mapperName); 357 setSwapTime(((EntityDesc) ecd).getPassivationTimeout()); 358 TraceEjb.interp.log(BasicLevel.INFO, beanName + " is loaded and using " + mapperName); 359 } catch (Exception e) { 360 TraceEjb.interp.log(BasicLevel.ERROR, "Impossible to instanciate the entity factory: " + cn, e); 361 throw new EJBException ("Impossible to instanciate the entity factory: " + cn, e); 362 } 363 } else if (dd instanceof EntityDesc) { 364 if (TraceEjb.isDebugIc()) { 365 TraceEjb.interp.log(BasicLevel.DEBUG, "add EntityBean " + beanName); 366 } 367 String cn = null; 369 try { 370 cn = DEFAULT_FACTORY_CLASS_NAME; 371 bf = (JEntityFactory) loader.loadClass(cn).newInstance(); 372 } catch (Exception e) { 373 throw new EJBException ("Impossible to instanciate the specified entity factory: " + cn, e); 374 } 375 ((JEntityFactory) bf).init((EntityDesc) dd, this); 376 setSwapTime(((EntityDesc) dd).getPassivationTimeout()); 377 } else { 378 throw new EJBException ("Bad Descriptor Type for " + beanName); 379 } 380 beanList.put(beanName, bf); 381 TraceEjb.interp.log(BasicLevel.INFO, beanName + " available"); 382 return bf; 383 } 384 385 395 private Set beansDependence(Enumeration beanFactories, String rName, boolean isResRef) { 396 HashSet result = new HashSet (); 397 BeanFactory bf = null; 398 while (beanFactories.hasMoreElements()) { 399 bf = (BeanFactory) beanFactories.nextElement(); 401 BeanDesc ejbDesc = bf.getDeploymentDescriptor(); 402 403 boolean isDependent = false; 405 String ejbType = null; 407 if (bf instanceof JEntityFactory) { 408 if (ejbDesc instanceof EntityBmpDesc) { 409 ejbType = "ejbbmp"; 410 } 411 if (ejbDesc instanceof EntityCmpDesc) { 412 ejbType = "ejbcmp"; 413 } 414 } else if (bf instanceof JStatefulFactory) { 415 ejbType = "ejbsbf"; 416 } else if (bf instanceof JStatelessFactory) { 417 ejbType = "ejbsbl"; 418 } else if (bf instanceof JMdbFactory || bf instanceof JMdbEndpointFactory) { 419 ejbType = "ejbmdb"; 420 } 421 422 if (isResRef) { 423 if (ejbType.equals("ejbcmp")) { 427 String jndiName = null; 428 if (ejbDesc instanceof EntityJdbcCmp1Desc) { 429 jndiName = ((EntityJdbcCmp1Desc) ejbDesc).getDatasourceJndiName(); 430 } else if (ejbDesc instanceof EntityJdbcCmp2Desc) { 431 jndiName = ((EntityJdbcCmp2Desc) ejbDesc).getDatasourceJndiName(); 432 } 433 isDependent = rName.equals(jndiName); 434 } 435 ResourceRefDesc[] rrDesc = ejbDesc.getResourceRefDesc(); 437 for (int i = 0; i < rrDesc.length; i++) { 438 if (rrDesc[i].getJndiName().equals(rName)) { 440 isDependent = true; 441 break; 442 } 443 } 444 } else { 445 if (ejbType.equals("ejbmdb")) { 446 if (rName.equals(((MessageDrivenDesc) ejbDesc).getDestinationJndiName())) { 447 isDependent = true; 448 } 449 } 450 ResourceEnvRefDesc[] rerDesc = ejbDesc.getResourceEnvRefDesc(); 452 for (int i = 0; i < rerDesc.length; i++) { 453 if (rerDesc[i].getJndiName().equals(rName)) { 455 isDependent = true; 456 break; 457 } 458 } 459 } 460 461 if (isDependent) { 462 Properties toAdd = new Properties (); 463 toAdd.setProperty("type", ejbType); 464 toAdd.setProperty("fname", getFileName()); 465 toAdd.setProperty("name", ejbDesc.getEjbName()); 466 toAdd.setProperty("cname", getName()); 467 String earFileName = getEarFileName(); 468 if (earFileName != null) { 469 toAdd.setProperty("earFileName", earFileName); 470 } 471 result.add(toAdd); 472 } 473 474 } 475 return result; 476 } 477 478 485 protected void checkSecurity(String ejbName, EJBInvocation ejbInv, boolean inRunAs) { 486 String oldContextId = PolicyContext.getContextID(); 487 488 boolean accessIsOk = false; 489 try { 490 if (permissionManager != null) { 492 accessIsOk = permissionManager.checkSecurity(ejbName, ejbInv, inRunAs); 493 } 494 } catch (Exception e) { 495 TraceEjb.security.log(BasicLevel.ERROR, "Error while checking security", e); 496 } finally { 497 PolicyContext.setContextID(oldContextId); 498 } 499 if (!accessIsOk) { 500 StringBuffer errMsg = new StringBuffer ("Access Denied on bean '"); 501 errMsg.append(ejbName); 502 errMsg.append("' with run-as = '"); 503 errMsg.append(inRunAs); 504 errMsg.append("'. "); 505 if (ejbInv != null && ejbInv.methodPermissionSignature != null) { 506 errMsg.append(" Method signature = '"); 507 errMsg.append(ejbInv.methodPermissionSignature); 508 errMsg.append("'."); 509 } 510 throw new AccessLocalException (errMsg.toString()); 511 } 512 513 } 514 515 520 public BeanFactory getBeanFactory(String ejbName) { 521 return (BeanFactory) beanList.get(ejbName); 522 } 523 524 527 public int getBeanNb() { 528 return beanList.size(); 529 } 530 531 534 public ClassLoader getClassLoader() { 535 if (loader == null) { 536 TraceEjb.logger.log(BasicLevel.ERROR, "container has been removed"); 537 return null; 539 } else { 540 return loader; 541 } 542 } 543 544 548 public ContainerNaming getContainerNaming() { 549 return naming; 550 } 551 552 558 public Set getDataSourceDependence(String dsName) { 559 return beansDependence(Collections.enumeration(beanList.values()), dsName, true); 561 } 562 563 567 public String getEarFileName() { 568 return earFileName; 569 } 570 571 574 public int getEntityBMPNb() { 575 BeanFactory bf; 576 int total = 0; 577 Iterator it = beanList.values().iterator(); 578 while (it.hasNext()) { 579 bf = (BeanFactory) it.next(); 580 if (bf.getDeploymentDescriptor() instanceof EntityBmpDesc) { 581 total++; 582 } 583 } 584 return total; 585 } 586 587 590 public int getEntityCMPNb() { 591 BeanFactory bf; 592 int total = 0; 593 Iterator it = beanList.values().iterator(); 594 while (it.hasNext()) { 595 bf = (BeanFactory) it.next(); 596 if (bf.getDeploymentDescriptor() instanceof EntityCmpDesc) { 597 total++; 598 } 599 } 600 return total; 601 } 602 603 606 public String getFileName() { 607 return fileName; 608 } 609 610 613 public String getExternalFileName() { 614 return externalFileName; 615 } 616 617 624 public Set getJmsConnectionFactoryDependence(String cfName) { 625 return beansDependence(Collections.enumeration(beanList.values()), cfName, true); 627 } 628 629 636 public Set getJmsDestinationDependence(String destName) { 637 return beansDependence(Collections.enumeration(beanList.values()), destName, false); 639 } 640 641 645 public JmsManager getJmsManager() { 646 return jms; 647 } 648 649 656 public Set getMailFactoryDependence(String mfName) { 657 return beansDependence(Collections.enumeration(beanList.values()), mfName, true); 659 } 660 661 664 public int getMessageDrivenNb() { 665 BeanFactory bf; 666 int total = 0; 667 Iterator it = beanList.values().iterator(); 668 while (it.hasNext()) { 669 bf = (BeanFactory) it.next(); 670 if (bf.getDeploymentDescriptor() instanceof MessageDrivenDesc) { 671 total++; 672 } 673 } 674 return total; 675 } 676 677 680 public String getName() { 681 return myname; 682 } 683 684 688 public PermissionManager getPermissionManager() { 689 return permissionManager; 690 } 691 692 695 public PrincipalFactory getPrincipalFactory() { 696 return principalFactory; 697 } 698 699 702 public int getStatefulSessionNb() { 703 BeanFactory bf; 704 int total = 0; 705 Iterator it = beanList.values().iterator(); 706 while (it.hasNext()) { 707 bf = (BeanFactory) it.next(); 708 if (bf.getDeploymentDescriptor() instanceof SessionStatefulDesc) { 709 total++; 710 } 711 } 712 return total; 713 } 714 715 718 public int getStatelessSessionNb() { 719 BeanFactory bf; 720 int total = 0; 721 Iterator it = beanList.values().iterator(); 722 while (it.hasNext()) { 723 bf = (BeanFactory) it.next(); 724 if (bf.getDeploymentDescriptor() instanceof SessionStatelessDesc) { 725 total++; 726 } 727 } 728 return total; 729 } 730 731 734 public int getSwapTime() { 735 return swapper.getSwapperTimeout(); 736 } 737 738 743 public TransactionManager getTransactionManager() { 744 return tm; 745 } 746 747 751 public boolean isInEarCase() { 752 return (earFileName != null); 753 } 754 755 759 762 public String [] listBeanNames() { 763 return (String []) beanList.keySet().toArray(new String [0]); 764 } 765 766 770 774 public void registerBF(BeanFactory bf) { 775 swapper.addBeanFactory(bf); 776 } 777 778 782 public void registerBFS(BeanFactory bf) { 783 swapper.addBeanFactorySync(bf); 784 } 785 786 789 public synchronized void remove() { 790 if (TraceEjb.isDebugIc()) { 791 TraceEjb.interp.log(BasicLevel.DEBUG, myname); 792 } 793 794 swapper.stopIt(); 796 797 syncAll(false); 800 801 Iterator it = beanList.values().iterator(); 803 while (it.hasNext()) { 804 BeanFactory bf = (BeanFactory) it.next(); 805 try { 806 bf.stop(); 807 TraceEjb.interp.log(BasicLevel.INFO, myname + ": " + bf.getEJBName() + " no longer available"); 808 } catch (Exception e) { 809 TraceEjb.logger.log(BasicLevel.ERROR, myname, e); 810 } 811 } 812 beanList.clear(); 813 814 loader = null; 816 817 try { 819 if (permissionManager != null) { 820 permissionManager.delete(); 821 } 822 } catch (PermissionManagerException pme) { 823 TraceEjb.logger.log(BasicLevel.ERROR, myname, pme); 824 } 825 permissionManager = null; 826 827 Runtime.getRuntime().gc(); 829 } 830 831 837 public void setBeanEnvironment(Context ctx, BeanDesc dd) throws NamingException { 838 839 Context ctxold = naming.setComponentContext(ctx); 842 Context envCtx = ctx.createSubcontext("comp/env"); 843 844 EnvEntryDesc[] envt = dd.getEnvEntryDesc(); 846 for (int i = 0; i < envt.length; i++) { 847 String name = envt[i].getName(); 849 Object obj = envt[i].getValue(); 850 if (TraceEjb.isDebugIc()) { 852 TraceEjb.interp.log(BasicLevel.DEBUG, myname + ": Binding object " + name + " -> " + obj); 853 } 854 envCtx.rebind(name, obj); 855 } 856 857 ResourceRefDesc[] resref = dd.getResourceRefDesc(); 859 for (int i = 0; i < resref.length; i++) { 860 String name = resref[i].getName(); 862 String resname = resref[i].getJndiName(); 863 String type = resref[i].getTypeName(); 864 867 if (TraceEjb.isDebugIc()) { 869 TraceEjb.interp.log(BasicLevel.DEBUG, myname + ": Linking resource " + name + " -> " + resname); 870 } 871 872 if (type.equalsIgnoreCase("java.net.URL")) { 873 Reference ref = new Reference ("java.net.URL", "org.objectweb.jonas_lib.naming.factory.URLFactory", null); 875 StringRefAddr refAddr = new StringRefAddr ("url", resname); 876 ref.add(refAddr); 877 envCtx.rebind(name, ref); 878 } else { 879 LinkRef lref = new LinkRef (resname); 880 envCtx.rebind(name, lref); 881 } 882 } 883 884 ResourceEnvRefDesc[] resEnvref = dd.getResourceEnvRefDesc(); 886 for (int i = 0; i < resEnvref.length; i++) { 887 String name = resEnvref[i].getName(); 889 String resname = resEnvref[i].getJndiName(); 890 LinkRef lref = new LinkRef (resname); 891 892 if (TraceEjb.isDebugIc()) { 893 TraceEjb.interp.log(BasicLevel.DEBUG, myname + ": Linking resource environment " + name + " -> " 894 + resname); 895 } 896 envCtx.rebind(name, lref); 897 } 898 899 EjbRefDesc[] ejbref = dd.getEjbRefDesc(); 901 for (int i = 0; i < ejbref.length; i++) { 902 String name = ejbref[i].getEjbRefName(); 904 String ejbname = null; 905 ejbname = ejbref[i].getJndiName(); 906 LinkRef lref = new LinkRef (ejbname); 907 908 if (TraceEjb.isDebugIc()) { 909 TraceEjb.interp.log(BasicLevel.DEBUG, myname + ": Linking ejb " + name + " -> " + ejbname); 910 } 911 envCtx.rebind(name, lref); 912 } 913 914 EjbLocalRefDesc[] ejblocalref = dd.getEjbLocalRefDesc(); 918 for (int i = 0; i < ejblocalref.length; i++) { 919 String name = ejblocalref[i].getEjbRefName(); 920 String ejbname = ejblocalref[i].getJndiLocalName(); 921 LinkRef lref = new LinkRef (ejbname); 922 if (TraceEjb.isDebugIc()) { 923 TraceEjb.interp.log(BasicLevel.DEBUG, myname + ": Linking ejb " + name + " -> " + ejbname); 924 } 925 envCtx.rebind(name, lref); 926 } 927 928 ServiceRefDesc[] serviceRefs = dd.getServiceRefDesc(); 930 if (serviceRefs.length != 0) { 931 932 JServiceFactory factory = null; 934 935 for (int i = 0; i < serviceRefs.length; i++) { 936 937 if (factory == null) { 938 factory = JServiceFactoryFinder.getJOnASServiceFactory(); 939 } 940 String refname = serviceRefs[i].getServiceRefName(); 942 943 Reference ref; 945 try { 946 ref = factory.getServiceReference(serviceRefs[i], loader); 947 } catch (Exception e1) { 948 throw NamingExceptionHelper.create("Cannot get service reference", e1); 949 } 950 envCtx.rebind(refname, ref); 951 if (TraceEjb.isDebugIc()) { 952 TraceEjb.interp.log(BasicLevel.DEBUG, "Adding service-ref 'java:comp/env/" + refname + "'"); 953 } 954 } 955 } 956 957 MessageDestinationRefDesc[] mdref = dd.getMessageDestinationRefDesc(); 959 for (int i = 0; i < mdref.length; i++) { 960 String name = mdref[i].getMessageDestinationRefName(); 962 String mdname = null; 963 mdname = mdref[i].getJndiName(); 964 LinkRef lref = new LinkRef (mdname); 965 966 if (TraceEjb.isDebugIc()) { 967 TraceEjb.interp.log(BasicLevel.DEBUG, myname + ": Linking message-destination " + name + " -> " + mdname); 968 } 969 envCtx.rebind(name, lref); 970 } 971 972 naming.setComponentContext(ctxold); 974 } 975 976 981 public void setContainerNaming(ContainerNaming naming) { 982 this.naming = naming; 983 } 984 985 990 public void setEarFileName(String fileName) { 991 earFileName = fileName; 992 } 993 994 999 public void setJmsManager(JmsManager jms) { 1000 this.jms = jms; 1001 } 1002 1003 1004 1008 public void setPermissionManager(PermissionManager permissionManager) { 1009 this.permissionManager = permissionManager; 1010 } 1011 1012 1017 public void setPrincipalFactory(PrincipalFactory pf) { 1018 principalFactory = pf; 1019 } 1020 1021 1025 public void setSecurity(boolean b) { 1026 securityFlag = b; 1027 } 1028 1029 1033 public void setSwapTime(int t) { 1034 if (t > 0) { 1035 if (TraceEjb.isDebugSwapper()) { 1036 TraceEjb.swapper.log(BasicLevel.DEBUG, myname + " sec=" + t); 1037 } 1038 swapper.setSwapperTimeout(t); 1039 } 1040 } 1041 1042 1047 public void setWorkManager(WorkManager wm) { 1048 workManager = wm; 1049 } 1050 1051 1054 public WorkManager getWorkManager() { 1055 return workManager; 1056 } 1057 1058 1063 public void setTransactionManager(TransactionManager tm) { 1064 this.tm = tm; 1065 } 1066 1067 1072 public synchronized void syncAll(boolean passivate) { 1073 if (TraceEjb.isDebugIc()) { 1074 TraceEjb.interp.log(BasicLevel.DEBUG, myname); 1075 } 1076 BeanFactory bf = null; 1077 Iterator it = beanList.values().iterator(); 1078 while (it.hasNext()) { 1079 bf = (BeanFactory) it.next(); 1080 if (passivate) { 1081 bf.reduceCache(); 1082 } else { 1083 bf.sync(); 1084 } 1085 } 1086 } 1087 1088 1092 public String getContextId() { 1093 return externalFileName; 1094 } 1095} 1096 | Popular Tags |