MCPcopy Index your code
hub / github.com/apache/tomcat / addContextVersion

Method addContextVersion

java/org/apache/catalina/mapper/Mapper.java:271–324  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 /**

Callers 8

testCompareIgnoreCaseMethod · 0.95
setUpMethod · 0.80
testAddHostMethod · 0.80
runMethod · 0.80
registerContextMethod · 0.80

Calls 14

renameWildcardHostMethod · 0.95
exactFindMethod · 0.95
addHostMethod · 0.95
isAliasMethod · 0.95
slashCountMethod · 0.95
addWrappersMethod · 0.95
addContextMethod · 0.95
updateContextListMethod · 0.95
insertMapMethod · 0.95
findMethod · 0.95
errorMethod · 0.65
getStringMethod · 0.65

Tested by 7

testCompareIgnoreCaseMethod · 0.76
setUpMethod · 0.64
testAddHostMethod · 0.64
runMethod · 0.64