Example usage for org.springframework.beans.factory.support RootBeanDefinition setRole

List of usage examples for org.springframework.beans.factory.support RootBeanDefinition setRole

Introduction

In this page you can find the example usage for org.springframework.beans.factory.support RootBeanDefinition setRole.

Prototype

@Override
public void setRole(int role) 

Source Link

Document

Set the role hint for this BeanDefinition .

Usage

From source file:com.googlecode.ehcache.annotations.config.AnnotationDrivenEhCacheBeanDefinitionParser.java

protected RuntimeBeanReference setupCachingReflectionHelper(ParserContext parserContext, Object elementSource) {
    final RootBeanDefinition defaultKeyGenerator = new RootBeanDefinition(CachingReflectionHelper.class);
    defaultKeyGenerator.setSource(elementSource);
    defaultKeyGenerator.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);

    final BeanDefinitionRegistry registry = parserContext.getRegistry();
    registry.registerBeanDefinition(CACHING_REFLECTION_HELPER_BEAN_NAME, defaultKeyGenerator);

    return new RuntimeBeanReference(CACHING_REFLECTION_HELPER_BEAN_NAME);
}

From source file:com.googlecode.ehcache.annotations.config.AnnotationDrivenEhCacheBeanDefinitionParser.java

/**
 * Utility API used to setup each of the default {@link CacheKeyGenerator} implementations. Requires
 * that the class has a static String field named DEFAULT_BEAN_NAME declared that is used for the bean
 * name. //w w  w.j  a va  2  s  .  co  m
 */
protected final void setupDefaultCacheKeyGenerator(
        Class<? extends CacheKeyGenerator<? extends Serializable>> generatorClass, ParserContext parserContext,
        Object elementSource) {
    final String generatorName;
    try {
        final Field field = generatorClass.getField("DEFAULT_BEAN_NAME");
        generatorName = (String) field.get(null);
    } catch (Exception e) {
        throw new IllegalArgumentException("Could not access static field 'DEFAULT_BEAN_NAME' on "
                + generatorClass + ". This field is required to be setup as a default CacheKeyGenerator", e);
    }

    final RootBeanDefinition defaultKeyGenerator = new RootBeanDefinition(generatorClass);
    defaultKeyGenerator.setSource(elementSource);
    defaultKeyGenerator.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);

    if (ReflectionHelperAware.class.isAssignableFrom(generatorClass)) {
        final RuntimeBeanReference cacheManagerReference = new RuntimeBeanReference(
                CACHING_REFLECTION_HELPER_BEAN_NAME);

        final MutablePropertyValues propertyValues = defaultKeyGenerator.getPropertyValues();
        propertyValues.addPropertyValue("reflectionHelper", cacheManagerReference);
    }

    final BeanDefinitionRegistry registry = parserContext.getRegistry();
    registry.registerBeanDefinition(generatorName, defaultKeyGenerator);
}

From source file:com.googlecode.ehcache.annotations.config.AnnotationDrivenEhCacheBeanDefinitionParser.java

/**
 * Create {@link PointcutAdvisor} that puts the {@link Pointcut} and {@link MethodInterceptor} together.
 * //w  ww.ja  v  a2s  .  co m
 * @return Reference to the {@link PointcutAdvisor}. Should never be null.
 */
protected RuntimeBeanReference setupPointcutAdvisor(Element element, ParserContext parserContext,
        Object elementSource, RuntimeBeanReference cacheablePointcutBeanReference,
        RuntimeBeanReference cachingInterceptorBeanReference) {
    final RootBeanDefinition pointcutAdvisor = new RootBeanDefinition(DefaultBeanFactoryPointcutAdvisor.class);
    pointcutAdvisor.setSource(elementSource);
    pointcutAdvisor.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);

    final MutablePropertyValues propertyValues = pointcutAdvisor.getPropertyValues();
    propertyValues.addPropertyValue("adviceBeanName", cachingInterceptorBeanReference.getBeanName());
    propertyValues.addPropertyValue("pointcut", cacheablePointcutBeanReference);
    if (element.hasAttribute("order")) {
        propertyValues.addPropertyValue("order", element.getAttribute("order"));
    }

    final BeanDefinitionRegistry registry = parserContext.getRegistry();
    registry.registerBeanDefinition(EHCACHE_CACHING_ADVISOR_BEAN_NAME, pointcutAdvisor);
    return new RuntimeBeanReference(EHCACHE_CACHING_ADVISOR_BEAN_NAME);
}

From source file:com.googlecode.ehcache.annotations.config.AnnotationDrivenEhCacheBeanDefinitionParser.java

/**
 * Create a {@link CacheAttributeSource} bean that will be used by the advisor and interceptor
 * /*from w w w.j  a va 2 s  . c  om*/
 * @return Reference to the {@link CacheAttributeSource}. Should never be null.
 */
protected RuntimeBeanReference setupCacheAttributeSource(Element element, ParserContext parserContext,
        Object elementSource) {

    final RuntimeBeanReference cachingReflectionHelper = this.setupCachingReflectionHelper(parserContext,
            elementSource);

    final RuntimeBeanReference defaultCacheKeyGenerator = this.setupDefaultCacheKeyGenerators(element,
            parserContext, elementSource);

    final RuntimeBeanReference defaultCacheResolverFactory = this.setupDefaultCacheResolverFactory(element,
            parserContext, elementSource);

    final RuntimeBeanReference defaultCacheableInterceptor = this.setupDefaultCacheableInterceptor(element,
            parserContext, elementSource);

    final RuntimeBeanReference defaultTriggersRemoveInterceptor = this
            .setupDefaultTriggersRemoveInterceptor(element, parserContext, elementSource);

    final RootBeanDefinition cacheAttributeSource = new RootBeanDefinition(CacheAttributeSourceImpl.class);
    cacheAttributeSource.setSource(elementSource);
    cacheAttributeSource.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);

    final MutablePropertyValues propertyValues = cacheAttributeSource.getPropertyValues();
    RuntimeBeanReference cacheManagerReference = new RuntimeBeanReference(
            element.getAttribute(XSD_ATTR__CACHE_MANAGER));
    propertyValues.addPropertyValue("cacheManager", cacheManagerReference);
    propertyValues.addPropertyValue("createCaches",
            Boolean.parseBoolean(element.getAttribute(XSD_ATTR__CREATE_MISSING_CACHES)));
    propertyValues.addPropertyValue("defaultCacheKeyGenerator", defaultCacheKeyGenerator);
    propertyValues.addPropertyValue("reflectionHelper", cachingReflectionHelper);
    if (defaultCacheResolverFactory != null) {
        propertyValues.addPropertyValue("cacheResolverFactory", defaultCacheResolverFactory);
    }
    if (defaultCacheableInterceptor != null) {
        propertyValues.addPropertyValue("defaultCacheableInterceptor", defaultCacheableInterceptor);
    }
    if (defaultTriggersRemoveInterceptor != null) {
        propertyValues.addPropertyValue("defaultTriggersRemoveInterceptor", defaultTriggersRemoveInterceptor);
    }
    final String blockingCacheScope = element.getAttribute(XSD_ATTR__SELF_POPULATING_CACHE_SCOPE);
    if (blockingCacheScope != null) {
        propertyValues.addPropertyValue("selfPopulatingCacheScope",
                SelfPopulatingCacheScope.valueOf(blockingCacheScope.toUpperCase()));
    }
    if (element.hasAttribute(XSD_ATTR__EXECUTOR)) {
        RuntimeBeanReference executorReference = new RuntimeBeanReference(
                element.getAttribute(XSD_ATTR__EXECUTOR));
        propertyValues.addPropertyValue("executor", executorReference);
    }
    if (element.hasAttribute(XSD_ATTR__SCHEDULER)) {
        RuntimeBeanReference schedulerReference = new RuntimeBeanReference(
                element.getAttribute(XSD_ATTR__SCHEDULER));
        propertyValues.addPropertyValue("scheduler", schedulerReference);
    }

    final XmlReaderContext readerContext = parserContext.getReaderContext();
    final String cacheAttributeSourceBeanName = readerContext.registerWithGeneratedName(cacheAttributeSource);
    return new RuntimeBeanReference(cacheAttributeSourceBeanName);
}

From source file:org.hdiv.config.xml.ConfigBeanDefinitionParser.java

private RootBeanDefinition createUserData(Element element, Object source) {
    RootBeanDefinition bean = new RootBeanDefinition(UserData.class);
    bean.setSource(source);/*from   w ww.ja  v  a  2s .co  m*/
    bean.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
    return bean;
}

From source file:org.hdiv.config.xml.ConfigBeanDefinitionParser.java

private RootBeanDefinition createLogger(Element element, Object source) {
    String userData = element.getAttribute("userData");
    if (userData == null || userData.length() < 1) {
        userData = "userData";// default userData bean id
    }// w  w  w .  j av a2  s.  c  om
    RootBeanDefinition bean = new RootBeanDefinition(Logger.class);
    bean.setSource(source);
    bean.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
    bean.getPropertyValues().addPropertyValue("userData", new RuntimeBeanReference(userData));
    return bean;
}

From source file:org.hdiv.config.xml.ConfigBeanDefinitionParser.java

private RootBeanDefinition createCipher(Element element, Object source) {
    RootBeanDefinition bean = new RootBeanDefinition(CipherHTTP.class);
    bean.setSource(source);/*from  w  w  w.j a v a  2  s  .  co  m*/
    bean.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
    bean.setInitMethodName("init");
    bean.getPropertyValues().addPropertyValue("transformation", "AES/CBC/PKCS5Padding");
    return bean;
}

From source file:org.hdiv.config.xml.ConfigBeanDefinitionParser.java

private RootBeanDefinition createStateUtil(Element element, Object source) {
    RootBeanDefinition bean = new RootBeanDefinition(StateUtil.class);
    bean.setSource(source);//from   w  w w.  ja v a 2s .c  o m
    bean.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
    bean.setInitMethodName("init");
    bean.getPropertyValues().addPropertyValue("encodingUtil", new RuntimeBeanReference("encoding"));
    bean.getPropertyValues().addPropertyValue("config", new RuntimeBeanReference("config"));
    return bean;
}

From source file:org.hdiv.config.xml.ConfigBeanDefinitionParser.java

private RootBeanDefinition createKeyFactory(Element element, Object source) {
    RootBeanDefinition bean = new RootBeanDefinition(KeyFactory.class);
    bean.setSource(source);// ww  w . j  a va2  s. com
    bean.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
    bean.getPropertyValues().addPropertyValue("algorithm", "AES");
    bean.getPropertyValues().addPropertyValue("keySize", "128");
    bean.getPropertyValues().addPropertyValue("prngAlgorithm", "SHA1PRNG");
    bean.getPropertyValues().addPropertyValue("provider", "SUN");
    return bean;
}

From source file:org.hdiv.config.xml.ConfigBeanDefinitionParser.java

private RootBeanDefinition createEncodingUtil(Element element, Object source) {
    RootBeanDefinition bean = new RootBeanDefinition(EncodingUtil.class);
    bean.setSource(source);/*from ww  w  . ja va  2s .  c  o m*/
    bean.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
    bean.setInitMethodName("init");
    bean.getPropertyValues().addPropertyValue("session", new RuntimeBeanReference("sessionHDIV"));
    return bean;
}