Example usage for org.springframework.beans.factory.xml BeanDefinitionParserDelegate getAutowireMode

List of usage examples for org.springframework.beans.factory.xml BeanDefinitionParserDelegate getAutowireMode

Introduction

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

Prototype

@SuppressWarnings("deprecation")
public int getAutowireMode(String attrValue) 

Source Link

Document

Parse the given autowire attribute value into AbstractBeanDefinition autowire constants.

Usage

From source file:org.seasar.dao.spring.autoregister.AbstractBeanAutoRegister.java

protected void register(final String packageName, final String shortClassName) {

    final String className = ClassUtil.concatName(packageName, shortClassName);

    final Class targetClass = ClassUtil.forName(className);
    Class enhancedClass;/*www  .  jav a2 s. co m*/

    final AspectWeaver weaver = new AspectWeaver(targetClass, null);

    final Method[] methods = targetClass.getMethods();
    for (int i = 0; i < methods.length; ++i) {
        final Method method = methods[i];
        if (isBridgeMethod(method)) {
            continue;
        }

        final List interceptorList = new ArrayList();
        for (int j = 0; j < interceptorNames.length; j++) {
            final MethodInterceptor interceptor = (MethodInterceptor) getBeanFactory()
                    .getBean(interceptorNames[j]);
            interceptorList.add(interceptor);
        }
        if (!isApplicableAspect(method)) {
            continue;
        }
        if (interceptorList.size() == 0) {
            weaver.setInterceptors(method, new MethodInterceptor[0]);
        } else {
            weaver.setInterceptors(method, (MethodInterceptor[]) interceptorList
                    .toArray(new MethodInterceptor[interceptorList.size()]));
        }
    }
    enhancedClass = weaver.generateClass();

    final BeanDefinitionParserDelegate delegate = new BeanDefinitionParserDelegate(
            new XmlReaderContext(null, null, null, null, null, null));
    final int autowireMode = delegate.getAutowireMode(autowire);

    final RootBeanDefinition bd = new RootBeanDefinition();
    bd.setBeanClass(enhancedClass);
    bd.setAutowireMode(autowireMode);
    bd.setScope(scope);

    String beanName;
    if (autoNaming != null) {
        beanName = autoNaming.defineName(packageName, shortClassName);
    } else {
        beanName = className;
    }
    getBeanFactory().registerBeanDefinition(beanName, bd);

}