Convenience class to embed a Catalina servlet container environment inside another application. You must call the methods of this class in the following order to ensure correct operation.
- Instantiate a new instance of this class.
- Set the relevant properties of this object itself. In particular, you will want to establish the default Logger to be used, as well as the default Realm if you are using container-managed security.
- Call
createEngine()
to create an Engine object, and then call its property setters as desired. - Call
createHost()
to create at least one virtual Host associated with the newly created Engine, and then call its property setters as desired. After you customize this Host, add it to the corresponding Engine with engine.addChild(host)
. - Call
createContext()
to create at least one Context associated with each newly created Host, and then call its property setters as desired. You SHOULD create a Context with a pathname equal to a zero-length string, which will be used to process all requests not mapped to some other Context. After you customize this Context, add it to the corresponding Host with host.addChild(context)
. - Call
addEngine()
to attach this Engine to the set of defined Engines for this object. - Call
createConnector()
to create at least one TCP/IP connector, and then call its property setters as desired. - Call
addConnector()
to attach this Connector to the set of defined Connectors for this object. The added Connector will use the most recently added Engine to process its received requests. - Repeat the above series of steps as often as required (although there will typically be only one Engine instance created).
- Call
start()
to initiate normal operations of all the attached components.
After normal operations have begun, you can add and remove Connectors, Engines, Hosts, and Contexts on the fly. However, once you have removed a particular component, it must be thrown away -- you can create a new one with the same characteristics if you merely want to do a restart.
To initiate a normal shutdown, call the stop()
method of this object.
@see org.apache.catalina.startup.Catalina#main For a complete exampleof how Tomcat is set up and launched as an Embedded application.
@author Craig R. McClanahan
@version $Id: Embedded.java 939353 2010-04-29 15:50:43Z kkolinko $