Example usage for org.springframework.web.context.request RequestAttributes SCOPE_SESSION

List of usage examples for org.springframework.web.context.request RequestAttributes SCOPE_SESSION

Introduction

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

Prototype

int SCOPE_SESSION

To view the source code for org.springframework.web.context.request RequestAttributes SCOPE_SESSION.

Click Source Link

Document

Constant that indicates session scope.

Usage

From source file:com.github.dactiv.common.spring.mvc.SpringMvcHolder.java

/**
 * ?sessiont attribute/*ww  w .  j  a  v  a  2  s. co  m*/
 * 
 * @param name ??
 * 
 * @return Object
 */
public static <T> T getSessionAttribute(String name) {
    return (T) getAttribute(name, RequestAttributes.SCOPE_SESSION);
}

From source file:io.pivotal.cla.mvc.support.ImportedSignaturesSessionAttr.java

public boolean getValue() {
    return Boolean.TRUE.equals(webRequest.getAttribute(ATTR_NAME, RequestAttributes.SCOPE_SESSION));
}

From source file:io.pivotal.cla.mvc.support.ImportedSignaturesSessionAttr.java

public void setValue(boolean value) {
    if (value) {//w ww .  ja va2 s. c  om
        webRequest.setAttribute(ATTR_NAME, value, RequestAttributes.SCOPE_SESSION);
    } else {
        webRequest.removeAttribute(ATTR_NAME, RequestAttributes.SCOPE_SESSION);
    }
}

From source file:com.github.dactiv.common.spring.mvc.SpringMvcHolder.java

/**
 * session attribute/*w  ww.jav  a2s.  c  om*/
 * 
 * @param name ??
 * @param value 
 */
public static void addSessionAttribute(String name, Object value) {
    addAttribute(name, value, RequestAttributes.SCOPE_SESSION);
}

From source file:uk.ac.ebi.intact.editor.util.HybridSessionThreadScope.java

@Override
public Object get(String name, ObjectFactory objectFactory) {
    Object scopedObject;/* w w w .ja  va 2s.  com*/

    if (RequestContextHolder.getRequestAttributes() != null) {
        Object mutex = RequestContextHolder.currentRequestAttributes().getSessionMutex();

        synchronized (mutex) {
            RequestAttributes attributes = RequestContextHolder.currentRequestAttributes();
            scopedObject = attributes.getAttribute(name, RequestAttributes.SCOPE_SESSION);

            if (scopedObject == null) {
                scopedObject = super.get(name, objectFactory);
                attributes.setAttribute(name, scopedObject, RequestAttributes.SCOPE_SESSION);
            }
        }
    } else {
        scopedObject = super.get(name, objectFactory);
    }

    return scopedObject;
}

From source file:org.jasig.portlet.calendar.adapter.exchange.ExchangeWsCredentialsProvider.java

@Override
public Credentials getCredentials(AuthScope authscope) {
    final RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
    final Credentials credentials = (Credentials) requestAttributes.getAttribute(
            ExchangeWsCredentialsProvider.EXCHANGE_CREDENTIALS_ATTRIBUTE, RequestAttributes.SCOPE_SESSION);
    return credentials;
}

From source file:org.vaadin.spring.internal.UIScope.java

private UIStore getUIStore() {
    final String attributeName = UIStore.class.getCanonicalName();
    UIStore uiStore = (UIStore) RequestContextHolder.currentRequestAttributes().getAttribute(attributeName,
            RequestAttributes.SCOPE_SESSION);
    if (uiStore == null) {
        uiStore = new UIStore();
        RequestContextHolder.currentRequestAttributes().setAttribute(attributeName, uiStore,
                RequestAttributes.SCOPE_SESSION);
    }//from ww w .jav  a  2 s .co  m
    return uiStore;
}

From source file:com.naver.timetable.resolver.UserHandlerMethodArgumentResolver.java

/**
 * @param parameter/*from   w  w w  . ja va 2 s. c o  m*/
 * @param mavContainer
 * @param webRequest
 * @param binderFactory
 * @return
 * @throws Exception
 * @see org.springframework.web.method.support.HandlerMethodArgumentResolver#resolveArgument(org.springframework.core.MethodParameter, org.springframework.web.method.support.ModelAndViewContainer, org.springframework.web.context.request.NativeWebRequest, org.springframework.web.bind.support.WebDataBinderFactory)
 */
@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
        NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
    User user = (User) webRequest.getAttribute("user", RequestAttributes.SCOPE_SESSION);
    return user;
}

From source file:org.jasig.portlet.calendar.adapter.exchange.ExchangeHttpWebServiceMessageSenderTest.java

@Before
public void setUp() throws Exception {
    sender = new ExchangeHttpWebServiceMessageSender();
    sender.setConnectionTimeout(1000);//from   w ww . j  ava2s  .c o m
    sender.setMaxConnections(5);
    sender.setReadTimeout(1000);
    sender.afterPropertiesSet();

    attr = new PortletRequestAttributes(new MockPortletRequest());
    attr.setAttribute(ExchangeHttpWebServiceMessageSender.EXCHANGE_CREDENTIALS_ATTRIBUTE,
            new UsernamePasswordCredentials("user", "pass"), RequestAttributes.SCOPE_SESSION);
    RequestContextHolder.setRequestAttributes(attr);

}

From source file:com.seajas.search.codex.social.interceptor.AbstractConnectInterceptor.java

/**
 * Add the username-state parameter so that we can track this connection by its username.
 * //from www .j a v a2s  . co  m
 * @param parameters
 * @param request
 */
protected void addState(final MultiValueMap<String, String> parameters, final WebRequest request) {
    String username = request.getParameter("username");

    if (logger.isInfoEnabled())
        logger.info("Setting state username in session to '" + username + "' for access token request");

    request.setAttribute(REQUEST_STATE_USERNAME, username, RequestAttributes.SCOPE_SESSION);
}