Package org.apache.catalina.core
Class StandardServer
java.lang.Object
org.apache.catalina.util.LifecycleBase
org.apache.catalina.util.LifecycleMBeanBase
org.apache.catalina.core.StandardServer
- All Implemented Interfaces:
MBeanRegistration
,JmxEnabled
,Lifecycle
,Server
Standard implementation of the Server interface, available for use (but not required) when deploying and
starting Catalina.
- Author:
- Craig R. McClanahan
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.catalina.Lifecycle
Lifecycle.SingleUse
-
Field Summary
Fields inherited from class org.apache.catalina.util.LifecycleMBeanBase
mserver
Fields inherited from interface org.apache.catalina.Lifecycle
AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a property change listener to this component.void
addService
(Service service) Add a new Service to the set of defined Services.void
await()
Wait until a proper shutdown command is received, then return.protected void
Sub-classes wishing to perform additional clean-up should override this method, ensuring that super.destroyInternal() is the last call in the overriding method.findService
(String name) Find the specified ServiceService[]
Return the address on which we listen to for shutdown commands.Return the outer Catalina startup/shutdown component if present.protected String
Obtain the MBean domain for this server.Return the global naming resources context.Return the global naming resources.protected String
Allow sub-classes to specify the key properties component of theObjectName
that will be used to register this component.Return the parent class loader for this component.int
getPort()
Return the port number we listen to for shutdown commands.int
Get the number that offsets the port used for shutdown commands.int
Get the actual port on which server is listening for the shutdown commands.Return the current server built timestampReport the current Tomcat Server Release numberReturn the current server's version number.Return the shutdown command string we are waiting for.protected void
Invoke a pre-startup initialization.void
Remove a property change listener from this component.void
removeService
(Service service) Remove the specified Service from the set associated from this Server.void
setAddress
(String address) Set the address on which we listen to for shutdown commands.void
setCatalina
(Catalina catalina) Set the outer Catalina startup/shutdown component if present.void
setCatalinaBase
(File catalinaBase) Set the configured base (instance) directory.void
setCatalinaHome
(File catalinaHome) Set the configured home (binary) directory.void
setGlobalNamingContext
(Context globalNamingContext) Set the global naming resources context.void
setGlobalNamingResources
(NamingResourcesImpl globalNamingResources) Set the global naming resources.void
setParentClassLoader
(ClassLoader parent) Set the parent class loader for this server.void
setPort
(int port) Set the port number we listen to for shutdown commands.void
setPortOffset
(int portOffset) Set the number that offsets the server port used for shutdown commands.void
setShutdown
(String shutdown) Set the shutdown command we are waiting for.protected void
Start nested components (Service
s) and implement the requirements ofLifecycleBase.startInternal()
.void
protected void
Stop nested components (Service
s) and implement the requirements ofLifecycleBase.stopInternal()
.void
Write the configuration information for this entireServer
out to the server.xml configuration file.void
storeContext
(Context context) Write the configuration information forContext
out to the specified configuration file.toString()
Return a String representation of this component.Methods inherited from class org.apache.catalina.util.LifecycleMBeanBase
getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister
Methods inherited from class org.apache.catalina.util.LifecycleBase
addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.catalina.Lifecycle
addLifecycleListener, destroy, findLifecycleListeners, getState, getStateName, init, removeLifecycleListener, start, stop
-
Constructor Details
-
StandardServer
public StandardServer()Construct a default instance of this class.
-
-
Method Details
-
getNamingToken
- Specified by:
getNamingToken
in interfaceServer
- Returns:
- the token necessary for operations on the associated JNDI naming context.
-
getGlobalNamingContext
Return the global naming resources context.- Specified by:
getGlobalNamingContext
in interfaceServer
- Returns:
- the global naming resources context.
-
setGlobalNamingContext
Set the global naming resources context.- Parameters:
globalNamingContext
- The new global naming resource context
-
getGlobalNamingResources
Return the global naming resources.- Specified by:
getGlobalNamingResources
in interfaceServer
- Returns:
- the global naming resources.
-
setGlobalNamingResources
Set the global naming resources.- Specified by:
setGlobalNamingResources
in interfaceServer
- Parameters:
globalNamingResources
- The new global naming resources
-
getServerInfo
Report the current Tomcat Server Release number- Returns:
- Tomcat release identifier
-
getServerBuilt
Return the current server built timestamp- Returns:
- server built timestamp.
-
getServerNumber
Return the current server's version number.- Returns:
- server's version number.
-
getPort
public int getPort()Return the port number we listen to for shutdown commands. -
setPort
public void setPort(int port) Set the port number we listen to for shutdown commands. -
getPortOffset
public int getPortOffset()Description copied from interface:Server
Get the number that offsets the port used for shutdown commands. For example, if port is 8005, and portOffset is 1000, the server listens at 9005.- Specified by:
getPortOffset
in interfaceServer
- Returns:
- the port offset
-
setPortOffset
public void setPortOffset(int portOffset) Description copied from interface:Server
Set the number that offsets the server port used for shutdown commands. For example, if port is 8005, and you set portOffset to 1000, connector listens at 9005.- Specified by:
setPortOffset
in interfaceServer
- Parameters:
portOffset
- sets the port offset
-
getPortWithOffset
public int getPortWithOffset()Description copied from interface:Server
Get the actual port on which server is listening for the shutdown commands. If you do not set port offset, port is returned. If you set port offset, port offset + port is returned.- Specified by:
getPortWithOffset
in interfaceServer
- Returns:
- the port with offset
-
getAddress
Return the address on which we listen to for shutdown commands.- Specified by:
getAddress
in interfaceServer
- Returns:
- the address on which we listen to for shutdown commands.
-
setAddress
Set the address on which we listen to for shutdown commands.- Specified by:
setAddress
in interfaceServer
- Parameters:
address
- The new address
-
getShutdown
Return the shutdown command string we are waiting for.- Specified by:
getShutdown
in interfaceServer
- Returns:
- the shutdown command string we are waiting for.
-
setShutdown
Set the shutdown command we are waiting for.- Specified by:
setShutdown
in interfaceServer
- Parameters:
shutdown
- The new shutdown command
-
getCatalina
Return the outer Catalina startup/shutdown component if present.- Specified by:
getCatalina
in interfaceServer
- Returns:
- the outer Catalina startup/shutdown component if present.
-
setCatalina
Set the outer Catalina startup/shutdown component if present.- Specified by:
setCatalina
in interfaceServer
- Parameters:
catalina
- the outer Catalina component
-
addService
Add a new Service to the set of defined Services.- Specified by:
addService
in interfaceServer
- Parameters:
service
- The Service to be added
-
stopAwait
public void stopAwait() -
await
public void await()Wait until a proper shutdown command is received, then return. This keeps the main thread alive - the thread pool listening for http connections is daemon threads. -
findService
Description copied from interface:Server
Find the specified Service- Specified by:
findService
in interfaceServer
- Parameters:
name
- Name of the Service to be returned- Returns:
- the specified Service (if it exists); otherwise return
null
.
-
findServices
- Specified by:
findServices
in interfaceServer
- Returns:
- The array of Services defined within this Server.
-
getServiceNames
- Returns:
- the JMX service names.
-
removeService
Remove the specified Service from the set associated from this Server.- Specified by:
removeService
in interfaceServer
- Parameters:
service
- The Service to be removed
-
getCatalinaBase
- Specified by:
getCatalinaBase
in interfaceServer
- Returns:
- the configured base (instance) directory. Note that home and base
may be the same (and are by default). If this is not set the value
returned by
Server.getCatalinaHome()
will be used.
-
setCatalinaBase
Description copied from interface:Server
Set the configured base (instance) directory. Note that home and base may be the same (and are by default).- Specified by:
setCatalinaBase
in interfaceServer
- Parameters:
catalinaBase
- the configured base directory
-
getCatalinaHome
- Specified by:
getCatalinaHome
in interfaceServer
- Returns:
- the configured home (binary) directory. Note that home and base may be the same (and are by default).
-
setCatalinaHome
Description copied from interface:Server
Set the configured home (binary) directory. Note that home and base may be the same (and are by default).- Specified by:
setCatalinaHome
in interfaceServer
- Parameters:
catalinaHome
- the configured home directory
-
addPropertyChangeListener
Add a property change listener to this component.- Parameters:
listener
- The listener to add
-
removePropertyChangeListener
Remove a property change listener from this component.- Parameters:
listener
- The listener to remove
-
toString
Return a String representation of this component. -
storeConfig
Write the configuration information for this entireServer
out to the server.xml configuration file.- Throws:
InstanceNotFoundException
- if the managed resource object cannot be foundMBeanException
- if the initializer of the object throws an exception, or persistence is not supportedRuntimeOperationsException
- if an exception is reported by the persistence mechanism
-
storeContext
Write the configuration information forContext
out to the specified configuration file.- Parameters:
context
- the context which should save its configuration- Throws:
InstanceNotFoundException
- if the managed resource object cannot be foundMBeanException
- if the initializer of the object throws an exception or persistence is not supportedRuntimeOperationsException
- if an exception is reported by the persistence mechanism
-
startInternal
Start nested components (Service
s) and implement the requirements ofLifecycleBase.startInternal()
.- Specified by:
startInternal
in classLifecycleBase
- Throws:
LifecycleException
- if this component detects a fatal error that prevents this component from being used
-
stopInternal
Stop nested components (Service
s) and implement the requirements ofLifecycleBase.stopInternal()
.- Specified by:
stopInternal
in classLifecycleBase
- Throws:
LifecycleException
- if this component detects a fatal error that needs to be reported
-
initInternal
Invoke a pre-startup initialization. This is used to allow connectors to bind to restricted ports under Unix operating environments.- Overrides:
initInternal
in classLifecycleMBeanBase
- Throws:
LifecycleException
- If the initialisation fails
-
destroyInternal
Description copied from class:LifecycleMBeanBase
Sub-classes wishing to perform additional clean-up should override this method, ensuring that super.destroyInternal() is the last call in the overriding method.- Overrides:
destroyInternal
in classLifecycleMBeanBase
- Throws:
LifecycleException
- If the destruction fails
-
getParentClassLoader
Return the parent class loader for this component.- Specified by:
getParentClassLoader
in interfaceServer
- Returns:
- the parent class loader for this component. If not set, return
Server.getCatalina()
Catalina.getParentClassLoader()
. If catalina has not been set, return the system class loader.
-
setParentClassLoader
Set the parent class loader for this server.- Specified by:
setParentClassLoader
in interfaceServer
- Parameters:
parent
- The new parent class loader
-
getDomainInternal
Obtain the MBean domain for this server. The domain is obtained using the following search order:- Specified by:
getDomainInternal
in classLifecycleMBeanBase
- Returns:
- The name of the domain to use to register MBeans.
-
getObjectNameKeyProperties
Description copied from class:LifecycleMBeanBase
Allow sub-classes to specify the key properties component of theObjectName
that will be used to register this component.- Specified by:
getObjectNameKeyProperties
in classLifecycleMBeanBase
- Returns:
- The string representation of the key properties component of the
desired
ObjectName
-