1 28 29 package com.caucho.server.webapp; 30 31 import com.caucho.log.Log; 32 import com.caucho.server.deploy.DeployContainer; 33 import com.caucho.server.deploy.DeployGenerator; 34 import com.caucho.server.e_app.EarDeployController; 35 import com.caucho.server.e_app.EarDeployGenerator; 36 37 import java.util.logging.Logger ; 38 39 42 public class WebAppEarDeployGenerator extends DeployGenerator<WebAppController> { 43 private static final Logger log = Log.open(WebAppEarDeployGenerator.class); 44 45 private WebAppContainer _container; 46 47 private String _urlPrefix = ""; 48 49 private ClassLoader _parentLoader; 50 51 private DeployContainer<EarDeployController> _earContainer; 52 53 private EarDeployGenerator _earDeploy; 54 55 58 public WebAppEarDeployGenerator(DeployContainer<WebAppController> deployContainer, 59 WebAppContainer container, 60 EarDeployGenerator earDeploy) 61 throws Exception 62 { 63 super(deployContainer); 64 65 setContainer(container); 66 67 _earDeploy = earDeploy; 68 _earContainer = earDeploy.getDeployContainer(); 69 } 70 71 74 public WebAppContainer getContainer() 75 { 76 return _container; 77 } 78 79 82 public void setContainer(WebAppContainer container) 83 { 84 _container = container; 85 86 if (_parentLoader == null) 87 _parentLoader = container.getClassLoader(); 88 } 89 90 93 public void setParentClassLoader(ClassLoader loader) 94 { 95 _parentLoader = loader; 96 } 97 98 101 public void setURLPrefix(String prefix) 102 { 103 while (prefix.endsWith("/")) { 104 prefix = prefix.substring(0, prefix.length() - 1); 105 } 106 107 _urlPrefix = prefix; 108 } 109 110 113 public String getURLPrefix() 114 { 115 return _urlPrefix; 116 } 117 118 121 protected Logger getLog() 122 { 123 return log; 124 } 125 126 129 @Override 130 protected void startImpl() 131 { 132 super.startImpl(); 133 134 _earContainer.start(); 135 } 136 137 140 public boolean isModified() 141 { 142 return _earContainer.isModified(); 143 } 144 145 148 public void update() 149 { 150 _earContainer.update(); 151 } 152 153 156 public WebAppController generateController(String name) 157 { 158 for (EarDeployController earController : _earContainer.getControllers()) { 159 WebAppController webAppController; 160 161 webAppController = earController.findWebAppController(name); 162 163 if (webAppController != null) 164 return webAppController; 165 } 166 167 return null; 168 } 169 170 173 @Override 174 protected void stopImpl() 175 { 176 _earContainer.stop(); 177 178 super.stopImpl(); 179 } 180 181 184 @Override 185 protected void destroyImpl() 186 { 187 _earContainer.destroy(); 188 189 super.destroyImpl(); 190 } 191 192 public String toString() 193 { 194 return "WebAppEarDeployGenerator[" + _earDeploy + "]"; 195 } 196 } 197 | Popular Tags |