Package play.server

Class Server


  • public class Server
    extends Object
    A Play server.
    • Constructor Detail

      • Server

        public Server​(play.core.server.Server server)
    • Method Detail

      • underlying

        public play.core.server.Server underlying()
        Returns:
        the underlying server.
      • stop

        public void stop()
        Stop the server.
      • httpPort

        public int httpPort()
        Get the HTTP port the server is running on.
        Returns:
        the port number.
        Throws:
        IllegalStateException - if it is not running on the HTTP protocol
      • httpsPort

        public int httpsPort()
        Get the HTTPS port the server is running on.
        Returns:
        the port number.
        Throws:
        IllegalStateException - if it is not running on the HTTPS protocol.
      • mainAddress

        public InetSocketAddress mainAddress()
        Get the address the server is running on.
        Returns:
        the address
      • forRouter

        public static Server forRouter​(Function<BuiltInComponents,​Router> block)
        Create a server for the given router.

        The server will be running on a randomly selected ephemeral port, which can be checked using the httpPort property.

        The server will be running in TEST mode.

        Parameters:
        block - The block that creates the router.
        Returns:
        The running server.
      • forRouter

        public static Server forRouter​(Mode mode,
                                       Function<BuiltInComponents,​Router> block)
        Create a server for the given router.

        The server will be running on a randomly selected ephemeral port, which can be checked using the httpPort property.

        The server will be running in TEST mode.

        Parameters:
        mode - The mode the server will run on.
        block - The block that creates the router.
        Returns:
        The running server.
      • forRouter

        public static Server forRouter​(int port,
                                       Function<BuiltInComponents,​Router> block)
        Create a server for the given router.

        The server will be running on a randomly selected ephemeral port, which can be checked using the httpPort property.

        The server will be running in TEST mode.

        Parameters:
        port - The port the server will run on.
        block - The block that creates the router.
        Returns:
        The running server.
      • forRouter

        public static Server forRouter​(Mode mode,
                                       int port,
                                       Function<BuiltInComponents,​Router> block)
        Create a server for the router returned by the given block.
        Parameters:
        block - The block which creates a router.
        mode - The mode the server will run on.
        port - The port the server will run on.
        Returns:
        The running server.