Class ResponseWriter
java.lang.Object
org.glassfish.jersey.servlet.internal.ResponseWriter
- All Implemented Interfaces:
ContainerResponseWriter
An internal implementation of
ContainerResponseWriter for Servlet containers.
The writer depends on provided AsyncContextDelegate to support async functionality.- Author:
- Paul Sandoz, Jakub Podlesak, Martin Matula, Libor Kramolis
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.glassfish.jersey.server.spi.ContainerResponseWriter
ContainerResponseWriter.TimeoutHandler -
Constructor Summary
ConstructorsConstructorDescriptionResponseWriter(boolean useSetStatusOn404, boolean configSetStatusOverSendError, jakarta.servlet.http.HttpServletResponse response, AsyncContextDelegate asyncExt, ScheduledExecutorService timeoutTaskExecutor) Creates a new instance to write a single Jersey response. -
Method Summary
Modifier and TypeMethodDescriptionvoidcommit()booleanvoidintProvides response status captured whenwriteResponseStatusAndHeaders(long, org.glassfish.jersey.server.ContainerResponse)has been invoked.booleanvoidsetSuspendTimeout(long timeOut, TimeUnit timeUnit) booleansuspend(long timeOut, TimeUnit timeUnit, ContainerResponseWriter.TimeoutHandler timeoutHandler) writeResponseStatusAndHeaders(long contentLength, ContainerResponse responseContext)
-
Constructor Details
-
ResponseWriter
public ResponseWriter(boolean useSetStatusOn404, boolean configSetStatusOverSendError, jakarta.servlet.http.HttpServletResponse response, AsyncContextDelegate asyncExt, ScheduledExecutorService timeoutTaskExecutor) Creates a new instance to write a single Jersey response.- Parameters:
useSetStatusOn404- true if status should be written explicitly when 404 is returnedconfigSetStatusOverSendError- iftruemethodHttpServletResponse.setStatus(int)is used overHttpServletResponse.sendError(int, java.lang.String)response- original HttpResponseRequestasyncExt- delegate to use for async features implementationtimeoutTaskExecutor- Jersey runtime executor used for background execution of timeout handling tasks.
-
-
Method Details
-
suspend
public boolean suspend(long timeOut, TimeUnit timeUnit, ContainerResponseWriter.TimeoutHandler timeoutHandler) - Specified by:
suspendin interfaceContainerResponseWriter
-
setSuspendTimeout
- Specified by:
setSuspendTimeoutin interfaceContainerResponseWriter- Throws:
IllegalStateException
-
writeResponseStatusAndHeaders
public OutputStream writeResponseStatusAndHeaders(long contentLength, ContainerResponse responseContext) throws ContainerException - Specified by:
writeResponseStatusAndHeadersin interfaceContainerResponseWriter- Throws:
ContainerException
-
commit
public void commit()- Specified by:
commitin interfaceContainerResponseWriter
-
failure
- Specified by:
failurein interfaceContainerResponseWriter
-
enableResponseBuffering
public boolean enableResponseBuffering()- Specified by:
enableResponseBufferingin interfaceContainerResponseWriter
-
getResponseStatus
public int getResponseStatus()Provides response status captured whenwriteResponseStatusAndHeaders(long, org.glassfish.jersey.server.ContainerResponse)has been invoked. The method will block if the write method has not been called yet.- Returns:
- response status
-
responseContextResolved
public boolean responseContextResolved() -
getResponseContext
-