org.eclipse.jetty.server

## Class Server

- java.lang.Object
- - org.eclipse.jetty.util.component.AbstractLifeCycle
  - - org.eclipse.jetty.util.component.AggregateLifeCycle
    - - org.eclipse.jetty.server.handler.AbstractHandler
      - - org.eclipse.jetty.server.handler.AbstractHandlerContainer
        - - org.eclipse.jetty.server.handler.HandlerWrapper
          - - org.eclipse.jetty.server.Server

- All Implemented Interfaces:
    Handler, HandlerContainer, Attributes, Destroyable, Dumpable, LifeCycle

      public class Server
      extends HandlerWrapper
      implements Attributes

  Jetty HTTP Servlet Server. This class is the main class for the Jetty HTTP Servlet server. It aggregates Connectors (HTTP request receivers) and request Handlers. The server is itself a handler and a ThreadPool. Connectors use the ThreadPool methods to run jobs that will eventually call the handle method.
  Apache XBean:
    description="Creates an embedded Jetty web server"

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `Server.Graceful`

    - ### Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

      `AbstractLifeCycle.AbstractLifeCycleListener`

    - ### Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

      `LifeCycle.Listener`

  - ### Field Summary

    - ### Fields inherited from class org.eclipse.jetty.server.handler.HandlerWrapper

      `_handler`

    - ### Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

      `_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Server()`
    `Server(InetSocketAddress addr)` Convenience constructor Creates server and a `SelectChannelConnector` at the passed address.
    `Server(int port)` Convenience constructor Creates server and a `SelectChannelConnector` at the passed port.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `addBean(Object o)` Add an associated bean.
    `void` | `addConnector(Connector connector)`
    `void` | `addLifeCycle(LifeCycle c)` Deprecated. Use `addBean(Object)`
    `void` | `clearAttributes()`
    `protected void` | `doStart()` Start the managed lifecycle beans in the order they were added.
    `protected void` | `doStop()` Stop the joined lifecycle beans in the reverse order they were added.
    `void` | `dump(Appendable out, String indent)`
    `Object` | `getAttribute(String name)`
    `Enumeration` | `getAttributeNames()`
    `Connector[]` | `getConnectors()`
    `Container` | `getContainer()`
    `int` | `getGracefulShutdown()`
    `int` | `getMaxCookieVersion()` Deprecated.
    `boolean` | `getSendDateHeader()`
    `boolean` | `getSendServerVersion()`
    `SessionIdManager` | `getSessionIdManager()`
    `boolean` | `getStopAtShutdown()`
    `ThreadPool` | `getThreadPool()`
    `static String` | `getVersion()`
    `void` | `handle(AbstractHttpConnection connection)`
    `void` | `handleAsync(AbstractHttpConnection connection)`
    `boolean` | `isDumpAfterStart()`
    `boolean` | `isDumpBeforeStop()`
    `boolean` | `isUncheckedPrintWriter()`
    `void` | `join()`
    `static void` | `main(String... args)`
    `void` | `removeAttribute(String name)`
    `boolean` | `removeBean(Object o)` Remove an associated bean.
    `void` | `removeConnector(Connector connector)` Conveniance method which calls `getConnectors()` and `setConnectors(Connector[])` to remove a connector.
    `void` | `removeLifeCycle(LifeCycle c)` Deprecated. Use `removeBean(Object)`
    `void` | `setAttribute(String name, Object attribute)`
    `void` | `setConnectors(Connector[] connectors)` Set the connectors for this server.
    `void` | `setDumpAfterStart(boolean dumpAfterStart)`
    `void` | `setDumpBeforeStop(boolean dumpBeforeStop)`
    `void` | `setGracefulShutdown(int timeoutMS)` Set graceful shutdown timeout.
    `void` | `setMaxCookieVersion(int maxCookieVersion)` Deprecated.
    `void` | `setSendDateHeader(boolean sendDateHeader)`
    `void` | `setSendServerVersion(boolean sendServerVersion)`
    `void` | `setSessionIdManager(SessionIdManager sessionIdManager)`
    `void` | `setStopAtShutdown(boolean stop)`
    `void` | `setThreadPool(ThreadPool threadPool)`
    `void` | `setUncheckedPrintWriter(boolean unchecked)`
    `String` | `toString()`

    - ### Methods inherited from class org.eclipse.jetty.server.handler.HandlerWrapper

      `destroy, expandChildren, getHandler, getHandlers, getNestedHandlerByClass, handle, setHandler, setServer`

    - ### Methods inherited from class org.eclipse.jetty.server.handler.AbstractHandlerContainer

      `expandHandler, findContainerOf, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass`

    - ### Methods inherited from class org.eclipse.jetty.server.handler.AbstractHandler

      `dumpThis, getServer`

    - ### Methods inherited from class org.eclipse.jetty.util.component.AggregateLifeCycle

      `addBean, contains, dump, dump, dump, dump, dumpObject, dumpStdErr, getBean, getBeans, getBeans, isManaged, manage, removeBeans, unmanage`

    - ### Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

      `addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop`

    - ### Methods inherited from class java.lang.Object

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

    - ### Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle

      `addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop`

- - ### Constructor Detail

    - #### Server

          public Server()

    - #### Server

          public Server(int port)

      Convenience constructor Creates server and a `SelectChannelConnector` at the passed port.

    - #### Server

          public Server(InetSocketAddress addr)

      Convenience constructor Creates server and a `SelectChannelConnector` at the passed address.

  - ### Method Detail

    - #### getVersion

          public static String getVersion()

    - #### getContainer

          public Container getContainer()

      Returns:
        Returns the container.

    - #### getStopAtShutdown

          public boolean getStopAtShutdown()

    - #### setStopAtShutdown

          public void setStopAtShutdown(boolean stop)

    - #### getConnectors

          public Connector[] getConnectors()

      Returns:
        Returns the connectors.

    - #### addConnector

          public void addConnector(Connector connector)

    - #### removeConnector

          public void removeConnector(Connector connector)

      Conveniance method which calls `getConnectors()` and `setConnectors(Connector[])` to remove a connector.
      Parameters:
        `connector` - The connector to remove.

    - #### setConnectors

          public void setConnectors(Connector[] connectors)

      Set the connectors for this server. Each connector has this server set as it's ThreadPool and its Handler.
      Parameters:
        `connectors` - The connectors to set.

    - #### getThreadPool

          public ThreadPool getThreadPool()

      Returns:
        Returns the threadPool.

    - #### setThreadPool

          public void setThreadPool(ThreadPool threadPool)

      Parameters:
        `threadPool` - The threadPool to set.

    - #### isDumpAfterStart

          public boolean isDumpAfterStart()

      Returns:
        true if `AggregateLifeCycle.dumpStdErr()` is called after starting

    - #### setDumpAfterStart

          public void setDumpAfterStart(boolean dumpAfterStart)

      Parameters:
        `dumpAfterStart` - true if `AggregateLifeCycle.dumpStdErr()` is called after starting

    - #### isDumpBeforeStop

          public boolean isDumpBeforeStop()

      Returns:
        true if `AggregateLifeCycle.dumpStdErr()` is called before stopping

    - #### setDumpBeforeStop

          public void setDumpBeforeStop(boolean dumpBeforeStop)

      Parameters:
        `dumpBeforeStop` - true if `AggregateLifeCycle.dumpStdErr()` is called before stopping

    - #### doStart

          protected void doStart()
                          throws Exception

      Description copied from class: `AggregateLifeCycle`
      Start the managed lifecycle beans in the order they were added.
      Overrides:
        `doStart` in class `HandlerWrapper`
      Throws:
        `Exception`
      See Also:
        `AbstractLifeCycle.doStart()`

    - #### doStop

          protected void doStop()
                         throws Exception

      Description copied from class: `AggregateLifeCycle`
      Stop the joined lifecycle beans in the reverse order they were added.
      Overrides:
        `doStop` in class `HandlerWrapper`
      Throws:
        `Exception`
      See Also:
        `AbstractLifeCycle.doStart()`

    - #### handle

          public void handle(AbstractHttpConnection connection)
                      throws IOException,
                             javax.servlet.ServletException

      Throws:
        `IOException`
        `javax.servlet.ServletException`

    - #### handleAsync

          public void handleAsync(AbstractHttpConnection connection)
                           throws IOException,
                                  javax.servlet.ServletException

      Throws:
        `IOException`
        `javax.servlet.ServletException`

    - #### join

          public void join()
                    throws InterruptedException

      Throws:
        `InterruptedException`

    - #### getSessionIdManager

          public SessionIdManager getSessionIdManager()

      Returns:
        Returns the sessionIdManager.

    - #### setSessionIdManager

          public void setSessionIdManager(SessionIdManager sessionIdManager)

      Parameters:
        `sessionIdManager` - The sessionIdManager to set.

    - #### setSendServerVersion

          public void setSendServerVersion(boolean sendServerVersion)

    - #### getSendServerVersion

          public boolean getSendServerVersion()

    - #### setSendDateHeader

          public void setSendDateHeader(boolean sendDateHeader)

      Parameters:
        `sendDateHeader` -

    - #### getSendDateHeader

          public boolean getSendDateHeader()

    - #### getMaxCookieVersion

          @Deprecated
          public int getMaxCookieVersion()

      Deprecated.

    - #### setMaxCookieVersion

          @Deprecated
          public void setMaxCookieVersion(int maxCookieVersion)

      Deprecated.

    - #### addLifeCycle

          @Deprecated
          public void addLifeCycle(LifeCycle c)

      Deprecated. Use `addBean(Object)`
      Add a LifeCycle object to be started/stopped along with the Server.
      Parameters:
        `c` -

    - #### addBean

          public boolean addBean(Object o)

      Add an associated bean. The bean will be added to the servers `Container` and if it is a `LifeCycle` instance, it will be started/stopped along with the Server. Any beans that are also `Destroyable`, will be destroyed with the server.
      Overrides:
        `addBean` in class `AggregateLifeCycle`
      Parameters:
        `o` - the bean object to add
      Returns:
        true if the bean was added or false if it has already been added.

    - #### removeLifeCycle

          @Deprecated
          public void removeLifeCycle(LifeCycle c)

      Deprecated. Use `removeBean(Object)`
      Remove a LifeCycle object to be started/stopped along with the Server

    - #### removeBean

          public boolean removeBean(Object o)

      Remove an associated bean.
      Overrides:
        `removeBean` in class `AggregateLifeCycle`

    - #### clearAttributes

          public void clearAttributes()

      Specified by:
        `clearAttributes` in interface `Attributes`

    - #### getAttribute

          public Object getAttribute(String name)

      Specified by:
        `getAttribute` in interface `Attributes`

    - #### getAttributeNames

          public Enumeration getAttributeNames()

      Specified by:
        `getAttributeNames` in interface `Attributes`

    - #### removeAttribute

          public void removeAttribute(String name)

      Specified by:
        `removeAttribute` in interface `Attributes`

    - #### setAttribute

          public void setAttribute(String name,
                          Object attribute)

      Specified by:
        `setAttribute` in interface `Attributes`

    - #### getGracefulShutdown

          public int getGracefulShutdown()

      Returns:
        the graceful

    - #### setGracefulShutdown

          public void setGracefulShutdown(int timeoutMS)

      Set graceful shutdown timeout. If set, the internal `doStop()` method will not immediately stop the server. Instead, all `Connector`s will be closed so that new connections will not be accepted and all handlers that implement `Server.Graceful` will be put into the shutdown mode so that no new requests will be accepted, but existing requests can complete. The server will then wait the configured timeout before stopping.
      Parameters:
        `timeoutMS` - the milliseconds to wait for existing request to complete before stopping the server.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### dump

          public void dump(Appendable out,
                  String indent)
                    throws IOException

      Specified by:
        `dump` in interface `Dumpable`
      Overrides:
        `dump` in class `AbstractHandlerContainer`
      Throws:
        `IOException`

    - #### isUncheckedPrintWriter

          public boolean isUncheckedPrintWriter()

    - #### setUncheckedPrintWriter

          public void setUncheckedPrintWriter(boolean unchecked)

    - #### main

          public static void main(String... args)
                           throws Exception

      Throws:
        `Exception`

Copyright © 1995-2015 Mort Bay Consulting. All Rights Reserved.