Package net.officefloor.server.http.impl
Class ProcessAwareServerHttpConnectionManagedObject<B>
- java.lang.Object
-
- net.officefloor.server.http.impl.ProcessAwareServerHttpConnectionManagedObject<B>
-
- Type Parameters:
B- Type of underlying buffer being used.
- All Implemented Interfaces:
FlowCallback,ContextAwareManagedObject,ManagedObject,ServerHttpConnection
public class ProcessAwareServerHttpConnectionManagedObject<B> extends java.lang.Object implements ServerHttpConnection, ContextAwareManagedObject, FlowCallback
ServerHttpConnectionimplementation available forExternalServiceInput.- Author:
- Daniel Sagenschneider
-
-
Field Summary
-
Fields inherited from interface net.officefloor.frame.api.function.FlowCallback
ESCALATE
-
Fields inherited from interface net.officefloor.server.http.ServerHttpConnection
DEFAULT_HTTP_ENTITY_CHARSET, HTTP_CHARSET, URI_CHARSET
-
-
Constructor Summary
Constructors Constructor Description ProcessAwareServerHttpConnectionManagedObject(HttpServerLocation serverLocation, boolean isSecure, java.util.function.Supplier<HttpMethod> methodSupplier, java.util.function.Supplier<java.lang.String> requestUriSupplier, HttpVersion version, NonMaterialisedHttpHeaders requestHeaders, ByteSequence requestEntity, HttpHeaderValue serverName, DateHttpHeaderClock dateHttpHeaderClock, boolean isIncludeStackTraceOnEscalation, HttpResponseWriter<B> writer, StreamBufferPool<B> bufferPool)Instantiate.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.SerializableexportState()Exports the state of the currentHttpRequestandHttpResponse.static ExternalServiceCleanupEscalationHandler<ProcessAwareServerHttpConnectionManagedObject>getCleanupEscalationHandler()Obtains theExternalServiceCleanupEscalationHandler.HttpRequestgetClientRequest()Obtains the actual client sentHttpRequestfor theServerHttpConnection.java.lang.ObjectgetObject()Obtains the object being managed.HttpRequestgetRequest()Obtains theHttpRequestto be serviced.HttpResponsegetResponse()Obtains theHttpResponse.HttpServerLocationgetServerLocation()Obtains theHttpServerLocation.FlowCallbackgetServiceFlowCallback()Obtains the serviceFlowCallback.voidimportState(java.io.Serializable momento)Imports and overrides the currentHttpRequestandHttpResponsewith the input momento.booleanisSecure()Indicates if the connection is over a secure channel (e.g.voidrun(java.lang.Throwable escalation)Invoked on completion of theFlow.voidsetCleanupEscalations(CleanupEscalation[] cleanupEscalations)Sets theCleanupEscalationinstances.voidsetManagedObjectContext(ManagedObjectContext context)Provides theManagedObjectContextto theManagedObject.
-
-
-
Constructor Detail
-
ProcessAwareServerHttpConnectionManagedObject
public ProcessAwareServerHttpConnectionManagedObject(HttpServerLocation serverLocation, boolean isSecure, java.util.function.Supplier<HttpMethod> methodSupplier, java.util.function.Supplier<java.lang.String> requestUriSupplier, HttpVersion version, NonMaterialisedHttpHeaders requestHeaders, ByteSequence requestEntity, HttpHeaderValue serverName, DateHttpHeaderClock dateHttpHeaderClock, boolean isIncludeStackTraceOnEscalation, HttpResponseWriter<B> writer, StreamBufferPool<B> bufferPool)
Instantiate.- Parameters:
serverLocation-HttpServerLocation.isSecure- Indicates if secure.methodSupplier-Supplierfor theHttpRequestHttpMethod.requestUriSupplier-Supplierfor theHttpRequestURI.version-HttpVersionfor theHttpRequest.requestHeaders-NonMaterialisedHttpHeadersfor theHttpRequest.requestEntity-ByteSequencefor theHttpRequestentity.serverName- Name of the server. May benullif not sendingServerHttpHeader.dateHttpHeaderClock-DateHttpHeaderClock. May benullto not sendDateHttpHeader.isIncludeStackTraceOnEscalation-trueto include theEscalationstack trace in theHttpResponse.writer-HttpResponseWriter.bufferPool-StreamBufferPool.
-
-
Method Detail
-
getCleanupEscalationHandler
public static ExternalServiceCleanupEscalationHandler<ProcessAwareServerHttpConnectionManagedObject> getCleanupEscalationHandler()
Obtains theExternalServiceCleanupEscalationHandler.- Returns:
ExternalServiceCleanupEscalationHandler.
-
getServiceFlowCallback
public FlowCallback getServiceFlowCallback()
Obtains the serviceFlowCallback.- Returns:
FlowCallbackto use for servicing this.
-
setCleanupEscalations
public void setCleanupEscalations(CleanupEscalation[] cleanupEscalations) throws java.io.IOException
Sets theCleanupEscalationinstances.- Parameters:
cleanupEscalations-CleanupEscalationinstances.- Throws:
java.io.IOException- If fails to send theCleanupEscalationdetails in theHttpResponse.
-
setManagedObjectContext
public void setManagedObjectContext(ManagedObjectContext context)
Description copied from interface:ContextAwareManagedObjectProvides theManagedObjectContextto theManagedObject.- Specified by:
setManagedObjectContextin interfaceContextAwareManagedObject- Parameters:
context-ManagedObjectContext.
-
getObject
public java.lang.Object getObject()
Description copied from interface:ManagedObjectObtains the object being managed.- Specified by:
getObjectin interfaceManagedObject- Returns:
- Object being managed.
-
getServerLocation
public HttpServerLocation getServerLocation()
Description copied from interface:ServerHttpConnectionObtains theHttpServerLocation.- Specified by:
getServerLocationin interfaceServerHttpConnection- Returns:
HttpServerLocation.
-
isSecure
public boolean isSecure()
Description copied from interface:ServerHttpConnectionIndicates if the connection is over a secure channel (e.g. utilising SSL).- Specified by:
isSecurein interfaceServerHttpConnection- Returns:
trueif connection is over a secure channel.
-
getRequest
public HttpRequest getRequest()
Description copied from interface:ServerHttpConnectionObtains theHttpRequestto be serviced.- Specified by:
getRequestin interfaceServerHttpConnection- Returns:
HttpRequestto be serviced.
-
getResponse
public HttpResponse getResponse()
Description copied from interface:ServerHttpConnectionObtains theHttpResponse.- Specified by:
getResponsein interfaceServerHttpConnection- Returns:
HttpResponse.
-
exportState
public java.io.Serializable exportState() throws java.io.IOExceptionDescription copied from interface:ServerHttpConnectionExports the state of the current
HttpRequestandHttpResponse.This enables maintaining the state of the
HttpRequest/HttpResponseand later reinstating them (typically after a redirect).- Specified by:
exportStatein interfaceServerHttpConnection- Returns:
- Momento containing the current
HttpRequestandHttpResponsestate. - Throws:
java.io.IOException- Should the state not be able to be exported.- See Also:
ServerHttpConnection.importState(Serializable)
-
importState
public void importState(java.io.Serializable momento) throws java.lang.IllegalArgumentException, java.io.IOExceptionDescription copied from interface:ServerHttpConnectionImports and overrides the currentHttpRequestandHttpResponsewith the input momento.- Specified by:
importStatein interfaceServerHttpConnection- Parameters:
momento- Momento exported from aServerHttpConnection.- Throws:
java.lang.IllegalArgumentException- Should the momento be invalid.java.io.IOException- Should the state not be able to be imported.- See Also:
ServerHttpConnection.exportState()
-
getClientRequest
public HttpRequest getClientRequest()
Description copied from interface:ServerHttpConnectionObtains the actual client sent
HttpRequestfor theServerHttpConnection.As the
HttpRequestcan be overridden, this allows logic requiring to know details of the actual clientHttpRequest. Examples of this logic are:- the POST/redirect/GET pattern that needs to know whether the client
sent
HttpMethodis aPOSTorGET(regardless of imported state) - checking for the
AuthorizationHttpHeaderto ensure it was sent by the client for servicing theHttpRequest - checking for the JWT token
HttpRequestCookieto ensure it was sent by the client for servicing theHttpRequest
Note for most application logic the
ServerHttpConnection.getRequest()should be used, as the intention is for this to contain the appropriate information for servicing theHttpRequest.- Specified by:
getClientRequestin interfaceServerHttpConnection- Returns:
- Actual client
HttpRequest. - See Also:
ServerHttpConnection.exportState(),ServerHttpConnection.importState(Serializable)
- the POST/redirect/GET pattern that needs to know whether the client
sent
-
run
public void run(java.lang.Throwable escalation) throws java.lang.ThrowableDescription copied from interface:FlowCallbackInvoked on completion of theFlow.- Specified by:
runin interfaceFlowCallback- Parameters:
escalation- PossibleThrowablefrom theFlow.nullindicates allEscalationinstances handled withinFlow.- Throws:
java.lang.Throwable-Escalationwithin the callback logic.
-
-