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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface Lifecycle
Lifecycle.SingleUse -
Field Summary
Fields inherited from interface 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a property change listener to this component.voidaddService(Service service) Add a new Service to the set of defined Services.voidawait()Wait until a proper shutdown command is received, then return.protected voidSubclasses implement this method to perform any instance destruction required.findService(String name) Find the specified ServiceService[]Returns the array of all Services defined within this Server.Returns the address on which the server listens for shutdown commands.Returns the outer Catalina startup/shutdown component, if one has been set.Returns the configured base (instance) directory.Returns the configured home (binary) directory.protected StringMethod implemented by subclasses to identify the domain in which MBeans should be registered.Returns the global JNDI naming context for this server.Returns the global naming resources for this server.Returns the token required for performing operations on the associated JNDI naming context.protected StringAllow subclasses to specify the key properties component of theObjectNamethat will be used to register this component.Returns the parent class loader for this server component.intReturn the period between two lifecycle events, in seconds.intgetPort()Returns the port number on which the server listens for shutdown commands.intGet the number that offsets the port used for shutdown commands.intGet 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 JMX ObjectNames for all configured services.Returns the shutdown command string the server is waiting for.Returns the utility executor managed by the server for background tasks.intGet the utility thread count.booleanGet if the utility threads are daemon threads.protected voidSubclasses implement this method to perform any instance initialisation required.voidRemove a property change listener from this component.voidremoveService(Service service) Remove the specified Service from the set associated from this Server.voidsetAddress(String address) Set the address on which we listen to for shutdown commands.voidsetCatalina(Catalina catalina) Set the outer Catalina startup/shutdown component if present.voidsetCatalinaBase(File catalinaBase) Set the configured base (instance) directory.voidsetCatalinaHome(File catalinaHome) Set the configured home (binary) directory.voidsetGlobalNamingContext(Context globalNamingContext) Set the global naming resources context.voidsetGlobalNamingResources(NamingResourcesImpl globalNamingResources) Set the global naming resources.voidsetParentClassLoader(ClassLoader parent) Set the parent class loader for this server.voidsetPeriodicEventDelay(int periodicEventDelay) Set the new period between two lifecycle events in seconds.voidsetPort(int port) Set the port number we listen to for shutdown commands.voidsetPortOffset(int portOffset) Set the number that offsets the server port used for shutdown commands.voidsetShutdown(String shutdown) Set the shutdown command we are waiting for.voidsetUtilityThreads(int utilityThreads) Set the utility thread count.voidsetUtilityThreadsAsDaemon(boolean utilityThreadsAsDaemon) Set the utility threads daemon flag.protected voidSubclasses must ensure that the state is changed toLifecycleState.STARTINGduring the execution of this method.voidStop the await thread by closing the await socket and interrupting the thread.protected voidSubclasses must ensure that the state is changed toLifecycleState.STOPPINGduring the execution of this method.voidWrite the configuration information for this entireServerout to the server.xml configuration file.voidstoreContext(Context context) Write the configuration information forContextout to the specified configuration file.toString()Methods inherited from class LifecycleMBeanBase
getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister, unregisterMethods inherited from class LifecycleBase
addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stopMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface 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
Description copied from interface:ServerReturns the token required for performing operations on the associated JNDI naming context.- Specified by:
getNamingTokenin interfaceServer- Returns:
- the JNDI naming context token
-
getGlobalNamingContext
Description copied from interface:ServerReturns the global JNDI naming context for this server.- Specified by:
getGlobalNamingContextin interfaceServer- Returns:
- the global naming context
-
setGlobalNamingContext
Set the global naming resources context.- Parameters:
globalNamingContext- The new global naming resource context
-
getGlobalNamingResources
Description copied from interface:ServerReturns the global naming resources for this server.- Specified by:
getGlobalNamingResourcesin interfaceServer- Returns:
- the global naming resources
-
setGlobalNamingResources
Description copied from interface:ServerSet the global naming resources.- Specified by:
setGlobalNamingResourcesin 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
-
setPort
-
getPortOffset
public int getPortOffset()Description copied from interface:ServerGet 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:
getPortOffsetin interfaceServer- Returns:
- the port offset
-
setPortOffset
public void setPortOffset(int portOffset) Description copied from interface:ServerSet 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:
setPortOffsetin interfaceServer- Parameters:
portOffset- sets the port offset
-
getPortWithOffset
public int getPortWithOffset()Description copied from interface:ServerGet 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:
getPortWithOffsetin interfaceServer- Returns:
- the port with offset
-
getAddress
Description copied from interface:ServerReturns the address on which the server listens for shutdown commands.- Specified by:
getAddressin interfaceServer- Returns:
- the address for shutdown commands
-
setAddress
Description copied from interface:ServerSet the address on which we listen to for shutdown commands.- Specified by:
setAddressin interfaceServer- Parameters:
address- The new address
-
getShutdown
Description copied from interface:ServerReturns the shutdown command string the server is waiting for.- Specified by:
getShutdownin interfaceServer- Returns:
- the shutdown command string
-
setShutdown
Description copied from interface:ServerSet the shutdown command we are waiting for.- Specified by:
setShutdownin interfaceServer- Parameters:
shutdown- The new shutdown command
-
getCatalina
Description copied from interface:ServerReturns the outer Catalina startup/shutdown component, if one has been set.- Specified by:
getCatalinain interfaceServer- Returns:
- the Catalina component, or
nullif not set
-
setCatalina
Description copied from interface:ServerSet the outer Catalina startup/shutdown component if present.- Specified by:
setCatalinain interfaceServer- Parameters:
catalina- the outer Catalina component
-
getUtilityThreads
public int getUtilityThreads()Description copied from interface:ServerGet the utility thread count.- Specified by:
getUtilityThreadsin interfaceServer- Returns:
- the thread count
-
setUtilityThreads
public void setUtilityThreads(int utilityThreads) Description copied from interface:ServerSet the utility thread count.- Specified by:
setUtilityThreadsin interfaceServer- Parameters:
utilityThreads- the new thread count
-
getUtilityThreadsAsDaemon
public boolean getUtilityThreadsAsDaemon()Get if the utility threads are daemon threads.- Returns:
- the threads daemon flag
-
setUtilityThreadsAsDaemon
public void setUtilityThreadsAsDaemon(boolean utilityThreadsAsDaemon) Set the utility threads daemon flag. The default value is true.- Parameters:
utilityThreadsAsDaemon- the new thread daemon flag
-
getPeriodicEventDelay
public int getPeriodicEventDelay()Return the period between two lifecycle events, in seconds.- Returns:
- The period between two lifecycle events, in seconds
-
setPeriodicEventDelay
public void setPeriodicEventDelay(int periodicEventDelay) Set the new period between two lifecycle events in seconds.- Parameters:
periodicEventDelay- The period in seconds, negative or zero will disable events
-
addService
Description copied from interface:ServerAdd a new Service to the set of defined Services.- Specified by:
addServicein interfaceServer- Parameters:
service- The Service to be added
-
stopAwait
public void stopAwait()Stop the await thread by closing the await socket and interrupting the thread. -
await
-
findService
Description copied from interface:ServerFind the specified Service- Specified by:
findServicein interfaceServer- Parameters:
name- Name of the Service to be returned- Returns:
- the specified Service, or
nullif none exists.
-
findServices
Description copied from interface:ServerReturns the array of all Services defined within this Server.- Specified by:
findServicesin interfaceServer- Returns:
- the array of Services, or an empty array if none are defined
-
getServiceNames
Return the JMX ObjectNames for all configured services.- Returns:
- the JMX service names.
-
removeService
Description copied from interface:ServerRemove the specified Service from the set associated from this Server.- Specified by:
removeServicein interfaceServer- Parameters:
service- The Service to be removed
-
getCatalinaBase
Description copied from interface:ServerReturns the configured base (instance) directory. If not set, the value fromServer.getCatalinaHome()is used. Note that home and base may be the same (and are by default).- Specified by:
getCatalinaBasein interfaceServer- Returns:
- the configured base directory
-
setCatalinaBase
Description copied from interface:ServerSet the configured base (instance) directory. Note that home and base may be the same (and are by default).- Specified by:
setCatalinaBasein interfaceServer- Parameters:
catalinaBase- the configured base directory
-
getCatalinaHome
Description copied from interface:ServerReturns the configured home (binary) directory. Note that home and base may be the same (and are by default).- Specified by:
getCatalinaHomein interfaceServer- Returns:
- the configured home directory
-
setCatalinaHome
Description copied from interface:ServerSet the configured home (binary) directory. Note that home and base may be the same (and are by default).- Specified by:
setCatalinaHomein 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
-
storeConfig
Write the configuration information for this entireServerout 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 forContextout 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
Description copied from class:LifecycleBaseSubclasses must ensure that the state is changed toLifecycleState.STARTINGduring the execution of this method. Changing state will trigger theLifecycle.START_EVENTevent. If a component fails to start it may either throw aLifecycleExceptionwhich will cause it's parent to fail to start, or it can place itself in the error state in which caseLifecycleBase.stop()will be called on the failed component but the parent component will continue to start normally.- Specified by:
startInternalin classLifecycleBase- Throws:
LifecycleException- Start error occurred
-
stopInternal
Description copied from class:LifecycleBaseSubclasses must ensure that the state is changed toLifecycleState.STOPPINGduring the execution of this method. Changing state will trigger theLifecycle.STOP_EVENTevent.- Specified by:
stopInternalin classLifecycleBase- Throws:
LifecycleException- Stop error occurred
-
initInternal
Subclasses implement this method to perform any instance initialisation required.This is used to allow connectors to bind to restricted ports under Unix operating environments.
- Overrides:
initInternalin classLifecycleMBeanBase- Throws:
LifecycleException- If the initialisation fails
-
destroyInternal
Description copied from class:LifecycleBaseSubclasses implement this method to perform any instance destruction required.- Overrides:
destroyInternalin classLifecycleMBeanBase- Throws:
LifecycleException- If the destruction fails
-
getParentClassLoader
Description copied from interface:ServerReturns the parent class loader for this server component. If not explicitly set, returns the parent class loader fromServer.getCatalina(). If Catalina has not been set, returns the system class loader.- Specified by:
getParentClassLoaderin interfaceServer- Returns:
- the parent class loader
-
setParentClassLoader
Description copied from interface:ServerSet the parent class loader for this server.- Specified by:
setParentClassLoaderin interfaceServer- Parameters:
parent- The new parent class loader
-
getDomainInternal
Description copied from class:LifecycleMBeanBaseMethod implemented by subclasses to identify the domain in which MBeans should be registered.- Specified by:
getDomainInternalin classLifecycleMBeanBase- Returns:
- the MBean domain for this server. The domain is obtained using the following search order:
-
getObjectNameKeyProperties
Description copied from class:LifecycleMBeanBaseAllow subclasses to specify the key properties component of theObjectNamethat will be used to register this component.- Specified by:
getObjectNameKeyPropertiesin classLifecycleMBeanBase- Returns:
- The string representation of the key properties component of the desired
ObjectName
-
getUtilityExecutor
Description copied from interface:ServerReturns the utility executor managed by the server for background tasks.- Specified by:
getUtilityExecutorin interfaceServer- Returns:
- the utility executor service
-