当前位置: 首页>>代码示例>>Java>>正文


Java InjectionMetadata.InjectedElement方法代码示例

本文整理汇总了Java中org.springframework.beans.factory.annotation.InjectionMetadata.InjectedElement方法的典型用法代码示例。如果您正苦于以下问题:Java InjectionMetadata.InjectedElement方法的具体用法?Java InjectionMetadata.InjectedElement怎么用?Java InjectionMetadata.InjectedElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.beans.factory.annotation.InjectionMetadata的用法示例。


在下文中一共展示了InjectionMetadata.InjectedElement方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildAutowiringMetadata

import org.springframework.beans.factory.annotation.InjectionMetadata; //导入方法依赖的package包/类
private InjectionMetadata buildAutowiringMetadata(final Class<?> clazz) {
    LinkedList<InjectionMetadata.InjectedElement> elements = new LinkedList<InjectionMetadata.InjectedElement>();
    Class<?> targetClass = clazz;

    do {
        final LinkedList<InjectionMetadata.InjectedElement> currElements =
                new LinkedList<InjectionMetadata.InjectedElement>();

        doWithLocalFields(targetClass, new ReflectionUtils.FieldCallback() {
            @Override
            public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException {
                CreateCache ann = field.getAnnotation(CreateCache.class);
                if (ann != null) {
                    if (Modifier.isStatic(field.getModifiers())) {
                        if (logger.isWarnEnabled()) {
                            logger.warn("Autowired annotation is not supported on static fields: " + field);
                        }
                        return;
                    }
                    currElements.add(new AutowiredFieldElement(field, ann));
                }
            }
        });

        elements.addAll(0, currElements);
        targetClass = targetClass.getSuperclass();
    }
    while (targetClass != null && targetClass != Object.class);

    return new InjectionMetadata(clazz, elements);
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:32,代码来源:CreateCacheAnnotationBeanPostProcessor.java

示例2: findFieldReferenceMetadata

import org.springframework.beans.factory.annotation.InjectionMetadata; //导入方法依赖的package包/类
/**
 * Finds {@link InjectionMetadata.InjectedElement} Metadata from annotated {@link Reference @Reference} fields
 *
 * @param beanClass The {@link Class} of Bean
 * @return non-null {@link List}
 */
private List<InjectionMetadata.InjectedElement> findFieldReferenceMetadata(final Class<?> beanClass) {

    final List<InjectionMetadata.InjectedElement> elements = new LinkedList<InjectionMetadata.InjectedElement>();

    ReflectionUtils.doWithFields(beanClass, new ReflectionUtils.FieldCallback() {
        @Override
        public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException {

            Reference reference = findReferenceAnnotation(field);

            if (reference != null) {

                if (Modifier.isStatic(field.getModifiers())) {
                    if (logger.isWarnEnabled()) {
                        logger.warn("@Reference annotation is not supported on static fields: " + field);
                    }
                    return;
                }

                elements.add(new ReferenceFieldElement(field, reference));
            }

        }
    });

    return elements;

}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:35,代码来源:ReferenceAnnotationBeanPostProcessor.java

示例3: findMethodReferenceMetadata

import org.springframework.beans.factory.annotation.InjectionMetadata; //导入方法依赖的package包/类
/**
 * Finds {@link InjectionMetadata.InjectedElement} Metadata from annotated {@link Reference @Reference} methods
 *
 * @param beanClass The {@link Class} of Bean
 * @return non-null {@link List}
 */
private List<InjectionMetadata.InjectedElement> findMethodReferenceMetadata(final Class<?> beanClass) {

    final List<InjectionMetadata.InjectedElement> elements = new LinkedList<InjectionMetadata.InjectedElement>();

    ReflectionUtils.doWithMethods(beanClass, new ReflectionUtils.MethodCallback() {
        @Override
        public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {

            Method bridgedMethod = BridgeMethodResolver.findBridgedMethod(method);

            if (!BridgeMethodResolver.isVisibilityBridgeMethodPair(method, bridgedMethod)) {
                return;
            }

            Reference reference = findReferenceAnnotation(bridgedMethod);

            if (reference != null && method.equals(ClassUtils.getMostSpecificMethod(method, beanClass))) {
                if (Modifier.isStatic(method.getModifiers())) {
                    if (logger.isWarnEnabled()) {
                        logger.warn("@Reference annotation is not supported on static methods: " + method);
                    }
                    return;
                }
                if (method.getParameterTypes().length == 0) {
                    if (logger.isWarnEnabled()) {
                        logger.warn("@Reference  annotation should only be used on methods with parameters: " +
                                method);
                    }
                }
                PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, beanClass);
                elements.add(new ReferenceMethodElement(method, pd, reference));
            }
        }
    });

    return elements;

}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:45,代码来源:ReferenceAnnotationBeanPostProcessor.java

示例4: buildPersistenceMetadata

import org.springframework.beans.factory.annotation.InjectionMetadata; //导入方法依赖的package包/类
private InjectionMetadata buildPersistenceMetadata(final Class<?> clazz) {
	LinkedList<InjectionMetadata.InjectedElement> elements = new LinkedList<InjectionMetadata.InjectedElement>();
	Class<?> targetClass = clazz;

	do {
		final LinkedList<InjectionMetadata.InjectedElement> currElements =
				new LinkedList<InjectionMetadata.InjectedElement>();

		ReflectionUtils.doWithLocalFields(targetClass, new ReflectionUtils.FieldCallback() {
			@Override
			public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException {
				if (field.isAnnotationPresent(PersistenceContext.class) ||
						field.isAnnotationPresent(PersistenceUnit.class)) {
					if (Modifier.isStatic(field.getModifiers())) {
						throw new IllegalStateException("Persistence annotations are not supported on static fields");
					}
					currElements.add(new PersistenceElement(field, field, null));
				}
			}
		});

		ReflectionUtils.doWithLocalMethods(targetClass, new ReflectionUtils.MethodCallback() {
			@Override
			public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
				Method bridgedMethod = BridgeMethodResolver.findBridgedMethod(method);
				if (!BridgeMethodResolver.isVisibilityBridgeMethodPair(method, bridgedMethod)) {
					return;
				}
				if ((bridgedMethod.isAnnotationPresent(PersistenceContext.class) ||
						bridgedMethod.isAnnotationPresent(PersistenceUnit.class)) &&
						method.equals(ClassUtils.getMostSpecificMethod(method, clazz))) {
					if (Modifier.isStatic(method.getModifiers())) {
						throw new IllegalStateException("Persistence annotations are not supported on static methods");
					}
					if (method.getParameterTypes().length != 1) {
						throw new IllegalStateException("Persistence annotation requires a single-arg method: " + method);
					}
					PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, clazz);
					currElements.add(new PersistenceElement(method, bridgedMethod, pd));
				}
			}
		});

		elements.addAll(0, currElements);
		targetClass = targetClass.getSuperclass();
	}
	while (targetClass != null && targetClass != Object.class);

	return new InjectionMetadata(clazz, elements);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:51,代码来源:PersistenceAnnotationBeanPostProcessor.java

示例5: buildReferenceMetadata

import org.springframework.beans.factory.annotation.InjectionMetadata; //导入方法依赖的package包/类
/**
 * @param beanClass
 * @return
 */
private InjectionMetadata buildReferenceMetadata(final Class<?> beanClass) {

    final List<InjectionMetadata.InjectedElement> elements = new LinkedList<InjectionMetadata.InjectedElement>();

    elements.addAll(findFieldReferenceMetadata(beanClass));

    elements.addAll(findMethodReferenceMetadata(beanClass));

    return new InjectionMetadata(beanClass, elements);

}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:16,代码来源:ReferenceAnnotationBeanPostProcessor.java


注:本文中的org.springframework.beans.factory.annotation.InjectionMetadata.InjectedElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。