Package net.officefloor.server.http
Class HttpServerSocketManagedObjectSource
- java.lang.Object
-
- net.officefloor.frame.api.managedobject.source.impl.AbstractAsyncManagedObjectSource<O,F>
-
- net.officefloor.frame.api.managedobject.source.impl.AbstractManagedObjectSource<None,Indexed>
-
- net.officefloor.server.http.HttpServerSocketManagedObjectSource
-
- All Implemented Interfaces:
ManagedFunction<Indexed,None>
,ThreadCompletionListener
,ManagedObjectSource<None,Indexed>
@PrivateSource public class HttpServerSocketManagedObjectSource extends AbstractManagedObjectSource<None,Indexed> implements ManagedFunction<Indexed,None>, ThreadCompletionListener
- Author:
- Daniel Sagenschneider
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.officefloor.frame.api.managedobject.source.impl.AbstractAsyncManagedObjectSource
AbstractAsyncManagedObjectSource.DependencyLabeller<K extends java.lang.Enum<K>>, AbstractAsyncManagedObjectSource.ExecutionLabeller, AbstractAsyncManagedObjectSource.Labeller<K extends java.lang.Enum<K>>, AbstractAsyncManagedObjectSource.MetaDataContext<O extends java.lang.Enum<O>,F extends java.lang.Enum<F>>, AbstractAsyncManagedObjectSource.SpecificationContext
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
HANDLE_REQUEST_FLOW_NAME
Name of theFlow
to handle the request.static java.lang.String
PROPERTY_MAX_ENTITY_LENGTH
Name ofProperty
for the maximum entity length for HTTP parsing.static java.lang.String
PROPERTY_MAX_HEADER_COUNT
static java.lang.String
PROPERTY_MAX_TEXT_LENGTH
Name ofProperty
for the maximum text length for HTTP parsing.static java.lang.String
PROPERTY_SECURE
Name ofProperty
indicating if secure.static java.lang.String
SSL_TEAM_NAME
Name of theTeam
to execute the SSL tasks.static java.lang.String
SYSTEM_PROPERTY_CORE_BUFFER_POOL_MAX_SIZE
Name ofSystem
property to obtain the maximumThreadLocalStreamBufferPool
core pool size.static java.lang.String
SYSTEM_PROPERTY_MAX_ACTIVE_SOCKET_REQUESTS
Name ofSystem
property to obtain the maximum number of active requests on the socket.static java.lang.String
SYSTEM_PROPERTY_MAX_READS_ON_SELECT
Name ofSystem
property to obtain the maximum number of reads for aSocketChannel
per select.static java.lang.String
SYSTEM_PROPERTY_MEMORY_THRESHOLD_PERCENTAGE
Name ofSystem
property to obtain the memory threshold percentage.static java.lang.String
SYSTEM_PROPERTY_RECEIVE_BUFFER_SIZE
Name ofSystem
property to obtain the receive buffer size of theSocket
.static java.lang.String
SYSTEM_PROPERTY_SEND_BUFFER_SIZE
Name ofSystem
property to obtain the send buffer size of theSocket
.static java.lang.String
SYSTEM_PROPERTY_SOCKET_LISTENER_COUNT
Name ofSystem
property to specify the number ofSocketServicer
instances.static java.lang.String
SYSTEM_PROPERTY_STREAM_BUFFER_SIZE
Name ofSystem
property to obtain the pooledStreamBuffer
size.static java.lang.String
SYSTEM_PROPERTY_THREADLOCAL_BUFFER_POOL_MAX_SIZE
-
Constructor Summary
Constructors Constructor Description HttpServerSocketManagedObjectSource()
Default constructor to configure fromPropertyList
.HttpServerSocketManagedObjectSource(HttpServerLocation serverLocation, HttpHeaderValue serverName, DateHttpHeaderClock dateHttpHeaderClock, boolean isIncludeEscalationStackTrace)
Instantiate for non-secure servicing.HttpServerSocketManagedObjectSource(HttpServerLocation serverLocation, HttpHeaderValue serverName, DateHttpHeaderClock dateHttpHeaderClock, boolean isIncludeEscalationStackTrace, javax.net.ssl.SSLContext sslContext)
Instantiate for secure servicing.
-
Method Summary
-
Methods inherited from class net.officefloor.frame.api.managedobject.source.impl.AbstractManagedObjectSource
sourceManagedObject
-
Methods inherited from class net.officefloor.frame.api.managedobject.source.impl.AbstractAsyncManagedObjectSource
getSpecification, init, stop
-
-
-
-
Field Detail
-
SYSTEM_PROPERTY_SOCKET_LISTENER_COUNT
public static final java.lang.String SYSTEM_PROPERTY_SOCKET_LISTENER_COUNT
Name ofSystem
property to specify the number ofSocketServicer
instances. If not specified, will default toRuntime.availableProcessors()
.- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_STREAM_BUFFER_SIZE
public static final java.lang.String SYSTEM_PROPERTY_STREAM_BUFFER_SIZE
Name ofSystem
property to obtain the pooledStreamBuffer
size.- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_RECEIVE_BUFFER_SIZE
public static final java.lang.String SYSTEM_PROPERTY_RECEIVE_BUFFER_SIZE
Name ofSystem
property to obtain the receive buffer size of theSocket
.- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_MAX_READS_ON_SELECT
public static final java.lang.String SYSTEM_PROPERTY_MAX_READS_ON_SELECT
Name ofSystem
property to obtain the maximum number of reads for aSocketChannel
per select.- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_MAX_ACTIVE_SOCKET_REQUESTS
public static final java.lang.String SYSTEM_PROPERTY_MAX_ACTIVE_SOCKET_REQUESTS
Name ofSystem
property to obtain the maximum number of active requests on the socket.- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_SEND_BUFFER_SIZE
public static final java.lang.String SYSTEM_PROPERTY_SEND_BUFFER_SIZE
Name ofSystem
property to obtain the send buffer size of theSocket
.- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_THREADLOCAL_BUFFER_POOL_MAX_SIZE
public static final java.lang.String SYSTEM_PROPERTY_THREADLOCAL_BUFFER_POOL_MAX_SIZE
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_CORE_BUFFER_POOL_MAX_SIZE
public static final java.lang.String SYSTEM_PROPERTY_CORE_BUFFER_POOL_MAX_SIZE
Name ofSystem
property to obtain the maximumThreadLocalStreamBufferPool
core pool size.- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_MEMORY_THRESHOLD_PERCENTAGE
public static final java.lang.String SYSTEM_PROPERTY_MEMORY_THRESHOLD_PERCENTAGE
Name ofSystem
property to obtain the memory threshold percentage.- See Also:
- Constant Field Values
-
PROPERTY_SECURE
public static final java.lang.String PROPERTY_SECURE
Name ofProperty
indicating if secure.- See Also:
- Constant Field Values
-
PROPERTY_MAX_HEADER_COUNT
public static final java.lang.String PROPERTY_MAX_HEADER_COUNT
- See Also:
- Constant Field Values
-
PROPERTY_MAX_TEXT_LENGTH
public static final java.lang.String PROPERTY_MAX_TEXT_LENGTH
Name ofProperty
for the maximum text length for HTTP parsing.- See Also:
- Constant Field Values
-
PROPERTY_MAX_ENTITY_LENGTH
public static final java.lang.String PROPERTY_MAX_ENTITY_LENGTH
Name ofProperty
for the maximum entity length for HTTP parsing.- See Also:
- Constant Field Values
-
HANDLE_REQUEST_FLOW_NAME
public static final java.lang.String HANDLE_REQUEST_FLOW_NAME
Name of theFlow
to handle the request.- See Also:
- Constant Field Values
-
SSL_TEAM_NAME
public static final java.lang.String SSL_TEAM_NAME
Name of theTeam
to execute the SSL tasks.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HttpServerSocketManagedObjectSource
public HttpServerSocketManagedObjectSource()
Default constructor to configure fromPropertyList
.
-
HttpServerSocketManagedObjectSource
public HttpServerSocketManagedObjectSource(HttpServerLocation serverLocation, HttpHeaderValue serverName, DateHttpHeaderClock dateHttpHeaderClock, boolean isIncludeEscalationStackTrace)
Instantiate for non-secure servicing.- Parameters:
serverLocation
-HttpServerLocation
.serverName
-Server
HttpHeaderValue
.dateHttpHeaderClock
-DateHttpHeaderClock
.isIncludeEscalationStackTrace
- Indicates if include theEscalation
stack trace on theHttpResponse
.
-
HttpServerSocketManagedObjectSource
public HttpServerSocketManagedObjectSource(HttpServerLocation serverLocation, HttpHeaderValue serverName, DateHttpHeaderClock dateHttpHeaderClock, boolean isIncludeEscalationStackTrace, javax.net.ssl.SSLContext sslContext)
Instantiate for secure servicing.- Parameters:
serverLocation
-HttpServerLocation
.serverName
-Server
HttpHeaderValue
.dateHttpHeaderClock
-DateHttpHeaderClock
.isIncludeEscalationStackTrace
- Indicates if include theEscalation
stack trace on theHttpResponse
.sslContext
-SSLContext
. May benull
if behind reverse proxy handling secure communication.
-
-
Method Detail
-
createSocketManager
public static SocketManager createSocketManager(java.util.concurrent.ThreadFactory[] executionStrategy, java.util.function.Consumer<ThreadCompletionListener> threadCompletionListenerCapture) throws java.io.IOException
Creates theSocketManager
configured fromSystem
properties.- Parameters:
executionStrategy
-ThreadFactory
instances for theExecutionStrategy
for theSocketManager
.threadCompletionListenerCapture
- Captures theThreadCompletionListener
for theSocketManager
. May benull
.- Returns:
SocketManager
configured fromSystem
properties.- Throws:
java.io.IOException
- If fails to create theSocketManager
.
-
isSocketManagerActive
public static boolean isSocketManagerActive()
Indicates if there is an activeSocketManager
forHttpServerSocketManagedObjectSource
instances.- Returns:
true
if activeSocketManager
.
-
getServerSocketDecorator
protected ServerSocketDecorator getServerSocketDecorator(AbstractAsyncManagedObjectSource.MetaDataContext<None,Indexed> context)
Enables overriding to configure aServerSocketDecorator
.- Parameters:
context
-AbstractAsyncManagedObjectSource.MetaDataContext
.- Returns:
ServerSocketDecorator
.
-
getAcceptedSocketDecorator
protected AcceptedSocketDecorator getAcceptedSocketDecorator(AbstractAsyncManagedObjectSource.MetaDataContext<None,Indexed> context)
Enables overriding to configure theAcceptedSocketDecorator
.- Parameters:
context
-AbstractAsyncManagedObjectSource.MetaDataContext
.- Returns:
AcceptedSocketDecorator
.
-
loadSpecification
protected void loadSpecification(AbstractAsyncManagedObjectSource.SpecificationContext context)
Description copied from class:AbstractAsyncManagedObjectSource
Overridden to load specifications.- Specified by:
loadSpecification
in classAbstractAsyncManagedObjectSource<None,Indexed>
- Parameters:
context
- Specifications.
-
loadMetaData
protected void loadMetaData(AbstractAsyncManagedObjectSource.MetaDataContext<None,Indexed> context) throws java.lang.Exception
Description copied from class:AbstractAsyncManagedObjectSource
Overridden to load meta-data.- Specified by:
loadMetaData
in classAbstractAsyncManagedObjectSource<None,Indexed>
- Parameters:
context
- Meta-data.- Throws:
java.lang.Exception
- If fails to load the meta-data.
-
start
public void start(ManagedObjectExecuteContext<Indexed> context) throws java.lang.Exception
Description copied from interface:ManagedObjectSource
Called once after
ManagedObjectSource.init(ManagedObjectSourceContext)
to indicate thisManagedObjectSource
should start execution.On invocation of this method,
ProcessState
instances may be invoked via theManagedObjectExecuteContext
.- Specified by:
start
in interfaceManagedObjectSource<None,Indexed>
- Overrides:
start
in classAbstractAsyncManagedObjectSource<None,Indexed>
- Parameters:
context
-ManagedObjectExecuteContext
to use in starting thisManagedObjectSource
.- Throws:
java.lang.Exception
- Should theManagedObjectSource
fail to start execution.
-
getManagedObject
protected ManagedObject getManagedObject() throws java.lang.Throwable
Description copied from class:AbstractManagedObjectSource
Synchronously obtains theManagedObject
.- Specified by:
getManagedObject
in classAbstractManagedObjectSource<None,Indexed>
- Returns:
ManagedObject
.- Throws:
java.lang.Throwable
- If fails to obtain theManagedObject
.
-
execute
public void execute(ManagedFunctionContext<Indexed,None> context) throws java.lang.Throwable
Description copied from interface:ManagedFunction
Executes the function.- Specified by:
execute
in interfaceManagedFunction<Indexed,None>
- Parameters:
context
-ManagedFunctionContext
for theManagedFunction
.- Throws:
java.lang.Throwable
- Indicating failure of theManagedFunction
.
-
threadComplete
public void threadComplete()
Description copied from interface:ThreadCompletionListener
Notifies that theThread
has completed.- Specified by:
threadComplete
in interfaceThreadCompletionListener
-
-