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 classServer.BuilderConfigures and builds an embedded server.static classServer.ProtocolSpecifies 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 ServerforRouter(int port, Function<BuiltInComponents,Router> block)Create a server for the given router.static ServerforRouter(Function<BuiltInComponents,Router> block)Create a server for the given router.static ServerforRouter(Mode mode, int port, Function<BuiltInComponents,Router> block)Create a server for the router returned by the given block.static ServerforRouter(Mode mode, Function<BuiltInComponents,Router> block)Create a server for the given router.inthttpPort()Get the HTTP port the server is running on.inthttpsPort()Get the HTTPS port the server is running on.InetSocketAddressmainAddress()Get the address the server is running on.voidstop()Stop the server.play.core.server.Serverunderlying()
-
-
-
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.
-
-