Example usage for org.springframework.web.context.request NativeWebRequest getNativeRequest

List of usage examples for org.springframework.web.context.request NativeWebRequest getNativeRequest

Introduction

In this page you can find the example usage for org.springframework.web.context.request NativeWebRequest getNativeRequest.

Prototype

@Nullable
<T> T getNativeRequest(@Nullable Class<T> requiredType);

Source Link

Document

Return the underlying native request object, if available.

Usage

From source file:architecture.ee.web.community.spring.controller.SocialConnectController.java

protected static void setOutputFormat(NativeWebRequest request) {
    HttpServletRequest httprequest = request.getNativeRequest(HttpServletRequest.class);
    HttpServletResponse httpresponse = request.getNativeResponse(HttpServletResponse.class);
    httprequest.setAttribute("output", "json");
}

From source file:org.sarons.spring4me.web.widget.bind.support.WidgetConfigMethodArgumentResolver.java

private WidgetConfig getWidgetConfig(NativeWebRequest webRequest) {
    HttpWidgetRequest widgetRequest = webRequest.getNativeRequest(HttpWidgetRequest.class);
    return WidgetConfigUtils.getWidgetConfig(widgetRequest);
}

From source file:com.greglturnquist.spring.social.ecobee.SimpleSignInAdapter.java

private String extractOriginalUrl(NativeWebRequest request) {

    HttpServletRequest nativeRequest = request.getNativeRequest(HttpServletRequest.class);
    HttpServletResponse nativeResponse = request.getNativeResponse(HttpServletResponse.class);
    SavedRequest saved = requestCache.getRequest(nativeRequest, nativeResponse);
    if (saved == null) {
        return null;
    }//from  w  w  w.j a  v  a2 s  .c  om
    requestCache.removeRequest(nativeRequest, nativeResponse);
    removeAuthenticationAttributes(nativeRequest.getSession(false));
    return saved.getRedirectUrl();
}

From source file:com.github.zhanhb.download.spring.PathDownloaderHandler.java

@Override
public void handleReturnValue(Object returnValue, MethodParameter returnType,
        ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
    HttpServletRequest request = webRequest.getNativeRequest(HttpServletRequest.class);
    HttpServletResponse response = webRequest.getNativeResponse(HttpServletResponse.class);
    ToDownload toDownload = returnType.getMethodAnnotation(ToDownload.class);

    PathPartial d = toDownload.attachment() ? downloader : viewer;
    d.service(request, response, Path.class.cast(returnValue));
    mavContainer.setRequestHandled(true);
}

From source file:org.jnap.core.mvc.bind.AtmosphereResourceArgumentResolver.java

protected AtmosphereResource getAtmosphereResource(NativeWebRequest webRequest, boolean session) {
    HttpServletRequest req = webRequest.getNativeRequest(HttpServletRequest.class);
    AtmosphereResource resource = null;//from  www.  j a  v  a2s .c o m

    if (session) {
        if ((Boolean) req.getAttribute(FrameworkConfig.SUPPORT_SESSION)) {
            //            resource = (AtmosphereResource) req.getSession().getAttribute(AtmosphereFilter.SUSPENDED_RESOURCE); TODO check
        }
    }

    if (resource == null) {
        resource = (AtmosphereResource) req.getAttribute(FrameworkConfig.ATMOSPHERE_RESOURCE);
    }

    return resource;
}

From source file:com.faujnet.signin.adapter.SimpleSignInAdapter.java

private String extractOriginalUrl(NativeWebRequest request) {
    HttpServletRequest nativeReq = request.getNativeRequest(HttpServletRequest.class);
    HttpServletResponse nativeRes = request.getNativeResponse(HttpServletResponse.class);
    SavedRequest saved = requestCache.getRequest(nativeReq, nativeRes);
    if (saved == null) {
        return null;
    }/*from  ww w .ja v a  2  s . c  o m*/
    requestCache.removeRequest(nativeReq, nativeRes);
    removeAutheticationAttributes(nativeReq.getSession(false));
    return saved.getRedirectUrl();
}

From source file:org.chtijbug.drools.platform.web.annotation.JsonPathArgumentResolver.java

private String getRequestBody(NativeWebRequest webRequest) {
    HttpServletRequest servletRequest = webRequest.getNativeRequest(HttpServletRequest.class);
    String jsonBody = (String) servletRequest.getAttribute(JSONBODYATTRIBUTE);
    if (jsonBody == null) {
        try {//w ww  . ja  v  a 2  s .c  o  m
            String body = IOUtils.toString(servletRequest.getInputStream());
            servletRequest.setAttribute(JSONBODYATTRIBUTE, body);
            return body;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    return jsonBody;

}

From source file:org.easit.core.controllers.signin.SimpleSignInAdapter.java

public String signIn(String localUserId, NativeWebRequest request) {
    HttpServletRequest req = request.getNativeRequest(HttpServletRequest.class);
    Authentication auth = SignInUtils.signin(localUserId);
    String originalUrl = extractOriginalUrl(request);

    try {//from w ww .  j a v  a 2  s.  c  om
        loginSuccess.setAttributesInSession(req, auth);
    } catch (Exception e) {
        logger.error(e.getMessage());
    }
    return originalUrl;
}

From source file:com.wesley_acheson.spring.BackingBeanValueResolver.java

@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
        NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
    return webRequest.getNativeRequest(HttpServletRequest.class)
            .getAttribute(BackingBeanUrlHandlerMapper.BACKING_BEAN_ATTRIBUTE);
}

From source file:org.springframework.cloud.aws.messaging.endpoint.AbstractNotificationMessageHandlerMethodArgumentResolver.java

private HttpInputMessage createInputMessage(NativeWebRequest webRequest) throws IOException {
    HttpServletRequest servletRequest = webRequest.getNativeRequest(HttpServletRequest.class);
    return new ServletServerHttpRequest(servletRequest);
}