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

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

Introduction

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

Prototype

String SCOPE_REQUEST

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

Click Source Link

Document

Scope identifier for request scope: "request".

Usage

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  . j  a  v a2 s .com
}

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.caelum.vraptor.ioc.spring.VRaptorScopeResolverTest.java

@Test
public void shouldResolveToRequestScopeByDefault() {
    ScopeMetadata scopeMetadata = readScopeMetadata(DummyComponent.class);
    Assert.assertEquals(ScopedProxyMode.NO, scopeMetadata.getScopedProxyMode());
    Assert.assertEquals(WebApplicationContext.SCOPE_REQUEST, scopeMetadata.getScopeName());
}

From source file:io.neba.core.spring.applicationcontext.configuration.RequestScopeConfiguratorTest.java

private void verifyRequestScopeIsConfigured() {
    verify(this.beanFactory).registerScope(eq(WebApplicationContext.SCOPE_REQUEST), isA(RequestScope.class));
}

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

@Test
public void shouldResolveRequestScopedAnnotationToRequestScope() {
    ScopeMetadata scopeMetadata = readScopeMetadata(RequestScopedComponent.class);
    Assert.assertEquals(ScopedProxyMode.NO, scopeMetadata.getScopedProxyMode());
    Assert.assertEquals(WebApplicationContext.SCOPE_REQUEST, scopeMetadata.getScopeName());
}

From source file:at.ac.univie.isc.asio.brood.BroodComponents.java

@Bean
@Scope(value = WebApplicationContext.SCOPE_REQUEST, proxyMode = ScopedProxyMode.INTERFACES)
public DatasetHolder activeDataset() {
    return new DatasetHolder();
}

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

private ScopeMetadata requestScopeAsDefault() {
    ScopeMetadata singleton = new ScopeMetadata();
    singleton.setScopeName(WebApplicationContext.SCOPE_REQUEST);
    return singleton;
}

From source file:pl.chilldev.web.spring.config.HandlePageModelBeanDefinitionParser.java

/**
 * {@inheritDoc}/*from w  w w.  j ava  2s. co m*/
 * @since 0.0.1
 */
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
    // page model bean prototype
    GenericBeanDefinition pageMetaModelBean = new GenericBeanDefinition();
    pageMetaModelBean.setBeanClass(PageMetaModel.class);
    pageMetaModelBean.setScope(WebApplicationContext.SCOPE_REQUEST);
    pageMetaModelBean.setFactoryBeanName(PageMetaModelFactoryBean.class.getName());
    pageMetaModelBean.setFactoryMethodName(HandlePageModelBeanDefinitionParser.METHOD_CREATEPAGEMETAMODEL);
    parserContext.getRegistry().registerBeanDefinition(PageMetaModel.class.getName(), pageMetaModelBean);

    parserContext.getRegistry().registerBeanDefinition(PageMetaModelFactoryBean.class.getName(),
            this.pageMetaModelFactoryBean);

    // XHTML switch needs to be handled with generator bean
    if (element.hasAttribute(HandlePageModelBeanDefinitionParser.ATTRIBUTE_XHTML)) {
        boolean xhtml = element.getAttribute(HandlePageModelBeanDefinitionParser.ATTRIBUTE_XHTML)
                .equals("true");

        GenericBeanDefinition generatorBean = new GenericBeanDefinition();
        generatorBean.setBeanClass(Generator.class);

        this.logger.info("Setting markup generator XHTML mode to {}.", xhtml);
        ConstructorArgumentValues arguments = generatorBean.getConstructorArgumentValues();
        arguments.addGenericArgumentValue(xhtml);

        parserContext.getRegistry().registerBeanDefinition(Generator.class.getName(), generatorBean);

        arguments = pageMetaModelBean.getConstructorArgumentValues();
        arguments.addGenericArgumentValue(new RuntimeBeanReference(Generator.class.getName()));
    }

    // register new resolving strategy
    PageMetaModelContextUtils.setPageMetaModelResolver(new SpringBeansJspPageMetaModelResolver());
    pl.chilldev.web.faces.context.PageMetaModelContextUtils
            .setPageMetaModelResolver(new SpringBeansFacesPageMetaModelResolver());

    return null;
}

From source file:devbury.threadscope.IntegrationTest.java

@Bean
@Scope(WebApplicationContext.SCOPE_REQUEST)
public ValueBean valueBean() {
    return new ValueBean();
}

From source file:org.vaadin.spring.config.VaadinExtensionsConfiguration.java

/**
 * Vaadin Http Service/*  w w w  .ja  va 2 s . c o  m*/
 * Allow access to HttpRequest / HttpResponse
 */
@Bean
@Scope(value = org.springframework.web.context.WebApplicationContext.SCOPE_REQUEST, proxyMode = ScopedProxyMode.INTERFACES)
HttpService httpService() {
    return new VaadinHttpService();
}