Bug 51418 - Allow more flexibility in adding webapps to org.apache.catalina.startup.Tomcat
Summary: Allow more flexibility in adding webapps to org.apache.catalina.startup.Tomcat
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 7.0.16
Hardware: PC All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-22 15:54 UTC by bmargulies
Modified: 2011-06-22 18:31 UTC (History)
0 users



Attachments
A patch to Tomcat.java as described. (3.34 KB, patch)
2011-06-22 15:54 UTC, bmargulies
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description bmargulies 2011-06-22 15:54:00 UTC
Created attachment 27194 [details]
A patch to Tomcat.java as described.

the Tomcat.addWebapp all create a context, set up the default realm, and set up the surrogate global web.xml lifecycle listener. They differ according to allowing more or less specific configuration of the new webapp. At the end, they add the new context to the host.

Once the container is running, the act of calling addChild starts it. Some configuration steps have to precede 'start' -- for example, setting the loader. Thus, in a complex case, the user needs to take more control of the process.

As things are today, this requires subclassing the Tomcat class and then copying code from the four-arg addWebapp.

The patch provided here allows non-subclasses to take complete control of the process. It accomplishes this by providing methods to obtain three things that are otherwise buried in the Tomcat class: the default in-memory realm, the listener that serves as a surrogate global web.xml, and a dummy pathname to allow the listener to work without conflicts.

Given these accessors, a user can simple create a the context (and its ContextConfig) and configure it to their heart's content, and then pass it to the addChild method of a Host.
Comment 1 Mark Thomas 2011-06-22 18:31:16 UTC
Thanks for the patch. It has been applied with a few changes (line lengths, spaces rather than tabs) to 7.0.x and will be included in 7.0.17 onwards.