Class ProcessAwareHttpResponse<B>
- java.lang.Object
 - 
- net.officefloor.server.http.impl.ProcessAwareHttpResponse<B>
 
 
- 
- All Implemented Interfaces:
 HttpResponse,CloseHandler
public class ProcessAwareHttpResponse<B> extends java.lang.Object implements HttpResponse, CloseHandler
SerializableHttpResponse.- Author:
 - Daniel Sagenschneider
 
 
- 
- 
Constructor Summary
Constructors Constructor Description ProcessAwareHttpResponse(ProcessAwareServerHttpConnectionManagedObject<B> serverHttpConnection, HttpVersion version, ManagedObjectContext managedObjectContext)Instantiate. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Handles the close.voidflushResponseToHttpResponseWriter(java.lang.Throwable escalation)Flushes theHttpResponseto theHttpResponseWriter.java.nio.charset.CharsetgetContentCharset()Obtains theCharsetfor the content.java.lang.StringgetContentType()Obtains theContent-Type.HttpResponseCookiesgetCookies()Obtains theHttpResponseCookies.ServerOutputStreamgetEntity()Obtains theServerOutputStreamto write the entity of the response.ServerWritergetEntityWriter()Obtains theServerWriterto write the entity of the response.HttpEscalationHandlergetEscalationHandler()Obtains theHttpEscalationHandler.HttpResponseHeadersgetHeaders()Obtains theHttpResponseHeaders.HttpStatusgetStatus()Obtains theHttpStatus.HttpVersiongetVersion()Obtains theHttpVersion.booleanisClosed()Indicates if closed.voidreset()Resets theHttpResponseby clearingHttpHeaderinstances and the entity.voidsend()Sends thisHttpResponse.voidsetContentType(java.lang.String contentType, java.nio.charset.Charset charset)Specifies theContent-Typeand optionally theCharset.voidsetContentType(HttpHeaderValue contentTypeAndCharsetValue, java.nio.charset.Charset charset)Provides means to useHttpHeaderValueto specify both theContent-Typeandcharsetfor more efficiency.voidsetEscalationHandler(HttpEscalationHandler escalationHandler)Sets theHttpEscalationHandlerfor the response.voidsetStatus(HttpStatus status)Specifies theHttpStatus.voidsetVersion(HttpVersion version)Override theHttpVersion. 
 - 
 
- 
- 
Constructor Detail
- 
ProcessAwareHttpResponse
public ProcessAwareHttpResponse(ProcessAwareServerHttpConnectionManagedObject<B> serverHttpConnection, HttpVersion version, ManagedObjectContext managedObjectContext)
Instantiate.- Parameters:
 serverHttpConnection-ServerHttpConnection.version-HttpVersion.managedObjectContext-ManagedObjectContext.
 
 - 
 
- 
Method Detail
- 
flushResponseToHttpResponseWriter
public void flushResponseToHttpResponseWriter(java.lang.Throwable escalation) throws java.io.IOExceptionFlushes theHttpResponseto theHttpResponseWriter.- Parameters:
 escalation- Possible escalation in servicing. Will benullif successful.- Throws:
 java.io.IOException- If fails to flushHttpResponseto theHttpResponseWriter.
 
- 
getVersion
public HttpVersion getVersion()
Description copied from interface:HttpResponseObtains theHttpVersion.- Specified by:
 getVersionin interfaceHttpResponse- Returns:
 HttpVersion.
 
- 
setVersion
public void setVersion(HttpVersion version)
Description copied from interface:HttpResponseOverride the
HttpVersion.This defaults to value on
HttpRequest.- Specified by:
 setVersionin interfaceHttpResponse- Parameters:
 version-HttpVersion.
 
- 
getStatus
public HttpStatus getStatus()
Description copied from interface:HttpResponseObtains the
HttpStatus.This is the current status. The status may changed based on particular HTTP rules (e.g. 200 becoming 204 due to no entity) or there being a failure in processing the message.
- Specified by:
 getStatusin interfaceHttpResponse- Returns:
 - Current 
HttpStatus. 
 
- 
setStatus
public void setStatus(HttpStatus status)
Description copied from interface:HttpResponseSpecifies the
HttpStatus.This defaults to
HttpStatus.OKassuming the request was processed successfully.- Specified by:
 setStatusin interfaceHttpResponse- Parameters:
 status-HttpStatus.
 
- 
getHeaders
public HttpResponseHeaders getHeaders()
Description copied from interface:HttpResponseObtains theHttpResponseHeaders.- Specified by:
 getHeadersin interfaceHttpResponse- Returns:
 HttpResponseHeaders.
 
- 
getCookies
public HttpResponseCookies getCookies()
Description copied from interface:HttpResponseObtains theHttpResponseCookies.- Specified by:
 getCookiesin interfaceHttpResponse- Returns:
 HttpResponseCookies.
 
- 
setContentType
public void setContentType(java.lang.String contentType, java.nio.charset.Charset charset) throws java.io.IOExceptionDescription copied from interface:HttpResponseSpecifies the
Content-Typeand optionally theCharset. Thecharsetparameter will automatically be added to theContent-Typeon using theHttpResponse.getEntityWriter().This must be specified before calling
HttpResponse.getEntityWriter().- Specified by:
 setContentTypein interfaceHttpResponse- Parameters:
 contentType-Content-Type. May benullto unset theContent-Type.charset-Charsetfor theContent-Type. This may benullto use the defaultCharset. Also usenullforContent-Types that do not require character encoding (including the default HTTP content encoding).- Throws:
 java.io.IOException- If attempting to specify after callingHttpResponse.getEntityWriter().
 
- 
setContentType
public void setContentType(HttpHeaderValue contentTypeAndCharsetValue, java.nio.charset.Charset charset) throws java.io.IOException
Description copied from interface:HttpResponseProvides means to use
HttpHeaderValueto specify both theContent-Typeandcharsetfor more efficiency.Note that
HttpHeaderValuewill require the inclusion of thecharset, as thecharsetwill not be appended.- Specified by:
 setContentTypein interfaceHttpResponse- Parameters:
 contentTypeAndCharsetValue-HttpHeaderValuefor theContent-Typeandcharset.charset-Charsetto configure theServerWriter.- Throws:
 java.io.IOException- If attempting to specify after callingHttpResponse.getEntityWriter().
 
- 
getContentType
public java.lang.String getContentType()
Description copied from interface:HttpResponseObtains theContent-Type.- Specified by:
 getContentTypein interfaceHttpResponse- Returns:
 Content-Type. May benullif noContent-Typehas been specified.
 
- 
getContentCharset
public java.nio.charset.Charset getContentCharset()
Description copied from interface:HttpResponseObtains the
Charsetfor the content.If no
Charsethas been specified, the defaultCharsetwill be returned.- Specified by:
 getContentCharsetin interfaceHttpResponse- Returns:
 Charset.
 
- 
getEntity
public ServerOutputStream getEntity() throws java.io.IOException
Description copied from interface:HttpResponseObtains the
ServerOutputStreamto write the entity of the response.Only one of
HttpResponse.getEntity()orHttpResponse.getEntityWriter()may be called.Closing the returned
ServerOutputStreamis similar to callingHttpResponse.send().- Specified by:
 getEntityin interfaceHttpResponse- Returns:
 ServerOutputStreamto write the entity of the response.- Throws:
 java.io.IOException- ShouldHttpResponse.getEntityWriter()already be provided.- See Also:
 HttpResponse.getEntityWriter(),HttpResponse.send()
 
- 
getEntityWriter
public ServerWriter getEntityWriter() throws java.io.IOException
Description copied from interface:HttpResponseObtains the
ServerWriterto write the entity of the response.Only one of
HttpResponse.getEntity()orHttpResponse.getEntityWriter()may be called.Closing the returned
ServerOutputStreamis similar to callingHttpResponse.send().- Specified by:
 getEntityWriterin interfaceHttpResponse- Returns:
 ServerWriterto write the entity of the response.- Throws:
 java.io.IOException- ShouldHttpResponse.getEntity()already be provided.- See Also:
 HttpResponse.getEntity(),HttpResponse.send()
 
- 
getEscalationHandler
public HttpEscalationHandler getEscalationHandler()
Description copied from interface:HttpResponseObtains theHttpEscalationHandler.- Specified by:
 getEscalationHandlerin interfaceHttpResponse- Returns:
 HttpEscalationHandlerornullif noHttpEscalationHandlerconfigured.
 
- 
setEscalationHandler
public void setEscalationHandler(HttpEscalationHandler escalationHandler)
Description copied from interface:HttpResponseSets theHttpEscalationHandlerfor the response.- Specified by:
 setEscalationHandlerin interfaceHttpResponse- Parameters:
 escalationHandler-HttpEscalationHandlerfor the response.
 
- 
reset
public void reset() throws java.io.IOExceptionDescription copied from interface:HttpResponseResets theHttpResponseby clearingHttpHeaderinstances and the entity.- Specified by:
 resetin interfaceHttpResponse- Throws:
 java.io.IOException- If committed to send theHttpResponse.
 
- 
send
public void send() throws java.io.IOExceptionDescription copied from interface:HttpResponse- Specified by:
 sendin interfaceHttpResponse- Throws:
 java.io.IOException- If fails to send thisHttpResponse.
 
- 
isClosed
public boolean isClosed()
Description copied from interface:CloseHandlerIndicates if closed.- Specified by:
 isClosedin interfaceCloseHandler- Returns:
 trueif closed.
 
- 
close
public void close() throws java.io.IOExceptionDescription copied from interface:CloseHandlerHandles the close.- Specified by:
 closein interfaceCloseHandler- Throws:
 java.io.IOException- If fails to close.
 
 - 
 
 -