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,InputManagedObject,ManagedObject,ServerHttpConnection
- Direct Known Subclasses:
SpringServerHttpConnection
public class ProcessAwareServerHttpConnectionManagedObject<B>
extends Object
implements ServerHttpConnection, ContextAwareManagedObject, InputManagedObject, FlowCallback
ServerHttpConnection implementation available for
ExternalServiceInput.- Author:
- Daniel Sagenschneider
-
Field Summary
Fields inherited from interface net.officefloor.frame.api.function.FlowCallback
ESCALATEFields inherited from interface net.officefloor.server.http.ServerHttpConnection
DEFAULT_HTTP_ENTITY_CHARSET, HTTP_CHARSET, URI_CHARSET -
Constructor Summary
ConstructorsConstructorDescriptionProcessAwareServerHttpConnectionManagedObject(HttpServerLocation serverLocation, boolean isSecure, Supplier<HttpMethod> methodSupplier, Supplier<String> requestUriSupplier, HttpVersion version, NonMaterialisedHttpHeaders requestHeaders, ByteSequence requestEntity, HttpHeaderValue serverName, DateHttpHeaderClock dateHttpHeaderClock, boolean isIncludeStackTraceOnEscalation, HttpResponseWriter<B> writer, StreamBufferPool<B> bufferPool) Instantiate. -
Method Summary
Modifier and TypeMethodDescriptionvoidclean(CleanupEscalation[] cleanupEscalations) Invoked to clean theManagedObjectat end of servicing.Exports the state of the currentHttpRequestandHttpResponse.Obtains the actual client sentHttpRequestfor theServerHttpConnection.Obtains the object being managed.Obtains theHttpRequestto be serviced.Obtains theHttpResponse.Obtains theHttpServerLocation.Obtains the serviceFlowCallback.voidimportState(Serializable momento) Imports and overrides the currentHttpRequestandHttpResponsewith the input momento.booleanisSecure()Indicates if the connection is over a secure channel (e.g.voidInvoked on completion of theFlow.voidProvides theManagedObjectContextto theManagedObject.
-
Constructor Details
-
ProcessAwareServerHttpConnectionManagedObject
public ProcessAwareServerHttpConnectionManagedObject(HttpServerLocation serverLocation, boolean isSecure, Supplier<HttpMethod> methodSupplier, Supplier<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 Details
-
getServiceFlowCallback
Obtains the serviceFlowCallback.- Returns:
FlowCallbackto use for servicing this.
-
setManagedObjectContext
Description copied from interface:ContextAwareManagedObjectProvides theManagedObjectContextto theManagedObject.- Specified by:
setManagedObjectContextin interfaceContextAwareManagedObject- Parameters:
context-ManagedObjectContext.
-
getObject
Description copied from interface:ManagedObjectObtains the object being managed.- Specified by:
getObjectin interfaceManagedObject- Returns:
- Object being managed.
-
clean
Description copied from interface:InputManagedObjectInvoked to clean theManagedObjectat end of servicing.- Specified by:
cleanin interfaceInputManagedObject- Parameters:
cleanupEscalations-CleanupEscalationinstances on failure of servicing.- Throws:
Throwable- If fails to handle theCleanupEscalationinstances.
-
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
Description copied from interface:ServerHttpConnectionObtains theHttpRequestto be serviced.- Specified by:
getRequestin interfaceServerHttpConnection- Returns:
HttpRequestto be serviced.
-
getResponse
Description copied from interface:ServerHttpConnectionObtains theHttpResponse.- Specified by:
getResponsein interfaceServerHttpConnection- Returns:
HttpResponse.
-
exportState
Description 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:
IOException- Should the state not be able to be exported.- See Also:
-
importState
Description copied from interface:ServerHttpConnectionImports and overrides the currentHttpRequestandHttpResponsewith the input momento.- Specified by:
importStatein interfaceServerHttpConnection- Parameters:
momento- Momento exported from aServerHttpConnection.- Throws:
IllegalArgumentException- Should the momento be invalid.IOException- Should the state not be able to be imported.- See Also:
-
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:
- the POST/redirect/GET pattern that needs to know whether the client
sent
-
run
Description copied from interface:FlowCallbackInvoked on completion of theFlow.- Specified by:
runin interfaceFlowCallback- Parameters:
escalation- PossibleThrowablefrom theFlow.nullindicates allEscalationinstances handled withinFlow.- Throws:
Throwable-Escalationwithin the callback logic.
-