- All Known Implementing Classes:
Server.Base
public interface Server
Web server contract. Defines operations to start, join and stop a web server. Jooby comes with
three web server implementation: Jetty, Netty and Undertow.
A web server is automatically discovered using the Java Service Loader API. All you need is to add the server dependency to your project classpath.
When service loader is not an option or do you want to manually bootstrap a server:
Server server = new NettyServer(); // or JettyServer or UndertowServer
App app = new App();
server.start(app);
...
server.stop();
- Since:
- 2.0.0
- Author:
- edgar
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addAddressInUse
(Predicate<Throwable> predicate) Add an address in use predicate.static void
addConnectionLost
(Predicate<Throwable> predicate) Add a connection lost predicate.static boolean
connectionLost
(Throwable cause) Test whenever the given exception is a connection-lost.Utility method to turn off odd logger.getName()
Get server name.Get server options.static boolean
isAddressInUse
(Throwable cause) Whenever the given exception is an address already in use.setOptions
(ServerOptions options) Set server options.Start an application.stop()
Stop the server.
-
Method Details
-
setOptions
Set server options.- Parameters:
options
- Server options.- Returns:
- This server.
-
getName
Get server name.- Returns:
- Server name.
-
getOptions
Get server options.- Returns:
- Server options.
-
start
Start an application.- Parameters:
application
- Application to start.- Returns:
- This server.
-
getLoggerOff
Utility method to turn off odd logger. This help to ensure same startup log lines across server implementations.These logs are silent at application startup time.
- Returns:
- Name of the logs we want to temporarily silent.
-
stop
Stop the server.- Returns:
- Stop the server.
-
addConnectionLost
Add a connection lost predicate. On unexpected exception, this method allows to customize which error are considered connection lost. If the error is considered a connection lost, no log statement will be emitted by the application.- Parameters:
predicate
- Customize connection lost error.
-
addAddressInUse
Add an address in use predicate. On unexpected exception, this method allows to customize which error are considered address in use. If the error is considered an address in use, no log statement will be emitted by the application.- Parameters:
predicate
- Customize connection lost error.
-
connectionLost
Test whenever the given exception is a connection-lost. Connection-lost exceptions don't generate log.error statements.- Parameters:
cause
- Exception to check.- Returns:
- True for connection lost.
-
isAddressInUse
Whenever the given exception is an address already in use. This probably won't work in none English locale systems.- Parameters:
cause
- Exception to check.- Returns:
- True address already in use.
-