org.glassfish.jersey.message.internal
Class WriterInterceptorExecutor

java.lang.Object
  extended by org.glassfish.jersey.message.internal.WriterInterceptorExecutor
All Implemented Interfaces:
InterceptorContext, WriterInterceptorContext

public class WriterInterceptorExecutor
extends java.lang.Object
implements WriterInterceptorContext

Entry point of the writer interceptor chain. It contstructs the chain of wrapped interceptor and invokes it. At the end of the chain the MessageBodyWriter is invoked which writes the entity to the output stream. The ExceptionWrapperInterceptor is always invoked on the client as a first interceptor.

Author:
Miroslav Fuksa (miroslav.fuksa at oracle.com)

Constructor Summary
WriterInterceptorExecutor(java.lang.Object entity, GenericType genericType, java.lang.annotation.Annotation[] annotations, MediaType mediaType, MultivaluedMap<java.lang.String,java.lang.Object> headers, java.util.Map<java.lang.String,java.lang.Object> properties, java.io.OutputStream entityStream, MessageBodyWorkers workers, MessageBodyWorkers.MessageBodySizeCallback sizeCallback, boolean intercept, boolean writeEntity)
          Reads a type from the entityStream using interceptors.
 
Method Summary
 java.lang.annotation.Annotation[] getAnnotations()
           
 java.lang.Object getEntity()
           
 java.lang.reflect.Type getGenericType()
           
 MultivaluedMap<java.lang.String,java.lang.Object> getHeaders()
           
 MediaType getMediaType()
           
 WriterInterceptor getNextInterceptor()
          Returns next interceptor in the chain.
 java.io.OutputStream getOutputStream()
           
 java.util.Map<java.lang.String,java.lang.Object> getProperties()
           
 java.lang.Class getType()
           
 void proceed()
          Starts the interceptor chain execution.
 void setAnnotations(java.lang.annotation.Annotation[] annotations)
           
 void setEntity(java.lang.Object entity)
           
 void setGenericType(java.lang.reflect.Type genericType)
           
 void setMediaType(MediaType mediaType)
           
 void setOutputStream(java.io.OutputStream os)
           
 void setType(java.lang.Class type)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.ws.rs.ext.InterceptorContext
getAnnotations, getGenericType, getMediaType, getProperties, getType, setAnnotations, setGenericType, setMediaType, setType
 

Constructor Detail

WriterInterceptorExecutor

public WriterInterceptorExecutor(java.lang.Object entity,
                                 GenericType genericType,
                                 java.lang.annotation.Annotation[] annotations,
                                 MediaType mediaType,
                                 MultivaluedMap<java.lang.String,java.lang.Object> headers,
                                 java.util.Map<java.lang.String,java.lang.Object> properties,
                                 java.io.OutputStream entityStream,
                                 MessageBodyWorkers workers,
                                 MessageBodyWorkers.MessageBodySizeCallback sizeCallback,
                                 boolean intercept,
                                 boolean writeEntity)
Reads a type from the entityStream using interceptors.

Parameters:
entity - entity object to be processed.
genericType - the generic type that is to be read from the input stream.
annotations - an array of the annotations on the declaration of the artifact that will be initialized with the produced instance. E.g. if the message body is to be converted into a method parameter, this will be the annotations on that parameter returned by Method.getParameterAnnotations.
mediaType - the media type of the HTTP entity.
headers - the mutable HTTP headers associated with HTTP entity.
properties - the mutable map of request-scoped properties.
entityStream - the InputStream of the HTTP entity. The stream is not closed after reading the entity.
workers - Message body workers.
sizeCallback - MessageBodyWorkers.MessageBodySizeCallback instance. Can be null.
intercept - true if the user interceptors should be executed. Otherwise only exception wrapping interceptor will be executed in the client.
writeEntity - true if the entity should be written. Otherwise only headers will be written to underlying OutputStream.
Throws:
WebApplicationException - Thrown when message body reader fails.
java.io.IOException - Thrown when reading from the entityStream fails.
Method Detail

getNextInterceptor

public WriterInterceptor getNextInterceptor()
Returns next interceptor in the chain. Stateful method.

Returns:
Next interceptor.

proceed

public void proceed()
             throws java.io.IOException
Starts the interceptor chain execution.

Specified by:
proceed in interface WriterInterceptorContext
Throws:
java.io.IOException

getEntity

public java.lang.Object getEntity()
Specified by:
getEntity in interface WriterInterceptorContext

setEntity

public void setEntity(java.lang.Object entity)
Specified by:
setEntity in interface WriterInterceptorContext

getOutputStream

public java.io.OutputStream getOutputStream()
Specified by:
getOutputStream in interface WriterInterceptorContext

setOutputStream

public void setOutputStream(java.io.OutputStream os)
Specified by:
setOutputStream in interface WriterInterceptorContext

getHeaders

public MultivaluedMap<java.lang.String,java.lang.Object> getHeaders()
Specified by:
getHeaders in interface WriterInterceptorContext

getProperties

public java.util.Map<java.lang.String,java.lang.Object> getProperties()
Specified by:
getProperties in interface InterceptorContext

getAnnotations

public java.lang.annotation.Annotation[] getAnnotations()
Specified by:
getAnnotations in interface InterceptorContext

setAnnotations

public void setAnnotations(java.lang.annotation.Annotation[] annotations)
Specified by:
setAnnotations in interface InterceptorContext

getType

public java.lang.Class getType()
Specified by:
getType in interface InterceptorContext

setType

public void setType(java.lang.Class type)
Specified by:
setType in interface InterceptorContext

getGenericType

public java.lang.reflect.Type getGenericType()
Specified by:
getGenericType in interface InterceptorContext

setGenericType

public void setGenericType(java.lang.reflect.Type genericType)
Specified by:
setGenericType in interface InterceptorContext

getMediaType

public MediaType getMediaType()
Specified by:
getMediaType in interface InterceptorContext

setMediaType

public void setMediaType(MediaType mediaType)
Specified by:
setMediaType in interface InterceptorContext


Copyright © 2007-2012 Oracle Corporation. All Rights Reserved. Use is subject to license terms.