rewrite-config-servlet 2.0.0.Beta3

org.ocpsoft.rewrite.servlet.config
Class Response

java.lang.Object
  extended by org.ocpsoft.rewrite.config.DefaultOperationBuilder
      extended by org.ocpsoft.rewrite.servlet.config.HttpOperation
          extended by org.ocpsoft.rewrite.servlet.config.Response
All Implemented Interfaces:
Operation, OperationBuilder

public abstract class Response
extends HttpOperation

Responsible for manipulating properties such as headers, cookies, ResponseContentInterceptor and ResponseStreamWrapper instances to the current HttpServletResponse

Author:
Lincoln Baxter, III

Constructor Summary
Response()
           
 
Method Summary
static OperationBuilder addCookie(Cookie cookie)
          Create an Operation that adds a Cookie to the HttpServletResponse
static OperationBuilder addDateHeader(String name, long value)
          Create an Operation that adds a date header to the HttpServletResponse
static OperationBuilder addHeader(String name, String value)
          Create an Operation that adds a header to the HttpServletResponse
static OperationBuilder addIntHeader(String name, int value)
          Create an Operation that adds an int header to the HttpServletResponse
static OperationBuilder complete()
          Create an Operation that halts further Rewrite processing and completes the current HttpServletResponse.
static OperationBuilder gzipCompression()
          Compress the ServletOutputStream contents written to the client.
static OperationBuilder gzipStreamCompression()
          Compress the ServletOutputStream contents written to the client.
static OperationBuilder setContentType(String contentType)
          Create an Operation that sets the content type for the HttpServletResponse
static OperationBuilder setStatus(int status)
          Create an Operation that sets the given status code via HttpServletResponse.setStatus(int).
static OperationBuilder withOutputInterceptedBy(ResponseContentInterceptor... buffers)
          Create an Operation that adds the given ResponseContentInterceptor instances to the current ServletResponse.
static OperationBuilder withOutputStreamWrappedBy(ResponseStreamWrapper... wrappers)
          Create an Operation that adds the given ResponseStreamWrapper instances to the current ServletResponse.
static OperationBuilder write(byte... bytes)
          Create an Operation that writes the given bytes to the current HttpServletResponse upon execution.
static OperationBuilder write(InputStream stream)
          Create an Operation that writes the contents of the given InputStream current HttpServletResponse upon execution.
static OperationBuilder write(Object value)
          Create an Operation that writes the String value of the given Object to the current HttpServletResponse upon execution.
 
Methods inherited from class org.ocpsoft.rewrite.servlet.config.HttpOperation
perform, performHttp
 
Methods inherited from class org.ocpsoft.rewrite.config.DefaultOperationBuilder
and
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Response

public Response()
Method Detail

withOutputInterceptedBy

public static OperationBuilder withOutputInterceptedBy(ResponseContentInterceptor... buffers)
                                                throws IllegalStateException
Create an Operation that adds the given ResponseContentInterceptor instances to the current ServletResponse. This will activate response buffering on the current ServletRequest - meaning that generated output will not be sent to the client until the entire request has completed and all registered ResponseContentInterceptor instances have been executed on the outbound response content.

WARNING: This will cause the ENTIRE response to be buffered in memory, which may cause performance issues on larger responses. Make sure you you really need to buffer the entire response! Favor using a ResponseStreamWrapper if desired behavior may be performed as a stream operation; this will result in far less memory overhead.

Throws:
IllegalStateException - When output has already been written to the client.

withOutputStreamWrappedBy

public static OperationBuilder withOutputStreamWrappedBy(ResponseStreamWrapper... wrappers)
                                                  throws IllegalStateException
Create an Operation that adds the given ResponseStreamWrapper instances to the current ServletResponse. This will activate response stream wrapping on the current ServletRequest - meaning response content will be piped through all registered ResponseStreamWrapper instances as it is written to the client ServletOutputStream.

Throws:
IllegalStateException - When output has already been written to the client.

addHeader

public static OperationBuilder addHeader(String name,
                                         String value)
Create an Operation that adds a header to the HttpServletResponse


addDateHeader

public static OperationBuilder addDateHeader(String name,
                                             long value)
Create an Operation that adds a date header to the HttpServletResponse


setContentType

public static OperationBuilder setContentType(String contentType)
Create an Operation that sets the content type for the HttpServletResponse


addIntHeader

public static OperationBuilder addIntHeader(String name,
                                            int value)
Create an Operation that adds an int header to the HttpServletResponse


addCookie

public static OperationBuilder addCookie(Cookie cookie)
Create an Operation that adds a Cookie to the HttpServletResponse


gzipCompression

public static OperationBuilder gzipCompression()
Compress the ServletOutputStream contents written to the client.

WARNING: This causes response content to be buffered in memory in order to properly count the response 'Content-Length'.


gzipStreamCompression

public static OperationBuilder gzipStreamCompression()
Compress the ServletOutputStream contents written to the client.

WARNING: This means that the HTTP response will not contain a 'Content-Length' header.


write

public static OperationBuilder write(byte... bytes)
Create an Operation that writes the given bytes to the current HttpServletResponse upon execution.


write

public static OperationBuilder write(Object value)
Create an Operation that writes the String value of the given Object to the current HttpServletResponse upon execution. The value to be written is obtained using Object.toString().


write

public static OperationBuilder write(InputStream stream)
Create an Operation that writes the contents of the given InputStream current HttpServletResponse upon execution.


setStatus

public static OperationBuilder setStatus(int status)
Create an Operation that sets the given status code via HttpServletResponse.setStatus(int). This does not call ServletResponse.flushBuffer()


complete

public static OperationBuilder complete()
Create an Operation that halts further Rewrite processing and completes the current HttpServletResponse.


rewrite-config-servlet 2.0.0.Beta3

Copyright © 2013 OCPsoft. All Rights Reserved.