Add a new Context to an existing Host. @param hostName Virtual host name this context belongs to @param host Host object @param path Context path @param version Context version @param context Context object @param welcomeResources Welcome files defi
(String hostName, Host host, String path, String version, Context context,
String[] welcomeResources, WebResourceRoot resources, Collection<WrapperMappingInfo> wrappers)
| 269 | * @param wrappers Information on wrapper mappings |
| 270 | */ |
| 271 | public void addContextVersion(String hostName, Host host, String path, String version, Context context, |
| 272 | String[] welcomeResources, WebResourceRoot resources, Collection<WrapperMappingInfo> wrappers) { |
| 273 | |
| 274 | hostName = renameWildcardHost(hostName); |
| 275 | |
| 276 | MappedHost mappedHost = exactFind(hosts, hostName); |
| 277 | if (mappedHost == null) { |
| 278 | addHost(hostName, new String[0], host); |
| 279 | mappedHost = exactFind(hosts, hostName); |
| 280 | if (mappedHost == null) { |
| 281 | log.error(sm.getString("mapper.addContext.noHost", hostName)); |
| 282 | return; |
| 283 | } |
| 284 | } |
| 285 | if (mappedHost.isAlias()) { |
| 286 | log.error(sm.getString("mapper.addContext.hostIsAlias", hostName)); |
| 287 | return; |
| 288 | } |
| 289 | int slashCount = slashCount(path); |
| 290 | synchronized (mappedHost) { |
| 291 | ContextVersion newContextVersion = |
| 292 | new ContextVersion(version, path, slashCount, context, resources, welcomeResources); |
| 293 | if (wrappers != null) { |
| 294 | addWrappers(newContextVersion, wrappers); |
| 295 | } |
| 296 | |
| 297 | ContextList contextList = mappedHost.contextList; |
| 298 | MappedContext mappedContext = exactFind(contextList.contexts, path); |
| 299 | if (mappedContext == null) { |
| 300 | mappedContext = new MappedContext(path, newContextVersion); |
| 301 | ContextList newContextList = contextList.addContext(mappedContext, slashCount); |
| 302 | if (newContextList != null) { |
| 303 | updateContextList(mappedHost, newContextList); |
| 304 | contextObjectToContextVersionMap.put(context, newContextVersion); |
| 305 | } |
| 306 | } else { |
| 307 | ContextVersion[] contextVersions = mappedContext.versions; |
| 308 | ContextVersion[] newContextVersions = new ContextVersion[contextVersions.length + 1]; |
| 309 | if (insertMap(contextVersions, newContextVersions, newContextVersion)) { |
| 310 | mappedContext.versions = newContextVersions; |
| 311 | contextObjectToContextVersionMap.put(context, newContextVersion); |
| 312 | } else { |
| 313 | // Re-registration after Context.reload() |
| 314 | // Replace ContextVersion with the new one |
| 315 | int pos = find(contextVersions, version); |
| 316 | if (pos >= 0 && contextVersions[pos].name.equals(version)) { |
| 317 | contextVersions[pos] = newContextVersion; |
| 318 | contextObjectToContextVersionMap.put(context, newContextVersion); |
| 319 | } |
| 320 | } |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | } |
| 325 | |
| 326 | |
| 327 | /** |