1 23 24 package com.sun.enterprise.server; 25 26 import com.sun.logging.LogDomains; 27 import com.sun.enterprise.config.ConfigException; 28 import com.sun.enterprise.config.serverbeans.J2eeApplication; 29 import com.sun.enterprise.deployment.Application; 30 import com.sun.enterprise.deployment.WebBundleDescriptor; 31 import com.sun.enterprise.instance.AppsManager; 32 import com.sun.enterprise.util.StringUtils; 33 import com.sun.enterprise.web.PEWebContainer; 34 import com.sun.enterprise.Switch; 35 36 import java.util.Iterator ; 37 import java.util.List ; 38 import java.util.Set ; 39 import java.util.logging.Logger ; 40 import java.util.logging.Level ; 41 42 import org.apache.catalina.Container; 43 import org.apache.catalina.Context; 44 import org.apache.catalina.Deployer; 45 import org.apache.catalina.Engine; 46 import org.apache.catalina.Host; 47 import org.apache.catalina.core.StandardHost; 48 49 55 public class TomcatApplicationLoader extends ApplicationLoader { 56 57 58 59 static Logger _logger = LogDomains.getLogger(LogDomains.LOADER_LOGGER); 60 61 62 64 65 72 public TomcatApplicationLoader(String appID, ClassLoader parentClassLoader, 73 AppsManager appsManager) { 74 75 super(appID, parentClassLoader, appsManager); 76 _logger.log(Level.FINEST, "[TomcatApplicationLoader] " + appID); 77 this.appsManager = appsManager; 78 webContainer = PEWebContainer.getPEWebContainer(); 80 _logger.log(Level.FINEST, "PEWebContainer " + webContainer); 81 82 } 83 84 85 87 88 93 private AppsManager appsManager = null; 94 95 96 99 private PEWebContainer webContainer = null; 100 101 102 103 110 boolean load(boolean jsr77) { 111 112 _logger.log(Level.FINEST, "[TomcatApplicationLoader] load " + jsr77); 113 boolean deployed = super.load(jsr77); 114 if (loadUnloadAction == Constants.LOAD_RAR) { 115 return deployed; 116 } 117 _logger.log(Level.FINEST, "deployed "+deployed); 118 if (webContainer == null) { 119 webContainer = PEWebContainer.getPEWebContainer(); 120 } 121 if (deployed) { 122 J2eeApplication[] j2eeAppBeans = appsManager.getAllApps(); 123 if (j2eeAppBeans != null) { 124 for (int i = 0; i < j2eeAppBeans.length; i++) { 125 if (j2eeAppBeans[i].getName().equals(id) && webContainer != null) { 126 _logger.log(Level.FINEST, 127 "[TomcatApplicationLoader] loadJ2EEAppWebModule with "+j2eeAppBeans[i]); 128 webContainer.loadJ2EEApplicationWebModules(j2eeAppBeans[i]); 129 130 } 131 } 132 } 133 } 134 return deployed; 135 136 } 137 138 139 144 boolean unload(boolean jsr77) { 145 146 if (loadUnloadAction == Constants.UNLOAD_RAR) { 147 return super.unload(jsr77); 148 } 149 150 super.unloadWebserviceEndpoints(jsr77); 151 152 Set wbds = null; 153 J2eeApplication[] j2eeAppBeans = appsManager.getAllApps(); 154 if (j2eeAppBeans != null) { 155 for (int i = 0; i < j2eeAppBeans.length; i++) { 156 if (j2eeAppBeans[i].getName().equals(id)) { 157 158 String virtualServers = null; 159 try { 160 virtualServers = appsManager. 161 getVirtualServersByAppName(j2eeAppBeans[i].getName()); 162 } catch(ConfigException ce) { 163 _logger.log(Level.FINEST, "[TomcatApplicationLoader] unload " 164 + id + ". error getting virtualServers", ce); 165 } 166 167 _logger.log(Level.FINEST, "[TomcatApplicationLoader] unload " 168 +id); 169 wbds = application.getWebBundleDescriptors(); 170 WebBundleDescriptor wbd = null; 171 if ( wbds == null) continue; 172 173 Iterator itr = wbds.iterator(); 174 175 while (itr.hasNext()){ 176 wbd = (WebBundleDescriptor) itr.next(); 177 String appName = wbd.getApplication().getRegistrationName(); 178 try { 179 webContainer.unloadWebModule(wbd.getContextRoot(), 180 appName, 181 virtualServers, 182 wbd); 183 184 } finally { 185 try { 186 Switch.getSwitch(). 187 getNamingManager().unbindObjects(wbd); 188 } catch (javax.naming.NamingException nameEx) { 189 _logger.log(Level.FINEST, "[TomcatApplicationLoader] " 190 + " Exception during namingManager.unbindObject", 191 nameEx); 192 } 193 } 194 } 195 196 } 197 } 198 } 199 200 return super.unload(jsr77); 201 } 202 } 203 | Popular Tags |