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:
- javax.management.MBeanRegistration,- JmxEnabled,- Lifecycle,- Server
 
 public final class StandardServer extends LifecycleMBeanBase implements 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.LifecycleLifecycle.SingleUse
 
- 
 - 
Field Summary- 
Fields inherited from class org.apache.catalina.util.LifecycleMBeanBasemserver
 - 
Fields inherited from interface org.apache.catalina.LifecycleAFTER_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 SummaryConstructors Constructor Description StandardServer()Construct a default instance of this class.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPropertyChangeListener(java.beans.PropertyChangeListener listener)Add 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 voiddestroyInternal()Sub-classes wishing to perform additional clean-up should override this method, ensuring that super.destroyInternal() is the last call in the overriding method.ServicefindService(java.lang.String name)Find the specified ServiceService[]findServices()java.lang.StringgetAddress()Return the address on which we listen to for shutdown commands.CatalinagetCatalina()Return the outer Catalina startup/shutdown component if present.java.io.FilegetCatalinaBase()java.io.FilegetCatalinaHome()protected java.lang.StringgetDomainInternal()Obtain the MBean domain for this server.javax.naming.ContextgetGlobalNamingContext()Return the global naming resources context.NamingResourcesImplgetGlobalNamingResources()Return the global naming resources.java.lang.ObjectgetNamingToken()protected java.lang.StringgetObjectNameKeyProperties()Allow sub-classes to specify the key properties component of theObjectNamethat will be used to register this component.java.lang.ClassLoadergetParentClassLoader()Return the parent class loader for this component.intgetPeriodicEventDelay()intgetPort()Return the port number we listen to for shutdown commands.intgetPortOffset()Get the number that offsets the port used for shutdown commands.intgetPortWithOffset()Get the actual port on which server is listening for the shutdown commands.java.lang.StringgetServerBuilt()Return the current server built timestampjava.lang.StringgetServerInfo()Report the current Tomcat Server Release numberjava.lang.StringgetServerNumber()Return the current server's version number.javax.management.ObjectName[]getServiceNames()java.lang.StringgetShutdown()Return the shutdown command string we are waiting for.java.util.concurrent.ScheduledExecutorServicegetUtilityExecutor()intgetUtilityThreads()Get the utility thread count.booleangetUtilityThreadsAsDaemon()Get if the utility threads are daemon threads.protected voidinitInternal()Invoke a pre-startup initialization.voidremovePropertyChangeListener(java.beans.PropertyChangeListener listener)Remove a property change listener from this component.voidremoveService(Service service)Remove the specified Service from the set associated from this Server.voidsetAddress(java.lang.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(java.io.File catalinaBase)Set the configured base (instance) directory.voidsetCatalinaHome(java.io.File catalinaHome)Set the configured home (binary) directory.voidsetGlobalNamingContext(javax.naming.Context globalNamingContext)Set the global naming resources context.voidsetGlobalNamingResources(NamingResourcesImpl globalNamingResources)Set the global naming resources.voidsetParentClassLoader(java.lang.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(java.lang.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 voidstartInternal()Start nested components (Services) and implement the requirements ofLifecycleBase.startInternal().voidstopAwait()protected voidstopInternal()Stop nested components (Services) and implement the requirements ofLifecycleBase.stopInternal().voidstoreConfig()Write 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.java.lang.StringtoString()Return a String representation of this component.- 
Methods inherited from class org.apache.catalina.util.LifecycleMBeanBasegetDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister, unregister
 - 
Methods inherited from class org.apache.catalina.util.LifecycleBaseaddLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface org.apache.catalina.LifecycleaddLifecycleListener, destroy, findLifecycleListeners, getState, getStateName, init, removeLifecycleListener, start, stop
 
- 
 
- 
- 
- 
Method Detail- 
getNamingTokenpublic java.lang.Object getNamingToken() - Specified by:
- getNamingTokenin interface- Server
- Returns:
- the token necessary for operations on the associated JNDI naming context.
 
 - 
getGlobalNamingContextpublic javax.naming.Context getGlobalNamingContext() Return the global naming resources context.- Specified by:
- getGlobalNamingContextin interface- Server
- Returns:
- the global naming resources context.
 
 - 
setGlobalNamingContextpublic void setGlobalNamingContext(javax.naming.Context globalNamingContext) Set the global naming resources context.- Parameters:
- globalNamingContext- The new global naming resource context
 
 - 
getGlobalNamingResourcespublic NamingResourcesImpl getGlobalNamingResources() Return the global naming resources.- Specified by:
- getGlobalNamingResourcesin interface- Server
- Returns:
- the global naming resources.
 
 - 
setGlobalNamingResourcespublic void setGlobalNamingResources(NamingResourcesImpl globalNamingResources) Set the global naming resources.- Specified by:
- setGlobalNamingResourcesin interface- Server
- Parameters:
- globalNamingResources- The new global naming resources
 
 - 
getServerInfopublic java.lang.String getServerInfo() Report the current Tomcat Server Release number- Returns:
- Tomcat release identifier
 
 - 
getServerBuiltpublic java.lang.String getServerBuilt() Return the current server built timestamp- Returns:
- server built timestamp.
 
 - 
getServerNumberpublic java.lang.String getServerNumber() Return the current server's version number.- Returns:
- server's version number.
 
 - 
getPortpublic int getPort() Return the port number we listen to for shutdown commands.- Specified by:
- getPortin interface- Server
- Returns:
- the port number we listen to for shutdown commands.
- See Also:
- Server.getPortOffset(),- Server.getPortWithOffset()
 
 - 
setPortpublic void setPort(int port) Set the port number we listen to for shutdown commands.- Specified by:
- setPortin interface- Server
- Parameters:
- port- The new port number
- See Also:
- Server.setPortOffset(int)
 
 - 
getPortOffsetpublic 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 interface- Server
- Returns:
- the port offset
 
 - 
setPortOffsetpublic 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 interface- Server
- Parameters:
- portOffset- sets the port offset
 
 - 
getPortWithOffsetpublic 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 interface- Server
- Returns:
- the port with offset
 
 - 
getAddresspublic java.lang.String getAddress() Return the address on which we listen to for shutdown commands.- Specified by:
- getAddressin interface- Server
- Returns:
- the address on which we listen to for shutdown commands.
 
 - 
setAddresspublic void setAddress(java.lang.String address) Set the address on which we listen to for shutdown commands.- Specified by:
- setAddressin interface- Server
- Parameters:
- address- The new address
 
 - 
getShutdownpublic java.lang.String getShutdown() Return the shutdown command string we are waiting for.- Specified by:
- getShutdownin interface- Server
- Returns:
- the shutdown command string we are waiting for.
 
 - 
setShutdownpublic void setShutdown(java.lang.String shutdown) Set the shutdown command we are waiting for.- Specified by:
- setShutdownin interface- Server
- Parameters:
- shutdown- The new shutdown command
 
 - 
getCatalinapublic Catalina getCatalina() Return the outer Catalina startup/shutdown component if present.- Specified by:
- getCatalinain interface- Server
- Returns:
- the outer Catalina startup/shutdown component if present.
 
 - 
setCatalinapublic void setCatalina(Catalina catalina) Set the outer Catalina startup/shutdown component if present.- Specified by:
- setCatalinain interface- Server
- Parameters:
- catalina- the outer Catalina component
 
 - 
getUtilityThreadspublic int getUtilityThreads() Description copied from interface:ServerGet the utility thread count.- Specified by:
- getUtilityThreadsin interface- Server
- Returns:
- the thread count
 
 - 
setUtilityThreadspublic void setUtilityThreads(int utilityThreads) Description copied from interface:ServerSet the utility thread count.- Specified by:
- setUtilityThreadsin interface- Server
- Parameters:
- utilityThreads- the new thread count
 
 - 
getUtilityThreadsAsDaemonpublic boolean getUtilityThreadsAsDaemon() Get if the utility threads are daemon threads.- Returns:
- the threads daemon flag
 
 - 
setUtilityThreadsAsDaemonpublic void setUtilityThreadsAsDaemon(boolean utilityThreadsAsDaemon) Set the utility threads daemon flag. The default value is true.- Parameters:
- utilityThreadsAsDaemon- the new thread daemon flag
 
 - 
getPeriodicEventDelaypublic int getPeriodicEventDelay() - Returns:
- The period between two lifecycle events, in seconds
 
 - 
setPeriodicEventDelaypublic 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
 
 - 
addServicepublic void addService(Service service) Add a new Service to the set of defined Services.- Specified by:
- addServicein interface- Server
- Parameters:
- service- The Service to be added
 
 - 
stopAwaitpublic void stopAwait() 
 - 
awaitpublic 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.
 - 
findServicepublic Service findService(java.lang.String name) Description copied from interface:ServerFind the specified Service- Specified by:
- findServicein interface- Server
- Parameters:
- name- Name of the Service to be returned
- Returns:
- the specified Service (if it exists); otherwise return null.
 
 - 
findServicespublic Service[] findServices() - Specified by:
- findServicesin interface- Server
- Returns:
- The array of Services defined within this Server.
 
 - 
getServiceNamespublic javax.management.ObjectName[] getServiceNames() - Returns:
- the JMX service names.
 
 - 
removeServicepublic void removeService(Service service) Remove the specified Service from the set associated from this Server.- Specified by:
- removeServicein interface- Server
- Parameters:
- service- The Service to be removed
 
 - 
getCatalinaBasepublic java.io.File getCatalinaBase() - Specified by:
- getCatalinaBasein interface- Server
- 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.
 
 - 
setCatalinaBasepublic void setCatalinaBase(java.io.File catalinaBase) 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 interface- Server
- Parameters:
- catalinaBase- the configured base directory
 
 - 
getCatalinaHomepublic java.io.File getCatalinaHome() - Specified by:
- getCatalinaHomein interface- Server
- Returns:
- the configured home (binary) directory. Note that home and base may be the same (and are by default).
 
 - 
setCatalinaHomepublic void setCatalinaHome(java.io.File catalinaHome) 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 interface- Server
- Parameters:
- catalinaHome- the configured home directory
 
 - 
addPropertyChangeListenerpublic void addPropertyChangeListener(java.beans.PropertyChangeListener listener) Add a property change listener to this component.- Parameters:
- listener- The listener to add
 
 - 
removePropertyChangeListenerpublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener) Remove a property change listener from this component.- Parameters:
- listener- The listener to remove
 
 - 
toStringpublic java.lang.String toString() Return a String representation of this component.- Overrides:
- toStringin class- java.lang.Object
 
 - 
storeConfigpublic void storeConfig() throws javax.management.InstanceNotFoundException, javax.management.MBeanExceptionWrite the configuration information for this entireServerout to the server.xml configuration file.- Throws:
- javax.management.InstanceNotFoundException- if the managed resource object cannot be found
- javax.management.MBeanException- if the initializer of the object throws an exception, or persistence is not supported
- javax.management.RuntimeOperationsException- if an exception is reported by the persistence mechanism
 
 - 
storeContextpublic void storeContext(Context context) throws javax.management.InstanceNotFoundException, javax.management.MBeanException Write the configuration information forContextout to the specified configuration file.- Parameters:
- context- the context which should save its configuration
- Throws:
- javax.management.InstanceNotFoundException- if the managed resource object cannot be found
- javax.management.MBeanException- if the initializer of the object throws an exception or persistence is not supported
- javax.management.RuntimeOperationsException- if an exception is reported by the persistence mechanism
 
 - 
startInternalprotected void startInternal() throws LifecycleExceptionStart nested components (Services) and implement the requirements ofLifecycleBase.startInternal().- Specified by:
- startInternalin class- LifecycleBase
- Throws:
- LifecycleException- if this component detects a fatal error that prevents this component from being used
 
 - 
stopInternalprotected void stopInternal() throws LifecycleExceptionStop nested components (Services) and implement the requirements ofLifecycleBase.stopInternal().- Specified by:
- stopInternalin class- LifecycleBase
- Throws:
- LifecycleException- if this component detects a fatal error that needs to be reported
 
 - 
initInternalprotected void initInternal() throws LifecycleExceptionInvoke a pre-startup initialization. This is used to allow connectors to bind to restricted ports under Unix operating environments.- Overrides:
- initInternalin class- LifecycleMBeanBase
- Throws:
- LifecycleException- If the initialisation fails
 
 - 
destroyInternalprotected void destroyInternal() throws LifecycleExceptionDescription copied from class:LifecycleMBeanBaseSub-classes wishing to perform additional clean-up should override this method, ensuring that super.destroyInternal() is the last call in the overriding method.- Overrides:
- destroyInternalin class- LifecycleMBeanBase
- Throws:
- LifecycleException- If the destruction fails
 
 - 
getParentClassLoaderpublic java.lang.ClassLoader getParentClassLoader() Return the parent class loader for this component.- Specified by:
- getParentClassLoaderin interface- Server
- 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.
 
 - 
setParentClassLoaderpublic void setParentClassLoader(java.lang.ClassLoader parent) Set the parent class loader for this server.- Specified by:
- setParentClassLoaderin interface- Server
- Parameters:
- parent- The new parent class loader
 
 - 
getDomainInternalprotected java.lang.String getDomainInternal() Obtain the MBean domain for this server. The domain is obtained using the following search order:- Specified by:
- getDomainInternalin class- LifecycleMBeanBase
- Returns:
- The name of the domain to use to register MBeans.
 
 - 
getObjectNameKeyPropertiesprotected java.lang.String getObjectNameKeyProperties() Description copied from class:LifecycleMBeanBaseAllow sub-classes to specify the key properties component of theObjectNamethat will be used to register this component.- Specified by:
- getObjectNameKeyPropertiesin class- LifecycleMBeanBase
- Returns:
- The string representation of the key properties component of the
          desired ObjectName
 
 - 
getUtilityExecutorpublic java.util.concurrent.ScheduledExecutorService getUtilityExecutor() - Specified by:
- getUtilityExecutorin interface- Server
- Returns:
- the utility executor managed by the Service.
 
 
- 
 
-