|
|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.catalina.startup.Embedded
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.
createEngine()
to create an Engine object, and then
call its property setters as desired.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)
.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)
.addEngine()
to attach this Engine to the set of
defined Engines for this object.createConnector()
to create at least one TCP/IP
connector, and then call its property setters as desired.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.start()
to initiate normal operations of all the
attached components.
To initiate a normal shutdown, call the stop()
method of
this object.
IMPLEMENTATION NOTE: The main()
method of
this class is a simple example that exercizes the features of dynamically
starting and stopping various components. You can execute this by executing
the following steps (on a Unix platform):
cd $CATALINA_HOME ./bin/catalina.sh embedded
Field Summary | |
protected Connector[] |
connectors
The set of Connectors that have been deployed in this server. |
protected int |
debug
The debugging detail level for this component. |
protected Engine[] |
engines
The set of Engines that have been deployed in this server. |
protected static java.lang.String |
info
Descriptive information about this server implementation. |
protected LifecycleSupport |
lifecycle
The lifecycle event support for this component. |
protected Logger |
logger
The default logger to be used by this component itself. |
protected Realm |
realm
The default realm to be used by all containers associated with this compoennt. |
protected static StringManager |
sm
The string manager for this package. |
protected java.lang.String |
socketFactory
The socket factory that will be used when a secure
Connector is created. |
protected boolean |
started
Has this component been started yet? |
protected java.beans.PropertyChangeSupport |
support
The property change support for this component. |
protected boolean |
useNaming
Is naming enabled ? |
Fields inherited from interface org.apache.catalina.Lifecycle |
AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, START_EVENT, STOP_EVENT |
Constructor Summary | |
Embedded()
Construct a new instance of this class with default properties. |
|
Embedded(Logger logger,
Realm realm)
Construct a new instance of this class with specified properties. |
Method Summary | |
void |
addConnector(Connector connector)
Add a new Connector to the set of defined Connectors. |
void |
addEngine(Engine engine)
Add a new Engine to the set of defined Engines. |
void |
addLifecycleListener(LifecycleListener listener)
Add a lifecycle event listener to this component. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a property change listener to this component. |
Connector |
createConnector(java.net.InetAddress address,
int port,
boolean secure)
Create, configure, and return a new TCP/IP socket connector based on the specified properties. |
Connector |
createConnector(java.net.InetAddress address,
int port,
java.lang.String protocol)
|
Context |
createContext(java.lang.String path,
java.lang.String docBase)
Create, configure, and return a Context that will process all HTTP requests received from one of the associated Connectors, and directed to the specified context path on the virtual host to which this Context is connected. |
Engine |
createEngine()
Create, configure, and return an Engine that will process all HTTP requests received from one of the associated Connectors, based on the specified properties. |
Host |
createHost(java.lang.String name,
java.lang.String appBase)
Create, configure, and return a Host that will process all HTTP requests received from one of the associated Connectors, and directed to the specified virtual host. |
Loader |
createLoader(java.lang.ClassLoader parent)
Create and return a class loader manager that can be customized, and then attached to a Context, before it is started. |
LifecycleListener[] |
findLifecycleListeners()
Get the lifecycle listeners associated with this lifecycle. |
int |
getDebug()
Return the debugging detail level for this component. |
java.lang.String |
getInfo()
Return descriptive information about this Server implementation and the corresponding version number, in the format <description>/<version> . |
Logger |
getLogger()
Return the Logger for this component. |
Realm |
getRealm()
Return the default Realm for our Containers. |
java.lang.String |
getSocketFactory()
Return the secure socket factory class name. |
boolean |
isUseNaming()
Return true if naming is enabled. |
static void |
main(java.lang.String[] args)
This main program is a unit test to exercize the various methods of the Embedded class. |
void |
removeConnector(Connector connector)
Remove the specified Connector from the set of defined Connectors. |
void |
removeContext(Context context)
Remove the specified Context from the set of defined Contexts for its associated Host. |
void |
removeEngine(Engine engine)
Remove the specified Engine from the set of defined Engines, along with all of its related Hosts and Contexts. |
void |
removeHost(Host host)
Remove the specified Host, along with all of its related Contexts, from the set of defined Hosts for its associated Engine. |
void |
removeLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a property change listener from this component. |
void |
setDebug(int debug)
Set the debugging detail level for this component. |
void |
setLogger(Logger logger)
Set the Logger for this component. |
void |
setRealm(Realm realm)
Set the default Realm for our Containers. |
void |
setSocketFactory(java.lang.String socketFactory)
Set the secure socket factory class name. |
void |
setUseNaming(boolean useNaming)
Enables or disables naming support. |
void |
start()
Prepare for the beginning of active use of the public methods of this component. |
void |
stop()
Gracefully terminate the active use of the public methods of this component. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected Connector[] connectors
protected int debug
protected boolean useNaming
protected Engine[] engines
protected static final java.lang.String info
protected LifecycleSupport lifecycle
protected Logger logger
protected Realm realm
protected static StringManager sm
protected java.lang.String socketFactory
secure
Connector is created. If a standard Connector is created, the
internal (to the Connector class default socket factory class)
will be used instead.
protected boolean started
protected java.beans.PropertyChangeSupport support
Constructor Detail |
public Embedded()
public Embedded(Logger logger, Realm realm)
logger
- Logger implementation to be inherited by all components
(unless overridden further down the container hierarchy)realm
- Realm implementation to be inherited by all components
(unless overridden further down the container hierarchy)Method Detail |
public int getDebug()
public void setDebug(int debug)
debug
- The new debugging detail levelpublic boolean isUseNaming()
public void setUseNaming(boolean useNaming)
useNaming
- The new use naming valuepublic Logger getLogger()
public void setLogger(Logger logger)
logger
- The new loggerpublic Realm getRealm()
public void setRealm(Realm realm)
realm
- The new default realmpublic java.lang.String getSocketFactory()
public void setSocketFactory(java.lang.String socketFactory)
socketFactory
- The new secure socket factory class namepublic void addConnector(Connector connector)
connector
- The connector to be added
java.lang.IllegalStateException
- if no engines have been added yetpublic void addEngine(Engine engine)
engine
- The engine to be addedpublic void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The listener to addpublic Connector createConnector(java.net.InetAddress address, int port, boolean secure)
address
- InetAddress to listen to, or null
to listen on all address on this serverport
- Port number to listen tosecure
- Should this port be SSL-enabled?public Connector createConnector(java.net.InetAddress address, int port, java.lang.String protocol)
public Context createContext(java.lang.String path, java.lang.String docBase)
After you have customized the properties, listeners, and Valves for this Context, you must attach it to the corresponding Host by calling:
host.addChild(context);which will also cause the Context to be started if the Host has already been started.
path
- Context path of this application ("" for the default
application for this host, must start with a slash otherwise)docBase
- Absolute pathname to the document base directory
for this web application
java.lang.IllegalArgumentException
- if an invalid parameter
is specifiedpublic Engine createEngine()
public Host createHost(java.lang.String name, java.lang.String appBase)
After you have customized the properties, listeners, and Valves for this Host, you must attach it to the corresponding Engine by calling:
engine.addChild(host);which will also cause the Host to be started if the Engine has already been started. If this is the default (or only) Host you will be defining, you may also tell the Engine to pass all requests not assigned to another virtual host to this one:
engine.setDefaultHost(host.getName());
name
- Canonical name of this virtual hostappBase
- Absolute pathname to the application base directory
for this virtual host
java.lang.IllegalArgumentException
- if an invalid parameter
is specifiedpublic Loader createLoader(java.lang.ClassLoader parent)
parent
- ClassLoader that will be the parent of the one
created by this Loaderpublic java.lang.String getInfo()
<description>/<version>
.
public void removeConnector(Connector connector)
connector
- The Connector to be removedpublic void removeContext(Context context)
context
- The Context to be removedpublic void removeEngine(Engine engine)
engine
- The Engine to be removedpublic void removeHost(Host host)
host
- The Host to be removedpublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The listener to removepublic void addLifecycleListener(LifecycleListener listener)
addLifecycleListener
in interface Lifecycle
listener
- The listener to addpublic LifecycleListener[] findLifecycleListeners()
findLifecycleListeners
in interface Lifecycle
public void removeLifecycleListener(LifecycleListener listener)
removeLifecycleListener
in interface Lifecycle
listener
- The listener to removepublic void start() throws LifecycleException
configure()
,
and before any of the public methods of the component are utilized.
start
in interface Lifecycle
LifecycleException
- if this component detects a fatal error
that prevents this component from being usedpublic void stop() throws LifecycleException
stop
in interface Lifecycle
LifecycleException
- if this component detects a fatal error
that needs to be reportedpublic static void main(java.lang.String[] args)
args
- The command line arguments
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |