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


Java MethodMetadata.getDeclaringClassName方法代码示例

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


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

示例1: hasCustomBeanDefinition

import org.springframework.core.type.MethodMetadata; //导入方法依赖的package包/类
private static <T> boolean hasCustomBeanDefinition(
		ConfigurableListableBeanFactory beanFactory, Class<T> type,
		Class<?> configClass) {
	String[] names = beanFactory.getBeanNamesForType(type, true, false);
	if (names == null || names.length != 1) {
		return false;
	}
	BeanDefinition definition = beanFactory.getBeanDefinition(names[0]);
	if (definition instanceof AnnotatedBeanDefinition) {
		MethodMetadata factoryMethodMetadata = ((AnnotatedBeanDefinition) definition)
				.getFactoryMethodMetadata();
		if (factoryMethodMetadata != null) {
			String className = factoryMethodMetadata.getDeclaringClassName();
			return !configClass.getName().equals(className);
		}
	}
	return true;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:19,代码来源:EndpointWebMvcAutoConfiguration.java

示例2: addDeducedBeanTypeForBeanMethod

import org.springframework.core.type.MethodMetadata; //导入方法依赖的package包/类
private void addDeducedBeanTypeForBeanMethod(ConditionContext context,
		AnnotatedTypeMetadata metadata, final List<String> beanTypes,
		final MethodMetadata methodMetadata) {
	try {
		// We should be safe to load at this point since we are in the
		// REGISTER_BEAN phase
		Class<?> configClass = ClassUtils.forName(
				methodMetadata.getDeclaringClassName(), context.getClassLoader());
		ReflectionUtils.doWithMethods(configClass, new MethodCallback() {
			@Override
			public void doWith(Method method)
					throws IllegalArgumentException, IllegalAccessException {
				if (methodMetadata.getMethodName().equals(method.getName())) {
					beanTypes.add(method.getReturnType().getName());
				}
			}
		});
	}
	catch (Throwable ex) {
		throw new BeanTypeDeductionException(
				methodMetadata.getDeclaringClassName(),
				methodMetadata.getMethodName(), ex);
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:25,代码来源:OnBeanCondition.java

示例3: addDeducedBeanTypeForBeanMethod

import org.springframework.core.type.MethodMetadata; //导入方法依赖的package包/类
private void addDeducedBeanTypeForBeanMethod(ConditionContext context,
                                             MethodMetadata metadata, final List<String> beanTypes) {
    try {
        // We should be safe to load at this point since we are in the
        // REGISTER_BEAN phase
        Class<?> returnType = ClassUtils.forName(metadata.getReturnTypeName(), context.getClassLoader());
        beanTypes.add(returnType.getName());
    } catch (Throwable ex) {
        throw new BeanTypeDeductionException(metadata.getDeclaringClassName(), metadata.getMethodName(), ex);
    }
}
 
开发者ID:drtrang,项目名称:spring-boot-autoconfigure,代码行数:12,代码来源:OnBeansCondition.java

示例4: addDeducedBeanTypeForBeanMethod

import org.springframework.core.type.MethodMetadata; //导入方法依赖的package包/类
private void addDeducedBeanTypeForBeanMethod(ConditionContext context,
		MethodMetadata metadata, final List<String> beanTypes) {
	try {
		// We should be safe to load at this point since we are in the
		// REGISTER_BEAN phase
		Class<?> returnType = ClassUtils.forName(metadata.getReturnTypeName(),
				context.getClassLoader());
		beanTypes.add(returnType.getName());
	}
	catch (Throwable ex) {
		throw new BeanTypeDeductionException(metadata.getDeclaringClassName(),
				metadata.getMethodName(), ex);
	}
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:15,代码来源:OnBeanCondition.java

示例5: getName

import org.springframework.core.type.MethodMetadata; //导入方法依赖的package包/类
private String getName(AnnotatedTypeMetadata metadata) {
	if (metadata instanceof AnnotationMetadata) {
		return ((AnnotationMetadata) metadata).getClassName();
	}
	if (metadata instanceof MethodMetadata) {
		MethodMetadata methodMetadata = (MethodMetadata) metadata;
		return methodMetadata.getDeclaringClassName() + "."
				+ methodMetadata.getMethodName();
	}
	return metadata.toString();
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:12,代码来源:SpringBootCondition.java

示例6: getClassOrMethodName

import org.springframework.core.type.MethodMetadata; //导入方法依赖的package包/类
private static String getClassOrMethodName(AnnotatedTypeMetadata metadata) {
	if (metadata instanceof ClassMetadata) {
		ClassMetadata classMetadata = (ClassMetadata) metadata;
		return classMetadata.getClassName();
	}
	MethodMetadata methodMetadata = (MethodMetadata) metadata;
	return methodMetadata.getDeclaringClassName() + "#"
			+ methodMetadata.getMethodName();
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:10,代码来源:SpringBootCondition.java

示例7: registerBeanDefinition

import org.springframework.core.type.MethodMetadata; //导入方法依赖的package包/类
@Override
public void registerBeanDefinition(String beanName, BeanDefinition beanDefinition) {
    try {
        Class<?> beanClazz = null;
        String beanClassName = beanDefinition.getBeanClassName();

        // Fix for @Bean annotations in @Configuration will return a "null" beanClassName. This
        // finds the class anyway:
        if (beanClassName == null && beanDefinition instanceof AnnotatedBeanDefinition) {
            MethodMetadata factoryMethodMetadata =
                    ((AnnotatedBeanDefinition) beanDefinition).getFactoryMethodMetadata();
            if (factoryMethodMetadata instanceof StandardMethodMetadata) {
                StandardMethodMetadata methodMetaData = (StandardMethodMetadata) factoryMethodMetadata;
                beanClazz = methodMetaData.getIntrospectedMethod().getReturnType();
            } else {
                // Try to find the method directly from the defining class/method
                String declaringClassName = factoryMethodMetadata.getDeclaringClassName();
                Class<?> factoryClazz = Class.forName(declaringClassName);

                // Note that MethodMetadata does not give us the exact method, we have to loop through to find
                // one which matches the name -- this is not optimal. But it should not matter much, the only thing
                // which may trip this up is having two classes with same name but different return values which is
                // not something we would expect in (sane) @Configuration classes.
                for (Method m : factoryClazz.getDeclaredMethods()) {
                    if (factoryMethodMetadata.getMethodName().equals(m.getName())) {
                        beanClazz = m.getReturnType();
                    }
                }
            }
        }

        if (beanClassName != null) {
            beanClazz = Class.forName(beanClassName);
        }
        if (beanClazz != null && isBeanRejected(beanName, beanClazz)) {
            log.info("Rejected bean [{}] with definiton [{}]", beanName, beanDefinition);
        } else {
            if (beanClazz == null) {
                log.warn("Unable to find beanclass for bean [{}] with definition [{}]", beanName, beanDefinition);
            }
            if (remockConfig.getEagerBeanClasses().contains(beanClazz)
                    || remockConfig.getEagerBeanNames().contains(beanName)) {
                beanDefinition.setLazyInit(false);
            } else if (!remockConfig.disableLazyInit()) {
                beanDefinition.setLazyInit(true);
            }
            super.registerBeanDefinition(beanName, beanDefinition);
        }
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:ksaua,项目名称:remock,代码行数:53,代码来源:RemockBeanFactory.java


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