Example usage for org.springframework.web.context WebApplicationContext SCOPE_SESSION

List of usage examples for org.springframework.web.context WebApplicationContext SCOPE_SESSION

Introduction

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

Prototype

String SCOPE_SESSION

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

Click Source Link

Document

Scope identifier for session scope: "session".

Usage

From source file:com.sonoport.ContextConfiguration.java

@Bean
@Scope(WebApplicationContext.SCOPE_SESSION)
public UISessionState getUISessionState() {
    return new UISessionState();
}

From source file:com.sonoport.ContextConfiguration.java

@Bean
@Scope(WebApplicationContext.SCOPE_SESSION)
public UserService getUserService() {
    return new UserServiceImpl();
}

From source file:org.wte4j.examples.showcase.server.config.WebContextTestExecutionListener.java

@Override
public void prepareTestInstance(TestContext testContext) {
    if (testContext.getApplicationContext() instanceof GenericApplicationContext) {
        GenericApplicationContext context = (GenericApplicationContext) testContext.getApplicationContext();
        ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
        beanFactory.registerScope(WebApplicationContext.SCOPE_REQUEST, new SimpleThreadScope());
        beanFactory.registerScope(WebApplicationContext.SCOPE_SESSION, new SimpleThreadScope());
    }//w w w  .ja  va 2 s  .co m
}

From source file:br.com.caelum.vraptor.ioc.spring.VRaptorScopeResolver.java

public VRaptorScopeResolver() {
    scopes.put(RequestScoped.class.getName(), WebApplicationContext.SCOPE_REQUEST);
    scopes.put(SessionScoped.class.getName(), WebApplicationContext.SCOPE_SESSION);
    scopes.put(ApplicationScoped.class.getName(), BeanDefinition.SCOPE_SINGLETON);
    scopes.put(PrototypeScoped.class.getName(), BeanDefinition.SCOPE_PROTOTYPE);
}

From source file:br.com.hyperclass.snackbar.config.SnackBarConfig.java

@Bean
@Scope(value = WebApplicationContext.SCOPE_SESSION, proxyMode = ScopedProxyMode.TARGET_CLASS)
public Order getOrder() {
    return new Order(getMenu());
}

From source file:br.com.caelum.vraptor.ioc.spring.VRaptorScopeResolverTest.java

@Test
public void shouldResolveSessionScopedAnnotationToSessionScope() {
    ScopeMetadata scopeMetadata = readScopeMetadata(SessionScopedComponent.class);
    Assert.assertEquals(ScopedProxyMode.NO, scopeMetadata.getScopedProxyMode());
    Assert.assertEquals(WebApplicationContext.SCOPE_SESSION, scopeMetadata.getScopeName());
}

From source file:org.pavlov.springmvcjavaconfig.config.WebConfig.java

@Bean
@Scope(value = WebApplicationContext.SCOPE_SESSION, proxyMode = ScopedProxyMode.TARGET_CLASS)
public User user() {
    //         User user = new User();
    //         user.setUserName("Kaka");
    return new User();
}

From source file:net.wessendorf.spring.scopes.CdiScopeMetadataResolver.java

/**
 * Checks if one of the following CDI scope annoations are used and maps
 * them to their matching Spring scopes:
 * //from   w w w . ja v  a2s.c  om
 * <ul>
 * <li><code>&#064;javax.enterprise.context.RequestScoped</code></li>
 * <li><code>&#064;javax.enterprise.context.SessionScoped</code></li>
 * <li><code>&#064;javax.enterprise.context.ApplicationScoped</code></li>
 * </ul>
 * 
 * If none of them are found it delegates back to the original Spring
 * <code>AnnotationScopeMetadataResolver</code> class. 
 */
@Override
public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) {
    ScopeMetadata metadata = new ScopeMetadata();
    if (definition instanceof AnnotatedBeanDefinition) {
        AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;
        Set<String> annotationTypes = annDef.getMetadata().getAnnotationTypes();

        if (annotationTypes.contains(RequestScoped.class.getName())) {
            metadata.setScopeName(WebApplicationContext.SCOPE_REQUEST);
        } else if (annotationTypes.contains(SessionScoped.class.getName())) {
            metadata.setScopeName(WebApplicationContext.SCOPE_SESSION);
        } else if (annotationTypes.contains(ApplicationScoped.class.getName())) {
            metadata.setScopeName(WebApplicationContext.SCOPE_APPLICATION);
        } else {
            // do the regular Spring stuff..
            return super.resolveScopeMetadata(definition);
        }
    }
    return metadata;
}

From source file:py.una.pol.karaku.test.configuration.BaseTestConfiguration.java

@Bean
public CustomScopeConfigurer configurer() {

    CustomScopeConfigurer toRet = new CustomScopeConfigurer();
    Map<String, Object> map = new HashMap<String, Object>();
    map.put(KarakuBaseConfiguration.SCOPE_CONVERSATION, new SimpleThreadScope());
    map.put(KarakuBaseConfiguration.SCOPE_CONVERSATION_MANUAL, new SimpleThreadScope());
    map.put(WebApplicationContext.SCOPE_SESSION, new SimpleThreadScope());
    toRet.setScopes(map);/*from  ww w.  jav  a  2s .co  m*/
    return toRet;
}