Package play.server
Class Server
- Object
-
- play.server.Server
-
public class Server extends Object
A Play server.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Server.Builder
Configures and builds an embedded server.static class
Server.Protocol
Specifies the protocols supported by the server.
-
Constructor Summary
Constructors Constructor Description Server(play.core.server.Server server)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Server
forRouter(int port, Function<BuiltInComponents,Router> block)
Create a server for the given router.static Server
forRouter(Function<BuiltInComponents,Router> block)
Create a server for the given router.static Server
forRouter(Mode mode, int port, Function<BuiltInComponents,Router> block)
Create a server for the router returned by the given block.static Server
forRouter(Mode mode, Function<BuiltInComponents,Router> block)
Create a server for the given router.int
httpPort()
Get the HTTP port the server is running on.int
httpsPort()
Get the HTTPS port the server is running on.InetSocketAddress
mainAddress()
Get the address the server is running on.void
stop()
Stop the server.play.core.server.Server
underlying()
-
-
-
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.
-
-