Using Spring Request Scoped Beans in Atmosphere Requests - Atmosphere/atmosphere Wiki

If you register the AtmosphereInterceptor described below will enable request scoped beans with Atmosphere requests.

import org.atmosphere.config.service.AtmosphereInterceptorService;
import org.atmosphere.cpr.Action;
import org.atmosphere.cpr.AtmosphereConfig;
import org.atmosphere.cpr.AtmosphereInterceptor;
import org.atmosphere.cpr.AtmosphereResource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
@AtmosphereInterceptorService
public class SpringInteceptor implements AtmosphereInterceptor{

    @Override
    public void configure(AtmosphereConfig config) {

    }

    @Override
    public Action inspect(AtmosphereResource r) {
        ServletRequestAttributes attributes = new ServletRequestAttributes(r.getRequest());
        LocaleContextHolder.setLocale(r.getRequest().getLocale(), true);
        RequestContextHolder.setRequestAttributes(attributes, true);

        return Action.CONTINUE;
    }

    @Override
    public void postInspect(AtmosphereResource r) {
        LocaleContextHolder.resetLocaleContext();
        RequestContextHolder.resetRequestAttributes();
    }

}