Server (Apache Tomcat 8.5.57 API Documentation)

org.apache.catalina

## Interface Server

- All Superinterfaces:
    Lifecycle
  All Known Implementing Classes:
    StandardServer

      public interface Server
      extends Lifecycle

  A `Server` element represents the entire Catalina servlet container. Its attributes represent the characteristics of the servlet container as a whole. A `Server` may contain one or more `Services`, and the top level set of naming resources.

  Normally, an implementation of this interface will also implement `Lifecycle`, such that when the `start()` and `stop()` methods are called, all of the defined `Services` are also started or stopped.

  In between, the implementation must open a server socket on the port number specified by the `port` property. When a connection is accepted, the first line is read and compared with the specified shutdown command. If the command matches, shutdown of the server is initiated.

  NOTE - The concrete implementation of this class should register the (singleton) instance with the `ServerFactory` class in its constructor(s).

  Author:
    Craig R. McClanahan

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.apache.catalina.Lifecycle

      `Lifecycle.SingleUse`

  - ### Field Summary

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

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `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.
    `Service` | `findService(String name)` Find the specified Service
    `Service[]` | `findServices()`
    `String` | `getAddress()`
    `Catalina` | `getCatalina()`
    `File` | `getCatalinaBase()`
    `File` | `getCatalinaHome()`
    `Context` | `getGlobalNamingContext()`
    `NamingResourcesImpl` | `getGlobalNamingResources()`
    `Object` | `getNamingToken()`
    `ClassLoader` | `getParentClassLoader()`
    `int` | `getPort()`
    `String` | `getShutdown()`
    `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` | `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` | `setShutdown(String shutdown)` Set the shutdown command we are waiting for.

    - ### Methods inherited from interface org.apache.catalina.Lifecycle

      `addLifecycleListener, destroy, findLifecycleListeners, getState, getStateName, init, removeLifecycleListener, start, stop`

- - ### Method Detail

    - #### getGlobalNamingResources

          NamingResourcesImpl getGlobalNamingResources()

      Returns:
        the global naming resources.

    - #### setGlobalNamingResources

          void setGlobalNamingResources(NamingResourcesImpl globalNamingResources)

      Set the global naming resources.
      Parameters:
        `globalNamingResources` - The new global naming resources

    - #### getGlobalNamingContext

          Context getGlobalNamingContext()

      Returns:
        the global naming resources context.

    - #### getPort

          int getPort()

      Returns:
        the port number we listen to for shutdown commands.

    - #### setPort

          void setPort(int port)

      Set the port number we listen to for shutdown commands.
      Parameters:
        `port` - The new port number

    - #### getAddress

          String getAddress()

      Returns:
        the address on which we listen to for shutdown commands.

    - #### setAddress

          void setAddress(String address)

      Set the address on which we listen to for shutdown commands.
      Parameters:
        `address` - The new address

    - #### getShutdown

          String getShutdown()

      Returns:
        the shutdown command string we are waiting for.

    - #### setShutdown

          void setShutdown(String shutdown)

      Set the shutdown command we are waiting for.
      Parameters:
        `shutdown` - The new shutdown command

    - #### getParentClassLoader

          ClassLoader getParentClassLoader()

      Returns:
        the parent class loader for this component. If not set, return `getCatalina()` `Catalina.getParentClassLoader()`. If catalina has not been set, return the system class loader.

    - #### setParentClassLoader

          void setParentClassLoader(ClassLoader parent)

      Set the parent class loader for this server.
      Parameters:
        `parent` - The new parent class loader

    - #### getCatalina

          Catalina getCatalina()

      Returns:
        the outer Catalina startup/shutdown component if present.

    - #### setCatalina

          void setCatalina(Catalina catalina)

      Set the outer Catalina startup/shutdown component if present.
      Parameters:
        `catalina` - the outer Catalina component

    - #### getCatalinaBase

          File getCatalinaBase()

      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 `getCatalinaHome()` will be used.

    - #### setCatalinaBase

          void setCatalinaBase(File catalinaBase)

      Set the configured base (instance) directory. Note that home and base may be the same (and are by default).
      Parameters:
        `catalinaBase` - the configured base directory

    - #### getCatalinaHome

          File getCatalinaHome()

      Returns:
        the configured home (binary) directory. Note that home and base may be the same (and are by default).

    - #### setCatalinaHome

          void setCatalinaHome(File catalinaHome)

      Set the configured home (binary) directory. Note that home and base may be the same (and are by default).
      Parameters:
        `catalinaHome` - the configured home directory

    - #### addService

          void addService(Service service)

      Add a new Service to the set of defined Services.
      Parameters:
        `service` - The Service to be added

    - #### await

          void await()

      Wait until a proper shutdown command is received, then return.

    - #### findService

          Service findService(String name)

      Find the specified Service
      Parameters:
        `name` - Name of the Service to be returned
      Returns:
        the specified Service, or `null` if none exists.

    - #### findServices

          Service[] findServices()

      Returns:
        the set of Services defined within this Server.

    - #### removeService

          void removeService(Service service)

      Remove the specified Service from the set associated from this Server.
      Parameters:
        `service` - The Service to be removed

    - #### getNamingToken

          Object getNamingToken()

      Returns:
        the token necessary for operations on the associated JNDI naming context.

Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.