1 23 24 package com.sun.enterprise.server; 25 26 import com.sun.enterprise.admin.event.AdminEventListenerException; 27 import com.sun.enterprise.admin.event.AdminEventListenerRegistry; 28 import com.sun.enterprise.admin.event.BaseDeployEvent; 29 import com.sun.enterprise.admin.event.DeployEventListenerHelper; 30 import com.sun.enterprise.admin.event.ModuleDeployEvent; 31 import com.sun.enterprise.admin.event.ModuleDeployEventListener; 32 import com.sun.enterprise.appclient.jws.AppclientJWSSupportManager; 33 import com.sun.enterprise.config.ConfigException; 34 import com.sun.enterprise.deployment.backend.DeployableObjectType; 35 import com.sun.enterprise.deployment.node.J2EEDocumentBuilder; 36 import com.sun.enterprise.instance.AppclientModulesManager; 37 import com.sun.enterprise.management.StateManageable; 38 import com.sun.enterprise.util.i18n.StringManager; 39 import com.sun.logging.LogDomains; 40 import java.util.Hashtable ; 41 import java.util.logging.Level ; 42 import java.util.logging.Logger ; 43 import javax.management.MBeanException ; 44 45 46 52 53 class StandAloneAppClientModulesManager extends AbstractManager 54 implements ModuleDeployEventListener { 55 56 static Logger _logger = LogDomains.getLogger(LogDomains.CORE_LOGGER); 57 private static StringManager localStrings = StringManager.getManager( 58 "com.sun.enterprise.server"); 59 60 63 StandAloneAppClientModulesManager( 64 AppclientModulesManager acModuleManager, ClassLoader sharedCL) { 65 66 super(sharedCL, acModuleManager); 67 68 AdminEventListenerRegistry.addModuleDeployEventListener(this); 69 70 71 AppclientJWSSupportManager.getInstance(); 72 73 } 74 75 78 public synchronized void moduleDeployed(ModuleDeployEvent event) 79 throws AdminEventListenerException { 80 81 82 boolean jsr77 = false; 83 84 if (_logger.isLoggable(Level.FINEST)) { 85 _logger.log(Level.FINEST, 86 "In StandAloneAppClientModulesManager moduleDeployed"); 87 _logger.log(Level.FINEST, "ModuleType=" + event.getModuleType()); 88 } 89 90 if (event.getModuleType().equals(event.TYPE_APPCLIENT)) { 91 92 DeployEventListenerHelper.getDeployEventListenerHelper().synchronize(event); 93 94 String modID = event.getModuleName(); 95 96 if (_logger.isLoggable(Level.FINEST)) { 97 _logger.log(Level.FINEST, "modID=" + modID); 98 } 99 100 try { 101 this.configManager.refreshConfigContext(event.getConfigContext()); 103 104 String action = event.getAction(); 108 if ((action.equals(BaseDeployEvent.DEPLOY)) || 109 (action.equals(BaseDeployEvent.REDEPLOY))) { 110 jsr77 = true; 111 } 112 113 if (!moduleDeployed(jsr77, modID)) { 114 115 String msg = localStrings.getString("appClientModule deploy failed", 117 modID); 118 throw new AdminEventListenerException(msg); 119 } 120 } catch (ConfigException ce) { 121 throw new AdminEventListenerException(ce.getMessage()); 122 } 123 } 124 } 125 126 127 130 131 public synchronized void moduleUndeployed(ModuleDeployEvent event) 132 throws AdminEventListenerException { 133 134 boolean jsr77 = false; 135 136 if (_logger.isLoggable(Level.FINEST)) { 137 _logger.log(Level.FINEST, 138 "In StandAloneAppClientModulesManager moduleUndeployed"); 139 } 140 141 String action = event.getAction(); 142 143 if ((action.equals(BaseDeployEvent.UNDEPLOY)) || 144 (action.equals(BaseDeployEvent.REDEPLOY))) { 145 jsr77 = true; 146 } 147 148 try { 149 if (event.getModuleType().equals(event.TYPE_APPCLIENT)) { 150 String modID = event.getModuleName(); 151 152 if (_logger.isLoggable(Level.FINEST)) { 153 _logger.log(Level.FINEST, "UnDeploying module: " + modID); 154 } 155 156 if (!moduleUndeployed(jsr77, modID)) { 158 String msg = localStrings.getString("appclient.appclient_undeployed_failed", 159 modID); 160 throw new AdminEventListenerException(msg); 161 } 162 163 } 164 } catch (Exception e) { 165 throw new AdminEventListenerException(e.getMessage()); 166 } 167 168 } 169 170 171 174 175 public synchronized void moduleRedeployed(ModuleDeployEvent event) 176 throws AdminEventListenerException { 177 178 if (_logger.isLoggable(Level.FINEST)) { 179 _logger.log(Level.FINEST, 180 "In StandAloneAppClientModulesManager moduleRedeployed"); 181 } 182 183 if (event.getModuleType().equals(event.TYPE_APPCLIENT)) { 184 185 String modID = event.getModuleName(); 186 187 if (_logger.isLoggable(Level.FINEST)) { 188 _logger.log(Level.FINEST, "ReDeploying module: " + modID); 189 } 190 191 moduleUndeployed(event); 192 moduleDeployed(event); 193 } 194 } 195 196 199 public synchronized void moduleEnabled(ModuleDeployEvent event) 200 throws AdminEventListenerException { 201 202 if (_logger.isLoggable(Level.FINEST)) { 203 _logger.log(Level.FINEST, 204 "In StandAloneAppClientModulesManager moduleEnabled"); 205 } 206 207 210 return; 211 } 212 213 214 217 218 public synchronized void moduleDisabled(ModuleDeployEvent event) 219 throws AdminEventListenerException { 220 221 if (_logger.isLoggable(Level.FINEST)) { 222 _logger.log(Level.FINEST, 223 "In StandAloneAppClientModulesManager moduleDisabled"); 224 } 225 226 229 return; 230 } 231 232 233 236 237 private boolean moduleDeployed(boolean jsr77, String modID) { 238 239 boolean result = false; 240 boolean loadJSR77 = jsr77 || loadJSR77(modID, DeployableObjectType.CAR); 241 try { 242 AbstractLoader modLoader = getLoader(modID); 243 244 if (loadJSR77) { 246 try { 247 modLoader.createRootMBean(); 248 } catch (MBeanException mbe) { 249 _logger.log(Level.WARNING, 250 "core.error_while_creating_jsr77_root_mbean",mbe); 251 } 252 } 253 254 result = modLoader.load(loadJSR77); 255 if (result) { 256 this.id2loader.put(modID, modLoader); 257 } 258 } catch (Exception ce) { 259 _logger.log(Level.WARNING, 260 "core.error_while_loading_application_client_module",ce); 261 result = false; 262 } 263 264 return result; 265 } 266 267 268 271 272 private boolean moduleUndeployed(boolean jsr77, String modID) { 273 274 boolean result = false; 275 try { 276 ApplicationClientModuleLoader modLoader = 277 (ApplicationClientModuleLoader) this.id2loader.remove(modID); 278 279 if (modLoader == null) { 280 return true; 281 } 282 283 if (jsr77) { 285 try { 286 modLoader.deleteRootMBean(); 287 } catch (MBeanException mbe) { 288 _logger.log(Level.WARNING, 289 "core.error_while_deleting_jsr77_root_mbean",mbe); 290 } 291 } 292 293 result = modLoader.unload(jsr77); 294 295 } catch (Exception ce) { 296 _logger.log(Level.WARNING, 297 "core.error_while_unloading_application_client_module",ce); 298 result = false; 299 } 300 301 return result; 302 } 303 304 307 308 protected AbstractLoader getLoader(String moduleId) { 309 return new ApplicationClientModuleLoader( 310 moduleId, 311 this.parentClassLoader, 312 (AppclientModulesManager) this.configManager); 313 } 314 315 316 323 public void moduleReferenceAdded(ModuleDeployEvent event) 324 throws AdminEventListenerException { 325 326 } 327 328 335 public void moduleReferenceRemoved(ModuleDeployEvent event) 336 throws AdminEventListenerException { 337 338 } 339 340 } 341 | Popular Tags |