1 29 30 package com.caucho.server.webapp; 31 32 import com.caucho.config.ConfigException; 33 import com.caucho.config.types.RawString; 34 import com.caucho.log.Log; 35 import com.caucho.server.deploy.DeployConfig; 36 import com.caucho.server.util.CauchoSystem; 37 import com.caucho.util.L10N; 38 39 import java.util.logging.Logger ; 40 import java.util.regex.Pattern ; 41 42 45 public class WebAppConfig extends DeployConfig { 46 static final L10N L = new L10N(WebAppConfig.class); 47 static final Logger log = Log.open(WebAppConfig.class); 48 49 private Pattern _urlRegexp; 51 52 private String _contextPath; 54 55 private WebAppConfig _prologue; 56 57 public WebAppConfig() 58 { 59 } 60 61 64 public String getContextPath() 65 { 66 String cp = _contextPath; 67 68 if (cp == null) 69 cp = getId(); 70 71 if (cp == null) 72 return null; 73 74 if (cp.endsWith("/")) 75 return cp.substring(0, cp.length() - 1); 76 else 77 return cp; 78 } 79 80 83 public void setContextPath(String path) 84 throws ConfigException 85 { 86 if (! path.startsWith("/")) 87 throw new ConfigException(L.l("context-path '{0}' must start with '/'.", 88 path)); 89 90 _contextPath = path; 91 } 92 93 96 public void setURLRegexp(String pattern) 97 { 98 if (! pattern.endsWith("$")) 99 pattern = pattern + "$"; 100 if (! pattern.startsWith("^")) 101 pattern = "^" + pattern; 102 103 if (CauchoSystem.isCaseInsensitive()) 104 _urlRegexp = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE); 105 else 106 _urlRegexp = Pattern.compile(pattern); 107 } 108 109 112 public Pattern getURLRegexp() 113 { 114 return _urlRegexp; 115 } 116 117 120 public void setAppDir(RawString appDir) 121 { 122 setRootDirectory(appDir); 123 } 124 125 128 public String getAppDir() 129 { 130 return getRootDirectory(); 131 } 132 133 136 public String getDocumentDirectory() 137 { 138 return getAppDir(); 139 } 140 141 144 public void setDocumentDirectory(RawString dir) 145 { 146 setRootDirectory(dir); 147 } 148 149 152 public void setLazyInit(boolean isLazy) 153 throws ConfigException 154 { 155 log.config(L.l("lazy-init is deprecated. Use <startup-mode>lazy</startup-mode> instead.")); 156 157 if (isLazy) 158 setStartupMode("lazy"); 159 else 160 setStartupMode("automatic"); 161 } 162 163 166 public void setPrologue(WebAppConfig prologue) 167 { 168 _prologue = prologue; 169 } 170 171 174 public DeployConfig getPrologue() 175 { 176 return _prologue; 177 } 178 } 179 | Popular Tags |