Example usage for org.springframework.beans.factory.config CustomScopeConfigurer setScopes

List of usage examples for org.springframework.beans.factory.config CustomScopeConfigurer setScopes

Introduction

In this page you can find the example usage for org.springframework.beans.factory.config CustomScopeConfigurer setScopes.

Prototype

public void setScopes(Map<String, Object> scopes) 

Source Link

Document

Specify the custom scopes that are to be registered.

Usage

From source file:de.beyondjava.Main.java

/**
 * Allows the use of @Scope("view") on Spring @Component, @Service and @Controller
 * beans// w  w  w  . j ava 2 s  .  c o  m
 */
@Bean
public static CustomScopeConfigurer scopeConfigurer() {
    CustomScopeConfigurer configurer = new CustomScopeConfigurer();
    HashMap<String, Object> hashMap = new HashMap<String, Object>();
    hashMap.put("view", viewScope());
    configurer.setScopes(hashMap);
    return configurer;
}

From source file:com.sunkur.springjavafxcontroller.config.AppContextConfig.java

@Bean
public CustomScopeConfigurer getCustomScopeConfigurer() {
    CustomScopeConfigurer configurer = new CustomScopeConfigurer();
    final Map<String, Object> scopeMap = new HashMap<>();
    scopeMap.put("screen", screenScope());
    configurer.setScopes(scopeMap);
    return configurer;
}

From source file:com.github.javarch.jsf.config.JavaServerFacesConfig.java

/**
 * /*  www  . jav  a 2  s .c o m*/
 * Registra escopos personalizveis para aplicao. Esta configurao possui
 * a equivalente em XML como:
 * 
 * <pre>
 * {@code
 *   <bean class="org.springframework.beans.factory.config.CustomScopeConfigurer">
 *       <property name="scopes">
 *           <map>
 *               <entry key="view">
 *                   <bean class="com.github.luksrn.webapp.core.spring.support.ViewScope"/>
 *               </entry>
 *               <entry key="thread">
 *                   <bean class="com.github.luksrn.webapp.core.spring.support.ThreadScope"/>
 *               </entry>
 *           </map>
 *       </property>
 *   </bean>
 *   }   
 * </pre>
 * 
 * 
 * @return
 */
@Bean
public CustomScopeConfigurer escoposPersonalizaveis() {
    CustomScopeConfigurer custom = new CustomScopeConfigurer();

    Map<String, Object> escopos = new HashMap<String, Object>();
    escopos.put("view", new ViewScope());
    custom.setScopes(escopos);

    return custom;
}

From source file:com.freebox.engeneering.application.system.configuration.WebFlowContext.java

@Bean
public CustomScopeConfigurer customScopeConfigurer() {
    final CustomScopeConfigurer customScopeConfigurer = new CustomScopeConfigurer();
    final Map<String, Object> hashMap = new HashMap<String, Object>();
    hashMap.put(ApplicationScope.NAME, new ApplicationScope());
    customScopeConfigurer.setScopes(hashMap);
    return customScopeConfigurer;
}

From source file:com.visural.domo.spring.TransactionImplTest.java

private AnnotationConfigApplicationContext springBootstrap(ConnectionSource source)
        throws BeansException, IllegalStateException {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.register(AnnotationAwareAspectJAutoProxyCreator.class);
    CustomScopeConfigurer conf = new CustomScopeConfigurer();
    Map<String, Object> scopes = new HashMap<String, Object>();
    TransactionScope scope = new TransactionScope();
    scopes.put(TransactionScope.Name, scope);
    conf.setScopes(scopes);
    context.getBeanFactory().registerSingleton("transactionScope", scope);
    context.addBeanFactoryPostProcessor(conf);
    context.scan("com.visural");
    context.refresh();/* ww w .j av  a  2 s . c  o  m*/
    context.getBean(TransactionConfig.class).getConnectionProvider().registerDefaultConnectionSource(source);
    return context;
}

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);
    return toRet;
}