All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.frameworkset.web.request.async.TimeoutDeferredResultProcessingInterceptor Maven / Gradle / Ivy

Go to download

bboss is a j2ee framework include aop/ioc,mvc,persistent,taglib,rpc,event ,bean-xml serializable and so on.http://www.bbossgroups.com

The newest version!
package org.frameworkset.web.request.async;

import javax.servlet.http.HttpServletResponse;

import org.frameworkset.http.HttpStatus;
import org.frameworkset.web.servlet.mvc.NativeWebRequest;

/**
 * Sends a 503 (SERVICE_UNAVAILABLE) in case of a timeout if the response is not
 * already committed. Registered at the end, after all other interceptors and
 * therefore invoked only if no other interceptor handles the timeout.
 *
 * 

Note that according to RFC 7231, a 503 without a 'Retry-After' header is * interpreted as a 500 error and the client should not retry. Applications * can install their own interceptor to handle a timeout and add a 'Retry-After' * header if necessary. * * @author Rossen Stoyanchev * @since 3.2 */ public class TimeoutDeferredResultProcessingInterceptor extends DeferredResultProcessingInterceptorAdapter { @Override public boolean handleTimeout(NativeWebRequest request, DeferredResult deferredResult) throws Exception { HttpServletResponse servletResponse = request.getNativeResponse(HttpServletResponse.class); if (!servletResponse.isCommitted()) { servletResponse.sendError(HttpStatus.SERVICE_UNAVAILABLE.value()); } return false; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy