Package fr.gouv.vitam.common.server

# Class BasicVitamServer

java.lang.Object
fr.gouv.vitam.common.server.BasicVitamServer

All Implemented Interfaces:
  `VitamServer`, `VitamServerInterface`

public class BasicVitamServer extends Object implements VitamServer
Basic implementation of a vitam server using embedded jetty as underlying app server

- ## Field Summary

  ### Fields inherited from interface fr.gouv.vitam.common.server.VitamServer

  `CAN_CONFIGURE_SERVER, CONFIG_FILE_IS_A_MANDATORY_ARGUMENT, CONFIGURATION_IS_A_MANDATORY_ARGUMENT, SERVER_CAN_NOT_START, SERVER_START_WITH_JETTY_CONFIG`

  ### Fields inherited from interface fr.gouv.vitam.common.server.VitamServerInterface

  `ADMIN_CONNECTOR_NAME, BUSINESS_CONNECTOR_NAME`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `BasicVitamServer(int port)`
  A Vitam server can only be instantiated with a given port to listen to
  `protected`
  `BasicVitamServer(int port, boolean withConnector)`
  `protected`
  `BasicVitamServer(String jettyConfigPath)`
  A Vitam server can be instantiated with a jetty xml configuration file.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `configure(org.eclipse.jetty.server.Handler applicationHandler)`
  Configure the server with one handler
  `int`
  `getAdminPort()`
  Retrieving all ports of the vitam server.
  `org.eclipse.jetty.server.Handler`
  `getHandler()`
  retrieving the handler
  `int`
  `getPort()`
  Retrieving the vitam server port. If the server is started, this returns the real port used.
  `org.eclipse.jetty.server.Server`
  `getServer()`
  Retrieving the underlying jetty server is restricted to sub-implementations only
  `org.eclipse.jetty.xml.XmlConfiguration`
  `getServerConfiguration()`
  Retrieving the server jetty configuration
  `VitamThreadPoolExecutor`
  `getVitamThreadPoolExecutor()`
  `boolean`
  `isConfigured()`
  check if is configured
  `boolean`
  `isStarted()`
  check if vitam server is started
  `boolean`
  `isStopped()`
  check if vitam server is stopped
  `protected void`
  `setConfigured(boolean configured)`
  setter configured status
  `void`
  `setHandler(org.eclipse.jetty.server.Handler handler)`
  setter of the handler
  `void`
  `start()`
  For Junit tests, starts only, not join
  `void`
  `startAndJoin()`
  Start the server with implicit Join
  `void`
  `stop()`
  For Junit tests, stops the server

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

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

- ## Constructor Details

  - ### BasicVitamServer

    protected BasicVitamServer(int port, boolean withConnector)

  - ### BasicVitamServer

    protected BasicVitamServer(int port)
    A Vitam server can only be instantiated with a given port to listen to
    Parameters:
      `port` - the port to listen to (must be a valid logical port number)
    Throws:
      `IllegalArgumentException` - if port <= 0

  - ### BasicVitamServer

    protected BasicVitamServer(String jettyConfigPath) throws VitamApplicationServerException
    A Vitam server can be instantiated with a jetty xml configuration file. This configuration file can be in : - /vitam/conf, - resource folder - resource in classpath
    Parameters:
      `jettyConfigPath` - configuration file of jetty server
    Throws:
      `VitamApplicationServerException` - if configuration not found, can't be parsed, can't be read or server can't started

- ## Method Details

  - ### configure

    public void configure(org.eclipse.jetty.server.Handler applicationHandler) throws VitamApplicationServerException
    Description copied from interface: `VitamServer`
    Configure the server with one handler
    Specified by:
      `configure` in interface `VitamServer`
    Parameters:
      `applicationHandler` -
    Throws:
      `VitamApplicationServerException`

  - ### startAndJoin

    public void startAndJoin() throws VitamApplicationServerException
    Description copied from interface: `VitamServer`
    Start the server with implicit Join
    Specified by:
      `startAndJoin` in interface `VitamServer`
    Throws:
      `VitamApplicationServerException`

  - ### start

    public void start() throws VitamApplicationServerException
    For Junit tests, starts only, not join
    Specified by:
      `start` in interface `VitamServer`
    Throws:
      `VitamApplicationServerException`

  - ### stop

    public void stop() throws VitamApplicationServerException
    For Junit tests, stops the server
    Specified by:
      `stop` in interface `VitamServer`
    Throws:
      `VitamApplicationServerException`

  - ### getServer

    public org.eclipse.jetty.server.Server getServer()
    Retrieving the underlying jetty server is restricted to sub-implementations only
    Specified by:
      `getServer` in interface `VitamServer`
    Returns:
      the underlying jetty server

  - ### getServerConfiguration

    public org.eclipse.jetty.xml.XmlConfiguration getServerConfiguration()
    Retrieving the server jetty configuration
    Specified by:
      `getServerConfiguration` in interface `VitamServer`
    Returns:
      XmlConfiguration

  - ### isStarted

    public boolean isStarted()
    check if vitam server is started
    Specified by:
      `isStarted` in interface `VitamServer`
    Returns:
      true if jetty server is started

  - ### isStopped

    public boolean isStopped()
    check if vitam server is stopped
    Specified by:
      `isStopped` in interface `VitamServer`
    Returns:
      true if jetty server is stopped

  - ### getPort

    public int getPort()
    Retrieving the vitam server port. If the server is started, this returns the real port used. If not, returns the supposely configured one.
    Specified by:
      `getPort` in interface `VitamServerInterface`
    Returns:
      the vitam server port

  - ### getAdminPort

    public int getAdminPort()
    Retrieving all ports of the vitam server.
    Specified by:
      `getAdminPort` in interface `VitamServerInterface`
    Returns:
      the vitam server port

  - ### isConfigured

    public boolean isConfigured()
    check if is configured
    Specified by:
      `isConfigured` in interface `VitamServer`
    Returns:
      true if it is configured

  - ### setConfigured

    protected void setConfigured(boolean configured)
    setter configured status
    Parameters:
      `configured` - configured status

  - ### getHandler

    public org.eclipse.jetty.server.Handler getHandler()
    retrieving the handler
    Specified by:
      `getHandler` in interface `VitamServer`
    Returns:
      the handler

  - ### setHandler

    public void setHandler(org.eclipse.jetty.server.Handler handler)
    setter of the handler
    Specified by:
      `setHandler` in interface `VitamServer`
    Parameters:
      `handler` - the handler to set

  - ### getVitamThreadPoolExecutor

    public VitamThreadPoolExecutor getVitamThreadPoolExecutor()
    Returns:
      the VitamThreadPoolExecutor used by the server