List of usage examples for org.springframework.core.type MethodMetadata getDeclaringClassName
String getDeclaringClassName();
From source file:lodsve.core.condition.SpringBootCondition.java
private static String getClassOrMethodName(AnnotatedTypeMetadata metadata) { if (metadata instanceof ClassMetadata) { ClassMetadata classMetadata = (ClassMetadata) metadata; return classMetadata.getClassName(); }//from ww w .ja v a 2 s . co m MethodMetadata methodMetadata = (MethodMetadata) metadata; return methodMetadata.getDeclaringClassName() + "#" + methodMetadata.getMethodName(); }
From source file:lodsve.core.condition.SpringBootCondition.java
private String getName(AnnotatedTypeMetadata metadata) { if (metadata instanceof AnnotationMetadata) { return ((AnnotationMetadata) metadata).getClassName(); }//w ww . ja v a 2 s . c om if (metadata instanceof MethodMetadata) { MethodMetadata methodMetadata = (MethodMetadata) metadata; return methodMetadata.getDeclaringClassName() + "." + methodMetadata.getMethodName(); } return metadata.toString(); }
From source file:org.springframework.boot.autoconfigure.condition.AbstractOnBeanCondition.java
@Override public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { MultiValueMap<String, Object> attributes = metadata.getAllAnnotationAttributes(annotationClass().getName(), true);//ww w . jav a 2 s .co m final List<String> beanClasses = collect(attributes, "value"); final List<String> beanNames = collect(attributes, "name"); if (beanClasses.size() == 0) { if (metadata instanceof MethodMetadata && metadata.isAnnotated(Bean.class.getName())) { try { final MethodMetadata methodMetadata = (MethodMetadata) metadata; // 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())) { beanClasses.add(method.getReturnType().getName()); } } }); } catch (Exception ex) { // swallow exception and continue } } } Assert.isTrue(beanClasses.size() > 0 || beanNames.size() > 0, "@" + ClassUtils.getShortName(annotationClass()) + " annotations must specify at least one bean"); return matches(context, metadata, beanClasses, beanNames); }
From source file:org.springframework.boot.autoconfigure.condition.ConditionLogUtils.java
private static String getMethodName(MethodMetadata metadata) { return metadata.getDeclaringClassName() + "#" + metadata.getMethodName(); }