1 23 24 package com.sun.enterprise.web; 25 26 import java.io.File ; 27 28 import org.apache.catalina.util.StringManager; 29 30 import com.sun.enterprise.deployment.Application; 31 import com.sun.enterprise.deployment.WebBundleDescriptor; 32 import com.sun.enterprise.config.serverbeans.WebModule; 33 import com.sun.enterprise.config.ConfigException; 34 import com.sun.enterprise.util.io.FileUtils; 35 36 40 public class WebModuleConfig { 41 42 44 48 private WebModule _wmBean = null; 49 50 54 private String _baseDir = null; 55 56 59 private ClassLoader _parentLoader = null; 60 61 64 private WebBundleDescriptor _wbd = null; 65 66 69 private String _vsIDs; 70 71 private String stubBaseDir; 73 75 76 79 private static StringManager _sm = 80 StringManager.getManager(Constants.Package); 81 82 84 88 public void setBean(WebModule wmBean) { 89 _wmBean = wmBean; 90 } 91 92 93 96 public WebModule getBean() { 97 return _wmBean; 98 } 99 100 105 public String getName() { 106 String name = null; 107 if (_wmBean != null) { 108 StringBuffer buffer = new StringBuffer (); 109 String appName = getAppName(); 110 if (appName != null) { 111 buffer.append(appName); 114 buffer.append(Constants.NAME_SEPARATOR); 115 } 116 buffer.append(getModuleName()); 117 name = buffer.toString(); 118 } 119 return name; 120 } 121 122 125 public String getContextPath() { 126 String ctxPath = null; 127 if (_wmBean != null) { 128 ctxPath = _wmBean.getContextRoot().trim(); 129 if ((ctxPath.length() > 0) && !ctxPath.startsWith("/")) { 132 ctxPath = "/" + ctxPath; 133 } else if (ctxPath.equals("/")) { 134 ctxPath = ""; 135 } 136 } 137 return ctxPath; 138 } 139 140 143 public String getLocation() { 144 String dir = null; 145 if (_wmBean != null) { 146 dir = _wmBean.getLocation(); 147 } 148 return dir; 149 } 150 151 155 public String getVirtualServers() { 156 161 return _vsIDs; 162 } 163 164 168 public void setVirtualServers(String virtualServers) { 169 _vsIDs = virtualServers; 170 } 171 172 175 public void setParentLoader(ClassLoader parentLoader) { 176 _parentLoader = parentLoader; 177 } 178 179 182 public ClassLoader getParentLoader() { 183 return _parentLoader; 184 } 185 186 194 public String getWorkDir() { 195 return getWebDir(_baseDir); 196 } 197 198 199 205 public String getStubPath() { 206 return getWebDir(stubBaseDir); 207 } 208 210 211 220 public void setWorkDirBase(String baseDir) { 221 _baseDir = baseDir; 222 } 223 224 225 231 public void setStubBaseDir(String stubBaseDir) { 232 this.stubBaseDir = stubBaseDir; 233 } 234 236 237 241 public WebBundleDescriptor getDescriptor() { 242 return _wbd; 243 } 244 245 246 252 public void setDescriptor(WebBundleDescriptor wbd) { 253 _wbd = wbd; 254 } 255 256 258 262 private String getAppName() { 263 String name = null; 264 if (_wbd != null) { 265 Application app = _wbd.getApplication(); 266 if ((app != null) && !app.isVirtual()) { 267 String appName = app.getRegistrationName(); 268 if ((appName != null) && (appName.length() > 0)) { 269 name = appName.trim(); 270 } 271 } 272 } 273 return name; 274 } 275 276 279 private String getModuleName() { 280 String name = null; 281 if (_wmBean != null) { 282 name = _wmBean.getName(); 283 } 284 return name; 285 } 286 287 288 294 private String getWebDir(String baseDir) { 295 296 String workDir = null; 297 298 if (baseDir != null) { 299 StringBuffer dir = new StringBuffer (); 300 dir.append(baseDir); 301 302 String appName = getAppName(); 305 if (appName != null) { 306 dir.append(File.separator); 307 dir.append(FileUtils.makeFriendlyFilename(appName)); 308 } 309 310 String name = getModuleName(); 312 if (name != null) { 313 dir.append(File.separator); 314 dir.append(FileUtils.makeFriendlyFilename(name)); 315 } 316 workDir = dir.toString(); 317 } 318 319 return workDir; 320 } 321 } 322 | Popular Tags |