Class AbstractWriterInterceptorContext
- java.lang.Object
-
- org.jboss.resteasy.core.interception.jaxrs.AbstractWriterInterceptorContext
-
- All Implemented Interfaces:
InterceptorContext,WriterInterceptorContext,AsyncWriterInterceptorContext
- Direct Known Subclasses:
ClientWriterInterceptorContext,ServerWriterInterceptorContext
public abstract class AbstractWriterInterceptorContext extends Object implements WriterInterceptorContext, AsyncWriterInterceptorContext
- Version:
- $Revision: 1 $
- Author:
- Bill Burke
-
-
Field Summary
Fields Modifier and Type Field Description protected Annotation[]annotationsprotected Objectentityprotected TypegenericTypeprotected MultivaluedMap<String,Object>headersprotected intindexprotected WriterInterceptor[]interceptorsprotected MediaTypemediaTypeprotected OutputStreamoutputStreamprotected ResteasyProviderFactoryproviderFactoryprotected booleanrequireAsyncIOprotected RESTEasyTracingLoggertracingLoggerprotected Classtype
-
Constructor Summary
Constructors Constructor Description AbstractWriterInterceptorContext(WriterInterceptor[] interceptors, Annotation[] annotations, Object entity, Type genericType, MediaType mediaType, Class type, OutputStream outputStream, ResteasyProviderFactory providerFactory, MultivaluedMap<String,Object> headers)Deprecated.AbstractWriterInterceptorContext(WriterInterceptor[] interceptors, Annotation[] annotations, Object entity, Type genericType, MediaType mediaType, Class type, OutputStream outputStream, ResteasyProviderFactory providerFactory, MultivaluedMap<String,Object> headers, RESTEasyTracingLogger logger)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description CompletionStage<Void>asyncProceed()Proceed to the next interceptor in the chain.Annotation[]getAnnotations()Get an array of the annotations formally declared on the artifact that initiated the intercepted entity provider invocation.AsyncOutputStreamgetAsyncOutputStream()Get the async output stream for the object to be written.ObjectgetEntity()Get object to be written as HTTP entity.TypegetGenericType()Get the type of the object to be produced or written.MultivaluedMap<String,Object>getHeaders()Get mutable map of HTTP headers.MediaTypegetMediaType()Get media type of HTTP entity.OutputStreamgetOutputStream()Get the output stream for the object to be written.intgetProcessedInterceptorCount()CompletionStage<Void>getStarted()ClassgetType()Get Java type supported by corresponding message body provider.protected MessageBodyWritergetWriter()protected booleanpreferAsyncIo()voidproceed()Proceed to the next interceptor in the chain.protected abstract MessageBodyWriterresolveWriter()voidsetAnnotations(Annotation[] annotations)Update annotations on the formal declaration of the artifact that initiated the intercepted entity provider invocation.voidsetAsyncOutputStream(AsyncOutputStream asyncOutputStream)Set a new async output stream for the object to be written.voidsetEntity(Object entity)Update object to be written as HTTP entity.voidsetGenericType(Type genericType)Update type of the object to be produced or written.voidsetMediaType(MediaType mediaType)Update media type of HTTP entity.voidsetOutputStream(OutputStream outputStream)Set a new output stream for the object to be written.voidsetType(Class type)Update Java type before calling message body provider.CompletionStage<Void>syncProceed()protected voidtraceAfter(WriterInterceptor interceptor)protected voidtraceBefore(WriterInterceptor interceptor)protected CompletionStage<Void>writeTo(MessageBodyWriter writer)protected CompletionStage<Void>writeTo(AsyncMessageBodyWriter writer)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jakarta.ws.rs.ext.InterceptorContext
getProperty, getPropertyNames, hasProperty, removeProperty, setProperty
-
-
-
-
Field Detail
-
tracingLogger
protected RESTEasyTracingLogger tracingLogger
-
interceptors
protected WriterInterceptor[] interceptors
-
requireAsyncIO
protected boolean requireAsyncIO
-
entity
protected Object entity
-
type
protected Class type
-
genericType
protected Type genericType
-
annotations
protected Annotation[] annotations
-
mediaType
protected MediaType mediaType
-
headers
protected MultivaluedMap<String,Object> headers
-
outputStream
protected OutputStream outputStream
-
index
protected int index
-
providerFactory
protected ResteasyProviderFactory providerFactory
-
-
Constructor Detail
-
AbstractWriterInterceptorContext
@Deprecated public AbstractWriterInterceptorContext(WriterInterceptor[] interceptors, Annotation[] annotations, Object entity, Type genericType, MediaType mediaType, Class type, OutputStream outputStream, ResteasyProviderFactory providerFactory, MultivaluedMap<String,Object> headers)
Deprecated.
-
AbstractWriterInterceptorContext
public AbstractWriterInterceptorContext(WriterInterceptor[] interceptors, Annotation[] annotations, Object entity, Type genericType, MediaType mediaType, Class type, OutputStream outputStream, ResteasyProviderFactory providerFactory, MultivaluedMap<String,Object> headers, RESTEasyTracingLogger logger)
-
-
Method Detail
-
getProcessedInterceptorCount
public int getProcessedInterceptorCount()
-
getEntity
public Object getEntity()
Description copied from interface:WriterInterceptorContextGet object to be written as HTTP entity.- Specified by:
getEntityin interfaceAsyncWriterInterceptorContext- Specified by:
getEntityin interfaceWriterInterceptorContext- Returns:
- object to be written as HTTP entity.
-
setEntity
public void setEntity(Object entity)
Description copied from interface:WriterInterceptorContextUpdate object to be written as HTTP entity.- Specified by:
setEntityin interfaceAsyncWriterInterceptorContext- Specified by:
setEntityin interfaceWriterInterceptorContext- Parameters:
entity- new object to be written.
-
getType
public Class getType()
Description copied from interface:InterceptorContextGet Java type supported by corresponding message body provider.- Specified by:
getTypein interfaceInterceptorContext- Returns:
- java type supported by provider
-
setType
public void setType(Class type)
Description copied from interface:InterceptorContextUpdate Java type before calling message body provider.- Specified by:
setTypein interfaceInterceptorContext- Parameters:
type- java type for provider
-
getGenericType
public Type getGenericType()
Description copied from interface:InterceptorContextGet the type of the object to be produced or written.- Specified by:
getGenericTypein interfaceInterceptorContext- Returns:
- type of object produced or written
-
setGenericType
public void setGenericType(Type genericType)
Description copied from interface:InterceptorContextUpdate type of the object to be produced or written.- Specified by:
setGenericTypein interfaceInterceptorContext- Parameters:
genericType- new type for object
-
getAnnotations
public Annotation[] getAnnotations()
Description copied from interface:InterceptorContextGet an array of the annotations formally declared on the artifact that initiated the intercepted entity provider invocation. E.g. if the message body is to be converted into a method parameter, this will be the annotations on that parameter returned byMethod.getParameterAnnotations(); if the server-side response entity instance is to be converted into an output stream, this will be the annotations on the matched resource method returned byMethod.getAnnotations(). This method may return an empty array in case the interceptor is not invoked in a context of any particular resource method (e.g. as part of the client API), but will never returnnull.- Specified by:
getAnnotationsin interfaceInterceptorContext- Returns:
- annotations declared on the artifact that initiated the intercepted entity provider invocation.
-
setAnnotations
public void setAnnotations(Annotation[] annotations)
Description copied from interface:InterceptorContextUpdate annotations on the formal declaration of the artifact that initiated the intercepted entity provider invocation. Calling this method has no effect in the client API.- Specified by:
setAnnotationsin interfaceInterceptorContext- Parameters:
annotations- updated annotations declarataion of the artifact that initiated the intercepted entity provider invocation. Must not benull.
-
getMediaType
public MediaType getMediaType()
Description copied from interface:InterceptorContextGet media type of HTTP entity.- Specified by:
getMediaTypein interfaceInterceptorContext- Returns:
- media type of HTTP entity
-
setMediaType
public void setMediaType(MediaType mediaType)
Description copied from interface:InterceptorContextUpdate media type of HTTP entity.- Specified by:
setMediaTypein interfaceInterceptorContext- Parameters:
mediaType- new type for HTTP entity
-
getHeaders
public MultivaluedMap<String,Object> getHeaders()
Description copied from interface:WriterInterceptorContextGet mutable map of HTTP headers.- Specified by:
getHeadersin interfaceAsyncWriterInterceptorContext- Specified by:
getHeadersin interfaceWriterInterceptorContext- Returns:
- map of HTTP headers.
-
getOutputStream
public OutputStream getOutputStream()
Description copied from interface:WriterInterceptorContextGet the output stream for the object to be written. The JAX-RS runtime is responsible for closing the output stream.- Specified by:
getOutputStreamin interfaceWriterInterceptorContext- Returns:
- output stream for the object to be written.
-
setOutputStream
public void setOutputStream(OutputStream outputStream)
Description copied from interface:WriterInterceptorContextSet a new output stream for the object to be written. For example, by wrapping it with another output stream. The JAX-RS runtime is responsible for closing the output stream that is set.- Specified by:
setOutputStreamin interfaceWriterInterceptorContext- Parameters:
outputStream- new output stream for the object to be written.
-
setAsyncOutputStream
public void setAsyncOutputStream(AsyncOutputStream asyncOutputStream)
Description copied from interface:AsyncWriterInterceptorContextSet a new async output stream for the object to be written. For example, by wrapping it with another async output stream. The runtime is responsible for closing the async output stream that is set.- Specified by:
setAsyncOutputStreamin interfaceAsyncWriterInterceptorContext- Parameters:
asyncOutputStream- new async output stream for the object to be written.
-
getAsyncOutputStream
public AsyncOutputStream getAsyncOutputStream()
Description copied from interface:AsyncWriterInterceptorContextGet the async output stream for the object to be written. The runtime is responsible for closing the output stream.- Specified by:
getAsyncOutputStreamin interfaceAsyncWriterInterceptorContext- Returns:
- async output stream for the object to be written.
-
getStarted
public CompletionStage<Void> getStarted()
-
preferAsyncIo
protected boolean preferAsyncIo()
-
asyncProceed
public CompletionStage<Void> asyncProceed()
Description copied from interface:AsyncWriterInterceptorContextProceed to the next interceptor in the chain. Interceptors MUST explicitly call this method to continue the execution chain; the call to this method in the last interceptor of the chain will invoke the wrappedAsyncMessageBodyWriter.asyncWriteTo(T, java.lang.Class<?>, java.lang.reflect.Type, java.lang.annotation.Annotation[], jakarta.ws.rs.core.MediaType, jakarta.ws.rs.core.MultivaluedMap<java.lang.String, java.lang.Object>, org.jboss.resteasy.spi.AsyncOutputStream)method.- Specified by:
asyncProceedin interfaceAsyncWriterInterceptorContext- Returns:
- a
CompletionStageindicating completion.
-
proceed
public void proceed() throws IOException, WebApplicationExceptionDescription copied from interface:WriterInterceptorContextProceed to the next interceptor in the chain. Interceptors MUST explicitly call this method to continue the execution chain; the call to this method in the last interceptor of the chain will invoke the wrappedMessageBodyWriter.writeTo(T, java.lang.Class<?>, java.lang.reflect.Type, java.lang.annotation.Annotation[], jakarta.ws.rs.core.MediaType, jakarta.ws.rs.core.MultivaluedMap<java.lang.String, java.lang.Object>, java.io.OutputStream)method.- Specified by:
proceedin interfaceWriterInterceptorContext- Throws:
IOException- if an IO error arises or is thrown by the wrappedMessageBodyWriter.writeTomethod.WebApplicationException- thrown by the wrappedMessageBodyWriter.writeTomethod.
-
syncProceed
public CompletionStage<Void> syncProceed() throws IOException, WebApplicationException
- Throws:
IOExceptionWebApplicationException
-
traceBefore
protected final void traceBefore(WriterInterceptor interceptor)
-
traceAfter
protected final void traceAfter(WriterInterceptor interceptor)
-
writeTo
protected CompletionStage<Void> writeTo(MessageBodyWriter writer) throws IOException
- Throws:
IOException
-
writeTo
protected CompletionStage<Void> writeTo(AsyncMessageBodyWriter writer)
-
getWriter
protected MessageBodyWriter getWriter()
-
resolveWriter
protected abstract MessageBodyWriter resolveWriter()
-
-