Example usage for org.springframework.beans.factory.xml XmlReaderContext registerWithGeneratedName

List of usage examples for org.springframework.beans.factory.xml XmlReaderContext registerWithGeneratedName

Introduction

In this page you can find the example usage for org.springframework.beans.factory.xml XmlReaderContext registerWithGeneratedName.

Prototype

public String registerWithGeneratedName(BeanDefinition beanDefinition) 

Source Link

Document

Call the bean name generator for the given bean definition and register the bean definition under the generated name.

Usage

From source file:com.github.spring.mvc.util.handler.config.UriMatchingAnnotationDrivenBeanDefinitionParser.java

/**
 * Create the {@link Pointcut} used to apply the caching interceptor
 * @return Reference to the {@link Pointcut}. Should never be null.
 *///ww w. jav  a  2 s .  c  o  m
protected RuntimeBeanReference setupPointcut(Element element, ParserContext parserContext,
        Object elementSource) {
    final RootBeanDefinition pointcut = new RootBeanDefinition(UriMatchingStaticMethodMatcherPointcut.class);
    pointcut.setSource(elementSource);
    pointcut.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);

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

From source file:com.github.spring.mvc.util.handler.config.UriMatchingAnnotationDrivenBeanDefinitionParser.java

/**
 * Create {@link MethodInterceptor} that is applies the caching logic to advised methods.
 * @return Reference to the {@link MethodInterceptor}. Should never be null.
 */// ww w .  j  a  v  a2  s  .  c  o  m
protected RuntimeBeanReference setupInterceptor(Element element, ParserContext parserContext,
        Object elementSource) {
    final RootBeanDefinition interceptor = new RootBeanDefinition(
            UriMatchingHandlerInterceptorInterceptor.class);
    interceptor.setSource(elementSource);
    interceptor.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);

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

From source file:org.jsr107.ri.annotations.spring.config.AnnotationDrivenJCacheBeanDefinitionParser.java

/**
 * Create {@link org.springframework.aop.PointcutAdvisor} that puts the
 * {@link org.springframework.aop.Pointcut} and {@link AbstractCacheInterceptor} together.
 */// w  w w .  ja v  a  2  s .  c o m
protected void setupPointcutAdvisor(Class<? extends AbstractCacheInterceptor<?>> interceptorClass,
        Element element, ParserContext parserContext, Object elementSource,
        RuntimeBeanReference cacheOperationSourceReference) {

    final RuntimeBeanReference interceptorReference = this.setupInterceptor(interceptorClass, parserContext,
            elementSource, cacheOperationSourceReference);

    final RuntimeBeanReference pointcutReference = this.setupPointcut(parserContext, elementSource,
            cacheOperationSourceReference, interceptorReference);

    final RootBeanDefinition pointcutAdvisor = new RootBeanDefinition(DefaultBeanFactoryPointcutAdvisor.class);
    pointcutAdvisor.setSource(elementSource);
    pointcutAdvisor.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);

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

    final XmlReaderContext readerContext = parserContext.getReaderContext();
    readerContext.registerWithGeneratedName(pointcutAdvisor);
}

From source file:org.jsr107.ri.annotations.spring.config.AnnotationDrivenJCacheBeanDefinitionParser.java

/**
 * Create {@link org.aopalliance.intercept.MethodInterceptor} that is applies the caching logic to advised methods.
 *
 * @return Reference to the {@link org.aopalliance.intercept.MethodInterceptor}. Should never be null.
 *//*from  www . j av a2 s.  co m*/
protected RuntimeBeanReference setupInterceptor(Class<? extends AbstractCacheInterceptor<?>> interceptorClass,
        ParserContext parserContext, Object elementSource,
        RuntimeBeanReference cacheOperationSourceRuntimeReference) {

    final RootBeanDefinition interceptor = new RootBeanDefinition(interceptorClass);
    interceptor.setSource(elementSource);
    interceptor.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);

    final ConstructorArgumentValues constructorArgumentValues = new ConstructorArgumentValues();
    constructorArgumentValues.addIndexedArgumentValue(0, cacheOperationSourceRuntimeReference);
    interceptor.setConstructorArgumentValues(constructorArgumentValues);

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

From source file:com.inspiresoftware.lib.dto.geda.config.AnnotationDrivenGeDABeanDefinitionParser.java

protected RuntimeBeanReference setupTransferableAdviceConfigResolver(final ParserContext parserContext,
        final Object elementSource, final Class impl) {

    final RootBeanDefinition defaultResolver = new RootBeanDefinition(impl);
    defaultResolver.setSource(elementSource);
    defaultResolver.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);

    final XmlReaderContext readerContext = parserContext.getReaderContext();

    final String beanName = readerContext.registerWithGeneratedName(defaultResolver);

    return new RuntimeBeanReference(beanName);
}

From source file:com.inspiresoftware.lib.dto.geda.config.AnnotationDrivenGeDABeanDefinitionParser.java

protected RuntimeBeanReference setupBootstapBeanPostprocessor(final Element element,
        final ParserContext parserContext, final Object elementSource) {

    final RootBeanDefinition beanPostProcessor = new RootBeanDefinition(GeDABootstrapAdvicePostProcessor.class);
    beanPostProcessor.setSource(elementSource);
    beanPostProcessor.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);

    final XmlReaderContext readerContext = parserContext.getReaderContext();

    final String beanName = readerContext.registerWithGeneratedName(beanPostProcessor);

    return new RuntimeBeanReference(beanName);
}

From source file:com.inspiresoftware.lib.dto.geda.config.AnnotationDrivenGeDABeanDefinitionParser.java

protected RuntimeBeanReference setupGeDAInterceptor(final ParserContext parserContext,
        final Object elementSource, final RuntimeBeanReference defaultSupport,
        final RuntimeBeanReference defaultResolver) {

    final RootBeanDefinition defaultInterceptor = new RootBeanDefinition(GeDAInterceptor.class);
    defaultInterceptor.setSource(elementSource);
    defaultInterceptor.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);

    final MutablePropertyValues propertyValues = defaultInterceptor.getPropertyValues();
    propertyValues.addPropertyValue("support", defaultSupport);
    propertyValues.addPropertyValue("resolver", defaultResolver);

    final XmlReaderContext readerContext = parserContext.getReaderContext();

    final String beanName = readerContext.registerWithGeneratedName(defaultInterceptor);

    return new RuntimeBeanReference(beanName);

}

From source file:com.inspiresoftware.lib.dto.geda.config.AnnotationDrivenGeDABeanDefinitionParser.java

protected RuntimeBeanReference setupPointcut(final ParserContext parserContext, final Object elementSource,
        final RuntimeBeanReference resolver, final String[] pointcutMatchRegex,
        final String[] pointcutNoMatchRegex) {

    final RootBeanDefinition pointcut;

    if (pointcutMatchRegex.length == 0 && pointcutNoMatchRegex.length == 0) {
        pointcut = new RootBeanDefinition(GeDAMethodMatcherPointcut.class);
        final ConstructorArgumentValues constructorArgs = pointcut.getConstructorArgumentValues();
        constructorArgs.addGenericArgumentValue(resolver);
    } else {//  ww w.  j  a  v  a2s  . com
        pointcut = new RootBeanDefinition(GeDAMethodRegExMatcherPointcut.class);
        final ConstructorArgumentValues constructorArgs = pointcut.getConstructorArgumentValues();
        constructorArgs.addGenericArgumentValue(resolver);
        final MutablePropertyValues propertyValues = pointcut.getPropertyValues();
        if (pointcutMatchRegex.length > 0) {
            propertyValues.addPropertyValue("patterns", pointcutMatchRegex);
        }
        if (pointcutNoMatchRegex.length > 0) {
            propertyValues.addPropertyValue("excludedPatterns", pointcutNoMatchRegex);
        }
    }

    pointcut.setSource(elementSource);
    pointcut.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);

    final XmlReaderContext readerContext = parserContext.getReaderContext();
    final String pointcutBeanName = readerContext.registerWithGeneratedName(pointcut);

    return new RuntimeBeanReference(pointcutBeanName);
}

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

/**
 * Create the {@link Pointcut} used to apply the caching interceptor
 * /*from  w  w w .j  ava 2  s  .c  o  m*/
 * @return Reference to the {@link Pointcut}. Should never be null.
 */
protected RuntimeBeanReference setupPointcut(Element element, ParserContext parserContext, Object elementSource,
        RuntimeBeanReference cacheAttributeSource) {
    final RootBeanDefinition pointcut = new RootBeanDefinition(CacheStaticMethodMatcherPointcut.class);
    pointcut.setSource(elementSource);
    pointcut.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);

    final MutablePropertyValues propertyValues = pointcut.getPropertyValues();
    propertyValues.addPropertyValue("cacheAttributeSource", cacheAttributeSource);

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

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

/**
 * Create {@link MethodInterceptor} that is applies the caching logic to advised methods.
 * /*from   w  w  w.j a v  a 2s .  c om*/
 * @return Reference to the {@link MethodInterceptor}. Should never be null.
 */
protected RuntimeBeanReference setupInterceptor(Element element, ParserContext parserContext,
        Object elementSource, RuntimeBeanReference cacheableAttributeSourceRuntimeReference) {
    final RootBeanDefinition interceptor = new RootBeanDefinition(EhCacheInterceptor.class);
    interceptor.setSource(elementSource);
    interceptor.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);

    final MutablePropertyValues propertyValues = interceptor.getPropertyValues();
    propertyValues.addPropertyValue("cacheAttributeSource", cacheableAttributeSourceRuntimeReference);

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