1 22 package org.jboss.web.deployers; 23 24 import org.jboss.deployers.spi.deployer.DeploymentUnit; 25 import org.jboss.deployment.DeploymentException; 26 import org.jboss.logging.Logger; 27 import org.jboss.metadata.WebMetaData; 28 import org.jboss.web.WebApplication; 29 30 44 public class WebModule 45 implements WebModuleMBean 46 { 47 private static Logger log = Logger.getLogger(WebModule.class); 48 private DeploymentUnit di; 49 private AbstractWarDeployer container; 50 private AbstractWarDeployment deployment; 51 52 public WebModule(DeploymentUnit di, AbstractWarDeployer container, 53 AbstractWarDeployment deployment) 54 { 55 this.di = di; 56 this.container = container; 57 this.deployment = deployment; 58 } 59 60 public void create() 61 { 62 63 } 64 public void start() throws Exception 65 { 66 startModule(); 67 } 68 69 public void stop() throws Exception 70 { 71 stopModule(); 72 } 73 74 public void destroy() 75 { 76 this.di = null; 77 this.container = null; 78 this.deployment = null; 79 } 80 81 83 public synchronized void startModule() 84 throws Exception 85 { 86 WebMetaData metaData = di.getAttachment(WebMetaData.class); 88 WebApplication webApp = deployment.start(di, metaData); 89 String warURL = di.getName(); 90 container.addDeployedApp(warURL, webApp); 91 } 92 93 95 public synchronized void stopModule() 96 throws DeploymentException 97 { 98 String warURL = di.getName(); 99 try 100 { 101 WebApplication webApp = container.removeDeployedApp(warURL); 102 if( deployment != null && webApp != null ) 103 { 104 deployment.stop(di, webApp); 105 } 106 else 107 { 108 log.debug("Failed to find deployer/deployment for war: "+warURL); 109 } 110 } 111 catch (Exception e) 112 { 113 throw new DeploymentException("Error during stop", e); 114 } 115 } 116 117 } 118 | Popular Tags |