Package net.officefloor.server.http
Class HttpServer
- java.lang.Object
-
- net.officefloor.server.http.HttpServer
-
public class HttpServer extends java.lang.Object
HTTP Server.- Author:
- Daniel Sagenschneider
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_HTTP_SERVER_IMPLEMENTATION_CLASS_NAME
Class
name of the defaultHttpServerImplementation
.static java.lang.String
PROPERTY_HTTP_DATE_HEADER
static java.lang.String
PROPERTY_HTTP_SERVER_NAME
static java.lang.String
PROPERTY_INCLUDE_STACK_TRACE
Name ofProperty
to include the stack trace.static java.lang.String
PROPERTY_SSL_CONTEXT_SOURCE
Name ofProperty
for theSslContextSource
.static java.lang.String
SSL_REVERSE_PROXIED
Value forPROPERTY_SSL_CONTEXT_SOURCE
to indicate that this server is behind a reverse proxy.
-
Constructor Summary
Constructors Constructor Description HttpServer(DeployedOfficeInput serviceInput, OfficeFloorDeployer officeFloorDeployer, OfficeFloorSourceContext context)
Instantiates theHttpServer
from configuration.HttpServer(HttpServerImplementation implementation, HttpServerLocation serverLocation, java.lang.String serverName, DateHttpHeaderClock dateHttpHeaderClock, boolean isIncludeEscalationStackTrace, javax.net.ssl.SSLContext sslContext, DeployedOfficeInput serviceInput, OfficeFloorDeployer officeFloorDeployer, OfficeFloorSourceContext context)
Instantiates theHttpServer
from direct configuration.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description HttpServerImplementation
getHttpServerImplementation()
Obtains theHttpServerImplementation
.HttpServerLocation
getHttpServerLocation()
Obtains theHttpServerLocation
.static int
getPropertyInteger(java.lang.String propertyName, SourceContext context, java.util.function.Supplier<java.lang.Integer> defaultValue)
Obtains theProperty
value.static java.lang.String
getPropertyString(java.lang.String propertyName, SourceContext context, java.util.function.Supplier<java.lang.String> defaultValue)
Obtains theProperty
value.static HttpHeaderValue
getServerHttpHeaderValue(HttpServerImplementationContext context, java.lang.String suffix)
Convenience method to obtain theServer
HttpHeaderValue
.javax.net.ssl.SSLContext
getSslContext()
Obtains theSSLContext
.static javax.net.ssl.SSLContext
getSslContext(SourceContext context)
Obtains theSSLContext
from configuration.
-
-
-
Field Detail
-
PROPERTY_HTTP_SERVER_NAME
public static final java.lang.String PROPERTY_HTTP_SERVER_NAME
- See Also:
- Constant Field Values
-
PROPERTY_HTTP_DATE_HEADER
public static final java.lang.String PROPERTY_HTTP_DATE_HEADER
- See Also:
- Constant Field Values
-
PROPERTY_INCLUDE_STACK_TRACE
public static final java.lang.String PROPERTY_INCLUDE_STACK_TRACE
Name ofProperty
to include the stack trace.- See Also:
- Constant Field Values
-
PROPERTY_SSL_CONTEXT_SOURCE
public static final java.lang.String PROPERTY_SSL_CONTEXT_SOURCE
Name ofProperty
for theSslContextSource
.- See Also:
- Constant Field Values
-
SSL_REVERSE_PROXIED
public static final java.lang.String SSL_REVERSE_PROXIED
Value forPROPERTY_SSL_CONTEXT_SOURCE
to indicate that this server is behind a reverse proxy. This enables the reverse proxy to handle SSL and communicate with this server via insecureSocket
(but stll appear as a secureServerHttpConnection
).- See Also:
- Constant Field Values
-
DEFAULT_HTTP_SERVER_IMPLEMENTATION_CLASS_NAME
public static java.lang.String DEFAULT_HTTP_SERVER_IMPLEMENTATION_CLASS_NAME
Class
name of the defaultHttpServerImplementation
.
-
-
Constructor Detail
-
HttpServer
public HttpServer(DeployedOfficeInput serviceInput, OfficeFloorDeployer officeFloorDeployer, OfficeFloorSourceContext context) throws java.lang.Exception
Instantiates theHttpServer
from configuration.- Parameters:
serviceInput
-DeployedOfficeInput
servicing theServerHttpConnection
.officeFloorDeployer
-OfficeFloorDeployer
.context
-OfficeFloorSourceContext
.- Throws:
java.lang.Exception
- If fails to create theHttpServer
from configuration.
-
HttpServer
public HttpServer(HttpServerImplementation implementation, HttpServerLocation serverLocation, java.lang.String serverName, DateHttpHeaderClock dateHttpHeaderClock, boolean isIncludeEscalationStackTrace, javax.net.ssl.SSLContext sslContext, DeployedOfficeInput serviceInput, OfficeFloorDeployer officeFloorDeployer, OfficeFloorSourceContext context) throws java.lang.Exception
Instantiates theHttpServer
from direct configuration.- Parameters:
implementation
-HttpServerImplementation
.serverLocation
-HttpServerLocation
.serverName
- Server name. May benull
.dateHttpHeaderClock
-DateHttpHeaderClock
. May benull
.isIncludeEscalationStackTrace
- Indicates whether to includeEscalation
stack trace inHttpResponse
.sslContext
-SSLContext
.serviceInput
-DeployedOfficeInput
servicing theServerHttpConnection
.officeFloorDeployer
-OfficeFloorDeployer
.context
-OfficeFloorSourceContext
.- Throws:
java.lang.Exception
- If fails to configure theHttpServerImplementation
.
-
-
Method Detail
-
getPropertyString
public static java.lang.String getPropertyString(java.lang.String propertyName, SourceContext context, java.util.function.Supplier<java.lang.String> defaultValue)
Obtains theProperty
value.- Parameters:
propertyName
- Name ofProperty
.context
-SourceContext
.defaultValue
-Supplier
of the default value.- Returns:
- Value for the
Property
.
-
getPropertyInteger
public static int getPropertyInteger(java.lang.String propertyName, SourceContext context, java.util.function.Supplier<java.lang.Integer> defaultValue)
Obtains theProperty
value.- Parameters:
propertyName
- Name ofProperty
.context
-SourceContext
.defaultValue
-Supplier
of the default value.- Returns:
- Value for the
Property
.
-
getSslContext
public static javax.net.ssl.SSLContext getSslContext(SourceContext context) throws java.lang.Exception
Obtains theSSLContext
from configuration.- Parameters:
context
-SourceContext
.- Returns:
SSLContext
.- Throws:
java.lang.Exception
- If fails to load theSSLContext
from configuration.
-
getServerHttpHeaderValue
public static HttpHeaderValue getServerHttpHeaderValue(HttpServerImplementationContext context, java.lang.String suffix)
Convenience method to obtain theServer
HttpHeaderValue
.- Parameters:
context
-HttpServerImplementationContext
.suffix
- Optional suffix. May benull
.- Returns:
Server
HttpHeaderValue
ornull
if not configured.
-
getHttpServerLocation
public HttpServerLocation getHttpServerLocation()
Obtains theHttpServerLocation
.- Returns:
HttpServerLocation
.
-
getHttpServerImplementation
public HttpServerImplementation getHttpServerImplementation()
Obtains theHttpServerImplementation
.- Returns:
HttpServerImplementation
.
-
getSslContext
public javax.net.ssl.SSLContext getSslContext()
Obtains theSSLContext
.- Returns:
SSLContext
.
-
-