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


Java MethodMetadata类代码示例

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


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

示例1: detectAnnotatedFactoryMethods

import org.springframework.core.type.MethodMetadata; //导入依赖的package包/类
/**
 * Detect relationships in annotated {@link Bean @Bean} Factory methods.
 * 
 * @return Relationships detected from factory methods.
 */
protected Set<Relationship> detectAnnotatedFactoryMethods() {
    Set<Relationship> result = new HashSet<>();
    /* retrieve all beans declared in the application context */
    String[] annotateBeans = applicationContext.getBeanDefinitionNames();
    ConfigurableBeanFactory factory = applicationContext.getBeanFactory();
    for (String beanName : annotateBeans) {
        /* ... and get the bean definition of each declared beans */
        Optional<MethodMetadata> metadata = getMethodMetadata(factory.getMergedBeanDefinition(beanName));
        if (metadata.isPresent()) {
            Set<Relationship> rel = detectMethodMetadata(metadata.get());
            result.addAll(rel);
        }
    }
    return result;
}
 
开发者ID:cereebro,项目名称:cereebro,代码行数:21,代码来源:AnnotationRelationshipDetector.java

示例2: detectMethodMetadata

import org.springframework.core.type.MethodMetadata; //导入依赖的package包/类
protected Set<Relationship> detectMethodMetadata(final MethodMetadata metadata) {
    /*
     * ... get the metadata of the current definition bean for the
     * annotation DependencyHint. In this case, we retrieve the annotation
     * on the annotated method @Bean. The map can be null.
     */
    Map<String, Object> hintData = metadata.getAnnotationAttributes(annotation.getName());
    /*
     * ... get the Hint directly from the class (Target = ElementType.TYPE)
     */
    Optional<T> methodAnnotation = getAnnotation(metadata);
    Set<Relationship> rel = new HashSet<>();
    if (!CollectionUtils.isEmpty(hintData)) {
        rel.addAll(extractFromAnnotationAttributes(hintData));
    } else if (methodAnnotation.isPresent()) {
        rel.addAll(extractFromAnnotation(methodAnnotation.get()));
    }
    return rel;
}
 
开发者ID:cereebro,项目名称:cereebro,代码行数:20,代码来源:AnnotationRelationshipDetector.java

示例3: getFactoryMethod

import org.springframework.core.type.MethodMetadata; //导入依赖的package包/类
private Method getFactoryMethod(ConfigurableListableBeanFactory beanFactory,
		BeanDefinition definition) throws Exception {
	if (definition instanceof AnnotatedBeanDefinition) {
		MethodMetadata factoryMethodMetadata = ((AnnotatedBeanDefinition) definition)
				.getFactoryMethodMetadata();
		if (factoryMethodMetadata instanceof StandardMethodMetadata) {
			return ((StandardMethodMetadata) factoryMethodMetadata)
					.getIntrospectedMethod();
		}
	}
	BeanDefinition factoryDefinition = beanFactory
			.getBeanDefinition(definition.getFactoryBeanName());
	Class<?> factoryClass = ClassUtils.forName(factoryDefinition.getBeanClassName(),
			beanFactory.getBeanClassLoader());
	return getFactoryMethod(definition, factoryClass);
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:17,代码来源:BeanTypeRegistry.java

示例4: getAnnotatedMethods

import org.springframework.core.type.MethodMetadata; //导入依赖的package包/类
private Map<String, List<SoapMethodData>> getAnnotatedMethods(AnnotationMetadata metadata) {
    String annotationName = SoapMethod.class.getCanonicalName();
    Map<String, List<SoapMethodData>> soapMethods = new HashMap<>();
    Set<MethodMetadata> proxyInterfaceMethods = metadata.getAnnotatedMethods(annotationName);
    for (MethodMetadata proxyInterfaceMethod : proxyInterfaceMethods) {
        String soapMethodName = (String) proxyInterfaceMethod.getAnnotationAttributes(annotationName).get("value");
        Class<?>[] autowiredFields = (Class<?>[]) proxyInterfaceMethod.getAnnotationAttributes(annotationName).get("autowired");
        Assert.hasText(soapMethodName, "Soap method name cannot be null or empty");
        if (soapMethods.containsKey(soapMethodName)) {
            soapMethods.get(soapMethodName).add(new SoapMethodData(
                    proxyInterfaceMethod.getMethodName(),
                    proxyInterfaceMethod.getReturnTypeName(),
                    autowiredFields));
        } else {
            List<SoapMethodData> methodNames = new ArrayList<>();
            methodNames.add(new SoapMethodData(proxyInterfaceMethod.getMethodName(),
                    proxyInterfaceMethod.getReturnTypeName(),
                    autowiredFields));
            soapMethods.put(soapMethodName, methodNames);
        }
    }
    return soapMethods;
}
 
开发者ID:Salmondx,项目名称:spring-soap-client-starter,代码行数:24,代码来源:SoapClientRegistrar.java

示例5: 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

示例6: 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

示例7: getFactoryMethod

import org.springframework.core.type.MethodMetadata; //导入依赖的package包/类
private Method getFactoryMethod(ConfigurableListableBeanFactory beanFactory,
		BeanDefinition definition) throws Exception {
	if (definition instanceof AnnotatedBeanDefinition) {
		MethodMetadata factoryMethodMetadata = ((AnnotatedBeanDefinition) definition)
				.getFactoryMethodMetadata();
		if (factoryMethodMetadata instanceof StandardMethodMetadata) {
			return ((StandardMethodMetadata) factoryMethodMetadata)
					.getIntrospectedMethod();
		}
	}
	BeanDefinition factoryDefinition = beanFactory
			.getBeanDefinition(definition.getFactoryBeanName());
	Class<?> factoryClass = ClassUtils.forName(factoryDefinition.getBeanClassName(),
			beanFactory.getBeanClassLoader());
	return ReflectionUtils.findMethod(factoryClass,
			definition.getFactoryMethodName());
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:BeanTypeRegistry.java

示例8: allBeanMethodsArePublic

import org.springframework.core.type.MethodMetadata; //导入依赖的package包/类
@Test
public void allBeanMethodsArePublic() throws IOException, ClassNotFoundException {
	Set<String> nonPublicBeanMethods = new HashSet<String>();
	for (AnnotationMetadata configurationClass : findConfigurationClasses()) {
		Set<MethodMetadata> beanMethods = configurationClass
				.getAnnotatedMethods(Bean.class.getName());
		for (MethodMetadata methodMetadata : beanMethods) {
			if (!isPublic(methodMetadata)) {
				nonPublicBeanMethods.add(methodMetadata.getDeclaringClassName() + "."
						+ methodMetadata.getMethodName());
			}
		}
	}
	assertEquals("Found non-public @Bean methods: " + nonPublicBeanMethods, 0,
			nonPublicBeanMethods.size());
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:17,代码来源:AbstractConfigurationClassTests.java

示例9: checkQualifier

import org.springframework.core.type.MethodMetadata; //导入依赖的package包/类
private boolean checkQualifier(BeanDefinition endpointBeanDefinition, Annotation qualifierAnnotation) {
	if (endpointBeanDefinition instanceof AnnotatedBeanDefinition) {
		AnnotatedBeanDefinition annotatedBeanDefinition = (AnnotatedBeanDefinition) endpointBeanDefinition;
		String qualifierCanonicalName = qualifierAnnotation.annotationType().getCanonicalName();

		MethodMetadata factoryMethodMetadata = annotatedBeanDefinition.getFactoryMethodMetadata();

		if (factoryMethodMetadata.isAnnotated(qualifierCanonicalName)) {
			if (qualifierAnnotation instanceof Qualifier) {
				Object value1 = factoryMethodMetadata.getAnnotationAttributes(qualifierCanonicalName).get("value");
				Object value2 = ((Qualifier) qualifierAnnotation).value();
				if (value1 == null || value2 == null) {
					throw new IllegalArgumentException("No value found on Qualifier annotation");
				}
				if (value1.equals(value2)) {
					return true;
				}
			}
			return true;
		}
	}
	return false;
}
 
开发者ID:Codearte,项目名称:resteeth,代码行数:24,代码来源:BeanResolver.java

示例10: qualifierAttributesFor

import org.springframework.core.type.MethodMetadata; //导入依赖的package包/类
static Map<Class<? extends Annotation>,AnnotationAttributes> qualifierAttributesFor(final MethodMetadata metadata) {
  if (metadata instanceof StandardMethodMetadata) {
    return qualifierFor(metadata, ((StandardMethodMetadata)metadata).getIntrospectedMethod());
  } else {
    if (logger.isDebugEnabled()) {
      logger.debug(String
          .format("Found unsupported method meta data %s for method %s.%s", metadata.getClass(), metadata.getDeclaringClassName(),metadata.getMethodName()));
    }
    try {
  	// TODO find better way to load the specified @Bean method (ignore parameter etc.)
      return qualifierFor(metadata, ReflectionUtils.findMethod(Class.forName(metadata.getDeclaringClassName()), metadata.getMethodName(), null));
    } catch (final ClassNotFoundException e) {
      logger.warn(String
          .format("Cant scan method meta data %s for method %s.%s", metadata.getClass(), metadata.getDeclaringClassName(),metadata.getMethodName()), e);
    }
  }
  return new HashMap<Class<? extends Annotation>, AnnotationAttributes>();
}
 
开发者ID:ahoehma,项目名称:spring-autowire-qualified-beans,代码行数:19,代码来源:ConfigurationClassBeanDefinitionReader.java

示例11: getAnnotation

import org.springframework.core.type.MethodMetadata; //导入依赖的package包/类
/**
 * Get the annotation from the class instead of the {@link Bean} method.
 * 
 * @param metadata
 *            Method metadata.
 * @return An optional target annotation.
 */
protected Optional<T> getAnnotation(MethodMetadata metadata) {
    try {
        return Optional.ofNullable(Class.forName(metadata.getReturnTypeName()).getDeclaredAnnotation(annotation));
    } catch (ClassNotFoundException e) {
        LOGGER.error("Could not load class : " + metadata.getReturnTypeName(), e);
    }
    return Optional.empty();
}
 
开发者ID:cereebro,项目名称:cereebro,代码行数:16,代码来源:AnnotationRelationshipDetector.java

示例12: detectUnknownClass

import org.springframework.core.type.MethodMetadata; //导入依赖的package包/类
@Test
public void detectUnknownClass() {
    ConsumerHintAnnotationRelationshipDetector detector = new ConsumerHintAnnotationRelationshipDetector();
    MethodMetadata metadataMock = Mockito.mock(MethodMetadata.class);
    Mockito.when(metadataMock.getReturnTypeName()).thenReturn("com.n0pe.ISwearThisClassWontExist");
    Optional<ConsumerHint> result = detector.getAnnotation(metadataMock);
    Assertions.assertThat(result.isPresent()).isFalse();
}
 
开发者ID:cereebro,项目名称:cereebro,代码行数:9,代码来源:AnnotationRelationshipDetectorEdgeCasesTest.java

示例13: isVerticleBeanDefinition

import org.springframework.core.type.MethodMetadata; //导入依赖的package包/类
private boolean isVerticleBeanDefinition(String beanName, BeanDefinition beanDefinition) {
    Class<?> beanClass = getBeanClass(beanName, beanDefinition);
    if (beanClass != null) {
        if (Verticle.class.isAssignableFrom(beanClass)) {
            return true;
        }
        if (FactoryBean.class.isAssignableFrom(beanClass) && beanDefinition instanceof AnnotatedBeanDefinition) {
            MethodMetadata factoryMethodMetadata = ((AnnotatedBeanDefinition) beanDefinition).getFactoryMethodMetadata();
            if (factoryMethodMetadata != null && factoryMethodMetadata.isAnnotated(VerticleDeployment.class.getName())) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:unbroken-dome,项目名称:vertx-spring,代码行数:16,代码来源:VerticleBeanPostProcessor.java

示例14: getMetadataFromBeanDefinition

import org.springframework.core.type.MethodMetadata; //导入依赖的package包/类
private AnnotatedTypeMetadata getMetadataFromBeanDefinition(BeanDefinition beanDefinition) {
    if (beanDefinition instanceof AnnotatedBeanDefinition) {
        AnnotatedBeanDefinition abd = (AnnotatedBeanDefinition) beanDefinition;
        MethodMetadata factoryMethodMetadata = abd.getFactoryMethodMetadata();
        if (factoryMethodMetadata != null) {
            return factoryMethodMetadata;
        } else {
            return abd.getMetadata();
        }
    }
    return null;
}
 
开发者ID:unbroken-dome,项目名称:vertx-spring,代码行数:13,代码来源:VerticleBeanPostProcessor.java

示例15: 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


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