1 22 package org.jboss.web; 23 24 import java.net.URL ; 25 26 import org.jboss.deployment.DeploymentInfo; 27 import org.jboss.deployment.DeploymentException; 28 import org.jboss.system.ServiceMBeanSupport; 29 30 44 public class WebModule extends ServiceMBeanSupport 45 implements WebModuleMBean 46 { 47 private DeploymentInfo di; 48 private AbstractWebContainer container; 49 private AbstractWebDeployer deployer; 50 51 public WebModule(DeploymentInfo di, AbstractWebContainer container, 52 AbstractWebDeployer deployer) 53 { 54 this.di = di; 55 this.container = container; 56 this.deployer = deployer; 57 } 58 59 protected void startService() throws Exception 60 { 61 startModule(); 62 } 63 64 protected void stopService() throws Exception 65 { 66 stopModule(); 67 } 68 69 protected void destroyService() 70 { 71 this.di = null; 72 this.container = null; 73 this.deployer = null; 74 } 75 76 78 public synchronized void startModule() 79 throws DeploymentException 80 { 81 URL warURL = di.localUrl != null ? di.localUrl : di.url; 83 WebApplication webApp = deployer.start(di); 84 di.context.put(AbstractWebContainer.WEB_APP, webApp); 85 container.addDeployedApp(warURL, webApp); 86 } 87 88 90 public synchronized void stopModule() 91 throws DeploymentException 92 { 93 URL warURL = di.localUrl != null ? di.localUrl : di.url; 94 String warUrl = warURL.toString(); 95 try 96 { 97 WebApplication webApp = container.removeDeployedApp(warURL); 98 if( deployer != null && webApp != null ) 99 { 100 deployer.stop(di); 101 } 102 else 103 { 104 log.debug("Failed to find deployer/deployment for war: "+warUrl); 105 } 106 } 107 catch (DeploymentException e) 108 { 109 throw e; 110 } 111 catch (Exception e) 112 { 113 throw new DeploymentException("Error during stop", e); 114 } 115 } 116 117 } 118 | Popular Tags |