Example usage for org.springframework.web.method.annotation SessionAttributesHandler SessionAttributesHandler

List of usage examples for org.springframework.web.method.annotation SessionAttributesHandler SessionAttributesHandler

Introduction

In this page you can find the example usage for org.springframework.web.method.annotation SessionAttributesHandler SessionAttributesHandler.

Prototype

public SessionAttributesHandler(Class<?> handlerType, SessionAttributeStore sessionAttributeStore) 

Source Link

Document

Create a new session attributes handler.

Usage

From source file:co.paralleluniverse.springframework.web.servlet.mvc.method.annotation.FiberRequestMappingHandlerAdapter.java

/**
 * Return the {@link SessionAttributesHandler} instance for the given
 * handler type, never {@code null}./*from   ww w  .j  ava  2  s .  c o  m*/
 */
private SessionAttributesHandler getSessionAttributesHandler(HandlerMethod handlerMethod) {
    Class<?> handlerType = handlerMethod.getBeanType();
    SessionAttributesHandler sessionAttrHandler = null;
    synchronized (this.sessionAttributesHandlerCache) {
        sessionAttrHandler = this.sessionAttributesHandlerCache.get(handlerType);
        if (sessionAttrHandler == null) {
            sessionAttrHandler = new SessionAttributesHandler(handlerType, sessionAttributeStore);
            this.sessionAttributesHandlerCache.put(handlerType, sessionAttrHandler);
        }
    }
    return sessionAttrHandler;
}

From source file:org.springframework.web.method.annotation.ModelFactoryOrderingTests.java

private void runTest(Object controller) throws Exception {
    HandlerMethodArgumentResolverComposite resolvers = new HandlerMethodArgumentResolverComposite();
    resolvers.addResolver(new ModelAttributeMethodProcessor(false));
    resolvers.addResolver(new ModelMethodProcessor());
    WebDataBinderFactory dataBinderFactory = new DefaultDataBinderFactory(null);

    Class<?> type = controller.getClass();
    Set<Method> methods = MethodIntrospector.selectMethods(type, METHOD_FILTER);
    List<InvocableHandlerMethod> modelMethods = new ArrayList<>();
    for (Method method : methods) {
        InvocableHandlerMethod modelMethod = new InvocableHandlerMethod(controller, method);
        modelMethod.setHandlerMethodArgumentResolvers(resolvers);
        modelMethod.setDataBinderFactory(dataBinderFactory);
        modelMethods.add(modelMethod);//ww w  .j  a v  a  2s .  c  o  m
    }
    Collections.shuffle(modelMethods);

    SessionAttributesHandler sessionHandler = new SessionAttributesHandler(type, this.sessionAttributeStore);
    ModelFactory factory = new ModelFactory(modelMethods, dataBinderFactory, sessionHandler);
    factory.initModel(this.webRequest, this.mavContainer, new HandlerMethod(controller, "handle"));
    if (logger.isDebugEnabled()) {
        StringBuilder sb = new StringBuilder();
        for (String name : getInvokedMethods()) {
            sb.append(" >> ").append(name);
        }
        logger.debug(sb);
    }
}