1 23 package com.sun.ejb.containers; 24 25 26 import java.util.logging.*; 27 import java.util.Vector ; 28 import java.util.Iterator ; 29 30 import javax.naming.NamingException ; 31 import javax.naming.Context ; 32 import javax.naming.InitialContext ; 33 34 import com.sun.ejb.Container; 35 import com.sun.ejb.InvocationInfo; 36 import com.sun.enterprise.deployment.*; 37 38 import com.sun.enterprise.config.serverbeans.ServerBeansFactory; 39 import com.sun.enterprise.server.ApplicationServer; 40 import com.sun.enterprise.server.ServerContext; 41 import com.sun.enterprise.config.serverbeans.EjbContainer; 42 import com.sun.enterprise.config.serverbeans.EjbTimerService; 43 44 45 public class TimerBeanContainer 46 extends EntityContainer 47 { 48 49 private EJBTimerService ejbTimerService; 50 51 56 protected TimerBeanContainer(EjbDescriptor desc, ClassLoader loader) 57 throws Exception 58 { 59 super(desc, loader); 60 61 _logger.log(Level.FINE,"[TimerBeanContainer] Created " 62 + " TimerBeanContainer: " + logParams[0]); 63 64 } 65 66 public void onShutdown() { 67 _logger.log(Level.FINE,"[TimerBeanContainer] onShutdown() called...."); 68 69 super.onShutdown(); 70 71 if (ejbTimerService != null) { 72 ejbTimerService.onShutdown(); 73 } 74 } 75 76 80 public void doAfterApplicationDeploy() { 81 82 super.doAfterApplicationDeploy(); 83 84 try { 85 86 TimerLocalHome timerLocalHome = (TimerLocalHome) ejbLocalHome; 87 88 EjbBundleDescriptor bundle = 90 ejbDescriptor.getEjbBundleDescriptor(); 91 92 ResourceReferenceDescriptor cmpResource = 95 bundle.getCMPResourceReference(); 96 97 String cmpResourceJndiName = cmpResource.getJndiName(); 98 99 ServerContext sc = ApplicationServer.getServerContext(); 101 EjbContainer ejbc = ServerBeansFactory. 102 getConfigBean(sc.getConfigContext()).getEjbContainer(); 103 EjbTimerService ejbt = ejbc.getEjbTimerService(); 104 String ejbtDatasource = (ejbt != null) ? 106 ejbt.getTimerDatasource() : null; 107 108 if( (ejbtDatasource != null) && 111 (!ejbtDatasource.equals(cmpResourceJndiName)) ) { 112 113 cmpResourceJndiName = ejbtDatasource; 114 115 cmpResource.setJndiName(cmpResourceJndiName); 117 } 118 119 Context context = new InitialContext (); 121 context.lookup(cmpResourceJndiName); 122 123 boolean checkStatus = 128 timerLocalHome.checkStatus(cmpResourceJndiName, false); 129 130 if( checkStatus ) { 131 132 Application application = ejbDescriptor.getApplication(); 134 135 String appID = application.getRegistrationName(); 137 138 Vector ejbs = application.getEjbDescriptors(); 139 TimerMigrationLocalHome timerMigrationLocalHome = null; 140 for(Iterator iter = ejbs.iterator(); iter.hasNext();) { 141 EjbDescriptor next = (EjbDescriptor) iter.next(); 142 if( next.getLocalHomeClassName().equals 143 (TimerMigrationLocalHome.class.getName()) ) { 144 BaseContainer container = (BaseContainer) 145 containerFactory.getContainer(next.getUniqueId()); 146 timerMigrationLocalHome = (TimerMigrationLocalHome) 147 container.getEJBLocalHome(); 148 break; 149 } 150 } 151 152 ejbTimerService = 154 new EJBTimerService(appID, timerLocalHome, 155 timerMigrationLocalHome); 156 157 containerFactory.setEJBTimerService(ejbTimerService); 158 159 _logger.log(Level.INFO, "ejb.timer_service_started", 160 new Object [] { cmpResourceJndiName } ); 161 162 } else { 163 } 165 166 } catch (NamingException nnfe) { 167 168 _logger.log(Level.WARNING, "ejb.timer_service_init_error", 171 logParams); 172 173 } catch (Exception ex) { 174 _logger.log(Level.WARNING, "ejb.timer_service_init_error", 175 logParams); 176 _logger.log(Level.WARNING, "", ex); 177 } 178 179 } 180 181 } | Popular Tags |