StandardServer (Apache Tomcat 11.0.24 API Documentation)
Description: declaration: package: org.apache.catalina.core, class: StandardServer

# 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`

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.

- ## 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
  Constructor
  Description
  `StandardServer()`
  Construct a default instance of this class.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addPropertyChangeListener(PropertyChangeListener listener)`
  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`
  `destroyInternal()`
  Subclasses implement this method to perform any instance destruction required.
  `Service`
  `findService(String name)`
  Find the specified Service
  `Service[]`
  `findServices()`
  Returns the array of all Services defined within this Server.
  `String`
  `getAddress()`
  Returns the address on which the server listens for shutdown commands.
  `Catalina`
  `getCatalina()`
  Returns the outer Catalina startup/shutdown component, if one has been set.
  `File`
  `getCatalinaBase()`
  Returns the configured base (instance) directory.
  `File`
  `getCatalinaHome()`
  Returns the configured home (binary) directory.
  `protected String`
  `getDomainInternal()`
  Method implemented by subclasses to identify the domain in which MBeans should be registered.
  `Context`
  `getGlobalNamingContext()`
  Returns the global JNDI naming context for this server.
  `NamingResourcesImpl`
  `getGlobalNamingResources()`
  Returns the global naming resources for this server.
  `Object`
  `getNamingToken()`
  Returns the token required for performing operations on the associated JNDI naming context.
  `protected String`
  `getObjectNameKeyProperties()`
  Allow subclasses to specify the key properties component of the `ObjectName` that will be used to register this component.
  `ClassLoader`
  `getParentClassLoader()`
  Returns the parent class loader for this server component.
  `int`
  `getPeriodicEventDelay()`
  Return the period between two lifecycle events, in seconds.
  `int`
  `getPort()`
  Returns the port number on which the server listens for shutdown commands.
  `int`
  `getPortOffset()`
  Get the number that offsets the port used for shutdown commands.
  `int`
  `getPortWithOffset()`
  Get the actual port on which server is listening for the shutdown commands.
  `String`
  `getServerBuilt()`
  Return the current server built timestamp
  `String`
  `getServerInfo()`
  Report the current Tomcat Server Release number
  `String`
  `getServerNumber()`
  Return the current server's version number.
  `ObjectName[]`
  `getServiceNames()`
  Return the JMX ObjectNames for all configured services.
  `String`
  `getShutdown()`
  Returns the shutdown command string the server is waiting for.
  `ScheduledExecutorService`
  `getUtilityExecutor()`
  Returns the utility executor managed by the server for background tasks.
  `int`
  `getUtilityThreads()`
  Get the utility thread count.
  `boolean`
  `getUtilityThreadsAsDaemon()`
  Get if the utility threads are daemon threads.
  `protected void`
  `initInternal()`
  Subclasses implement this method to perform any instance initialisation required.
  `void`
  `removePropertyChangeListener(PropertyChangeListener listener)`
  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`
  `setPeriodicEventDelay(int periodicEventDelay)`
  Set the new period between two lifecycle events in seconds.
  `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.
  `void`
  `setUtilityThreads(int utilityThreads)`
  Set the utility thread count.
  `void`
  `setUtilityThreadsAsDaemon(boolean utilityThreadsAsDaemon)`
  Set the utility threads daemon flag.
  `protected void`
  `startInternal()`
  Subclasses must ensure that the state is changed to `LifecycleState.STARTING` during the execution of this method.
  `void`
  `stopAwait()`
  Stop the await thread by closing the await socket and interrupting the thread.
  `protected void`
  `stopInternal()`
  Subclasses must ensure that the state is changed to `LifecycleState.STOPPING` during the execution of this method.
  `void`
  `storeConfig()`
  Write the configuration information for this entire `Server` out to the server.xml configuration file.
  `void`
  `storeContext(Context context)`
  Write the configuration information for `Context` out to the specified configuration file.
  `String`
  `toString()`

  ### Methods inherited from class LifecycleMBeanBase

  `getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister, unregister`

  ### Methods inherited from class LifecycleBase

  `addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods 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

    public Object getNamingToken()
    Description copied from interface: `Server`
    Returns the token required for performing operations on the associated JNDI naming context.
    Specified by:
      `getNamingToken` in interface `Server`
    Returns:
      the JNDI naming context token

  - ### getGlobalNamingContext

    public Context getGlobalNamingContext()
    Description copied from interface: `Server`
    Returns the global JNDI naming context for this server.
    Specified by:
      `getGlobalNamingContext` in interface `Server`
    Returns:
      the global naming context

  - ### setGlobalNamingContext

    public void setGlobalNamingContext(Context globalNamingContext)
    Set the global naming resources context.
    Parameters:
      `globalNamingContext` - The new global naming resource context

  - ### getGlobalNamingResources

    public NamingResourcesImpl getGlobalNamingResources()
    Description copied from interface: `Server`
    Returns the global naming resources for this server.
    Specified by:
      `getGlobalNamingResources` in interface `Server`
    Returns:
      the global naming resources

  - ### setGlobalNamingResources

    public void setGlobalNamingResources(NamingResourcesImpl globalNamingResources)
    Description copied from interface: `Server`
    Set the global naming resources.
    Specified by:
      `setGlobalNamingResources` in interface `Server`
    Parameters:
      `globalNamingResources` - The new global naming resources

  - ### getServerInfo

    public String getServerInfo()
    Report the current Tomcat Server Release number
    Returns:
      Tomcat release identifier

  - ### getServerBuilt

    public String getServerBuilt()
    Return the current server built timestamp
    Returns:
      server built timestamp.

  - ### getServerNumber

    public String getServerNumber()
    Return the current server's version number.
    Returns:
      server's version number.

  - ### getPort

    public int getPort()
    Description copied from interface: `Server`
    Returns the port number on which the server listens for shutdown commands.
    Specified by:
      `getPort` in interface `Server`
    Returns:
      the port number for shutdown commands
    See Also:
      - `Server.getPortOffset()`
      - `Server.getPortWithOffset()`

  - ### setPort

    public void setPort(int port)
    Description copied from interface: `Server`
    Set the port number we listen to for shutdown commands.
    Specified by:
      `setPort` in interface `Server`
    Parameters:
      `port` - The new port number
    See Also:
      - `Server.setPortOffset(int)`

  - ### 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 interface `Server`
    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 interface `Server`
    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 interface `Server`
    Returns:
      the port with offset

  - ### getAddress

    public String getAddress()
    Description copied from interface: `Server`
    Returns the address on which the server listens for shutdown commands.
    Specified by:
      `getAddress` in interface `Server`
    Returns:
      the address for shutdown commands

  - ### setAddress

    public void setAddress(String address)
    Description copied from interface: `Server`
    Set the address on which we listen to for shutdown commands.
    Specified by:
      `setAddress` in interface `Server`
    Parameters:
      `address` - The new address

  - ### getShutdown

    public String getShutdown()
    Description copied from interface: `Server`
    Returns the shutdown command string the server is waiting for.
    Specified by:
      `getShutdown` in interface `Server`
    Returns:
      the shutdown command string

  - ### setShutdown

    public void setShutdown(String shutdown)
    Description copied from interface: `Server`
    Set the shutdown command we are waiting for.
    Specified by:
      `setShutdown` in interface `Server`
    Parameters:
      `shutdown` - The new shutdown command

  - ### getCatalina

    public Catalina getCatalina()
    Description copied from interface: `Server`
    Returns the outer Catalina startup/shutdown component, if one has been set.
    Specified by:
      `getCatalina` in interface `Server`
    Returns:
      the Catalina component, or `null` if not set

  - ### setCatalina

    public void setCatalina(Catalina catalina)
    Description copied from interface: `Server`
    Set the outer Catalina startup/shutdown component if present.
    Specified by:
      `setCatalina` in interface `Server`
    Parameters:
      `catalina` - the outer Catalina component

  - ### getUtilityThreads

    public int getUtilityThreads()
    Description copied from interface: `Server`
    Get the utility thread count.
    Specified by:
      `getUtilityThreads` in interface `Server`
    Returns:
      the thread count

  - ### setUtilityThreads

    public void setUtilityThreads(int utilityThreads)
    Description copied from interface: `Server`
    Set the utility thread count.
    Specified by:
      `setUtilityThreads` in interface `Server`
    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

    public void addService(Service service)
    Description copied from interface: `Server`
    Add a new Service to the set of defined Services.
    Specified by:
      `addService` in interface `Server`
    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

    public void await()
    Description copied from interface: `Server`
    Wait until a proper shutdown command is received, then return.
    Specified by:
      `await` in interface `Server`

  - ### findService

    public Service findService(String name)
    Description copied from interface: `Server`
    Find the specified Service
    Specified by:
      `findService` in interface `Server`
    Parameters:
      `name` - Name of the Service to be returned
    Returns:
      the specified Service, or `null` if none exists.

  - ### findServices

    public Service[] findServices()
    Description copied from interface: `Server`
    Returns the array of all Services defined within this Server.
    Specified by:
      `findServices` in interface `Server`
    Returns:
      the array of Services, or an empty array if none are defined

  - ### getServiceNames

    public ObjectName[] getServiceNames()
    Return the JMX ObjectNames for all configured services.
    Returns:
      the JMX service names.

  - ### removeService

    public void removeService(Service service)
    Description copied from interface: `Server`
    Remove the specified Service from the set associated from this Server.
    Specified by:
      `removeService` in interface `Server`
    Parameters:
      `service` - The Service to be removed

  - ### getCatalinaBase

    public File getCatalinaBase()
    Description copied from interface: `Server`
    Returns the configured base (instance) directory. If not set, the value from `Server.getCatalinaHome()` is used. Note that home and base may be the same (and are by default).
    Specified by:
      `getCatalinaBase` in interface `Server`
    Returns:
      the configured base directory

  - ### setCatalinaBase

    public void setCatalinaBase(File catalinaBase)
    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 interface `Server`
    Parameters:
      `catalinaBase` - the configured base directory

  - ### getCatalinaHome

    public File getCatalinaHome()
    Description copied from interface: `Server`
    Returns the configured home (binary) directory. Note that home and base may be the same (and are by default).
    Specified by:
      `getCatalinaHome` in interface `Server`
    Returns:
      the configured home directory

  - ### setCatalinaHome

    public void setCatalinaHome(File catalinaHome)
    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 interface `Server`
    Parameters:
      `catalinaHome` - the configured home directory

  - ### addPropertyChangeListener

    public void addPropertyChangeListener(PropertyChangeListener listener)
    Add a property change listener to this component.
    Parameters:
      `listener` - The listener to add

  - ### removePropertyChangeListener

    public void removePropertyChangeListener(PropertyChangeListener listener)
    Remove a property change listener from this component.
    Parameters:
      `listener` - The listener to remove

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### storeConfig

    public void storeConfig() throws InstanceNotFoundException, MBeanException
    Write the configuration information for this entire `Server` out to the server.xml configuration file.
    Throws:
      `InstanceNotFoundException` - if the managed resource object cannot be found
      `MBeanException` - if the initializer of the object throws an exception, or persistence is not supported
      `RuntimeOperationsException` - if an exception is reported by the persistence mechanism

  - ### storeContext

    public void storeContext(Context context) throws InstanceNotFoundException, MBeanException
    Write the configuration information for `Context` out to the specified configuration file.
    Parameters:
      `context` - the context which should save its configuration
    Throws:
      `InstanceNotFoundException` - if the managed resource object cannot be found
      `MBeanException` - if the initializer of the object throws an exception or persistence is not supported
      `RuntimeOperationsException` - if an exception is reported by the persistence mechanism

  - ### startInternal

    protected void startInternal() throws LifecycleException
    Description copied from class: `LifecycleBase`
    Subclasses must ensure that the state is changed to `LifecycleState.STARTING` during the execution of this method. Changing state will trigger the `Lifecycle.START_EVENT` event. If a component fails to start it may either throw a `LifecycleException` which will cause it's parent to fail to start, or it can place itself in the error state in which case `LifecycleBase.stop()` will be called on the failed component but the parent component will continue to start normally.
    Specified by:
      `startInternal` in class `LifecycleBase`
    Throws:
      `LifecycleException` - Start error occurred

  - ### stopInternal

    protected void stopInternal() throws LifecycleException
    Description copied from class: `LifecycleBase`
    Subclasses must ensure that the state is changed to `LifecycleState.STOPPING` during the execution of this method. Changing state will trigger the `Lifecycle.STOP_EVENT` event.
    Specified by:
      `stopInternal` in class `LifecycleBase`
    Throws:
      `LifecycleException` - Stop error occurred

  - ### initInternal

    protected void initInternal() throws LifecycleException
    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:
      `initInternal` in class `LifecycleMBeanBase`
    Throws:
      `LifecycleException` - If the initialisation fails

  - ### destroyInternal

    protected void destroyInternal() throws LifecycleException
    Description copied from class: `LifecycleBase`
    Subclasses implement this method to perform any instance destruction required.
    Overrides:
      `destroyInternal` in class `LifecycleMBeanBase`
    Throws:
      `LifecycleException` - If the destruction fails

  - ### getParentClassLoader

    public ClassLoader getParentClassLoader()
    Description copied from interface: `Server`
    Returns the parent class loader for this server component. If not explicitly set, returns the parent class loader from `Server.getCatalina()`. If Catalina has not been set, returns the system class loader.
    Specified by:
      `getParentClassLoader` in interface `Server`
    Returns:
      the parent class loader

  - ### setParentClassLoader

    public void setParentClassLoader(ClassLoader parent)
    Description copied from interface: `Server`
    Set the parent class loader for this server.
    Specified by:
      `setParentClassLoader` in interface `Server`
    Parameters:
      `parent` - The new parent class loader

  - ### getDomainInternal

    protected String getDomainInternal()
    Description copied from class: `LifecycleMBeanBase`
    Method implemented by subclasses to identify the domain in which MBeans should be registered.
    Specified by:
      `getDomainInternal` in class `LifecycleMBeanBase`
    Returns:
      the MBean domain for this server. The domain is obtained using the following search order:
      1. Name of first `Engine`.
      2. Name of first `Service`.

  - ### getObjectNameKeyProperties

    protected String getObjectNameKeyProperties()
    Description copied from class: `LifecycleMBeanBase`
    Allow subclasses to specify the key properties component of the `ObjectName` that will be used to register this component.
    Specified by:
      `getObjectNameKeyProperties` in class `LifecycleMBeanBase`
    Returns:
      The string representation of the key properties component of the desired `ObjectName`

  - ### getUtilityExecutor

    public ScheduledExecutorService getUtilityExecutor()
    Description copied from interface: `Server`
    Returns the utility executor managed by the server for background tasks.
    Specified by:
      `getUtilityExecutor` in interface `Server`
    Returns:
      the utility executor service