Java Code Examples for org.springframework.core.annotation.AnnotatedElementUtils#getAllAnnotationAttributes()

The following examples show how to use org.springframework.core.annotation.AnnotatedElementUtils#getAllAnnotationAttributes() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StandardAnnotationMetadata.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
@Nullable
public MultiValueMap<String, Object> getAllAnnotationAttributes(String annotationName, boolean classValuesAsString) {
	if (this.nestedAnnotationsAsMap) {
		return AnnotationMetadata.super.getAllAnnotationAttributes(annotationName, classValuesAsString);
	}
	return AnnotatedElementUtils.getAllAnnotationAttributes(
			getIntrospectedClass(), annotationName, classValuesAsString, false);
}
 
Example 2
Source File: StandardMethodMetadata.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
@Nullable
public MultiValueMap<String, Object> getAllAnnotationAttributes(String annotationName, boolean classValuesAsString) {
	if (this.nestedAnnotationsAsMap) {
		return MethodMetadata.super.getAllAnnotationAttributes(annotationName, classValuesAsString);
	}
	return AnnotatedElementUtils.getAllAnnotationAttributes(this.introspectedMethod,
			annotationName, classValuesAsString, false);
}
 
Example 3
Source File: StandardAnnotationMetadata.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
@Nullable
public MultiValueMap<String, Object> getAllAnnotationAttributes(String annotationName, boolean classValuesAsString) {
	return (this.annotations.length > 0 ? AnnotatedElementUtils.getAllAnnotationAttributes(
			getIntrospectedClass(), annotationName, classValuesAsString, this.nestedAnnotationsAsMap) : null);
}
 
Example 4
Source File: StandardMethodMetadata.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
@Nullable
public MultiValueMap<String, Object> getAllAnnotationAttributes(String annotationName, boolean classValuesAsString) {
	return AnnotatedElementUtils.getAllAnnotationAttributes(this.introspectedMethod,
			annotationName, classValuesAsString, this.nestedAnnotationsAsMap);
}
 
Example 5
Source File: StandardAnnotationMetadata.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MultiValueMap<String, Object> getAllAnnotationAttributes(String annotationName, boolean classValuesAsString) {
	return (this.annotations.length > 0 ? AnnotatedElementUtils.getAllAnnotationAttributes(
			getIntrospectedClass(), annotationName, classValuesAsString, this.nestedAnnotationsAsMap) : null);
}
 
Example 6
Source File: StandardMethodMetadata.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MultiValueMap<String, Object> getAllAnnotationAttributes(String annotationName, boolean classValuesAsString) {
	return AnnotatedElementUtils.getAllAnnotationAttributes(this.introspectedMethod,
			annotationName, classValuesAsString, this.nestedAnnotationsAsMap);
}
 
Example 7
Source File: StandardAnnotationMetadata.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public MultiValueMap<String, Object> getAllAnnotationAttributes(String annotationName, boolean classValuesAsString) {
	return (this.annotations.length > 0 ? AnnotatedElementUtils.getAllAnnotationAttributes(
			getIntrospectedClass(), annotationName, classValuesAsString, this.nestedAnnotationsAsMap) : null);
}
 
Example 8
Source File: StandardMethodMetadata.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public MultiValueMap<String, Object> getAllAnnotationAttributes(String annotationName, boolean classValuesAsString) {
	return AnnotatedElementUtils.getAllAnnotationAttributes(this.introspectedMethod,
			annotationName, classValuesAsString, this.nestedAnnotationsAsMap);
}
 
Example 9
Source File: BootstrapUtils.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
/**
 * Resolve the {@link TestContextBootstrapper} type for the test class in the
 * supplied {@link BootstrapContext}, instantiate it, and provide it a reference
 * to the {@link BootstrapContext}.
 *
 * <p>If the {@link BootstrapWith @BootstrapWith} annotation is present on
 * the test class, either directly or as a meta-annotation, then its
 * {@link BootstrapWith#value value} will be used as the bootstrapper type.
 * Otherwise, the {@link org.springframework.test.context.support.DefaultTestContextBootstrapper
 * DefaultTestContextBootstrapper} will be used.
 *
 * @param bootstrapContext the bootstrap context to use
 * @return a fully configured {@code TestContextBootstrapper}
 */
@SuppressWarnings("unchecked")
static TestContextBootstrapper resolveTestContextBootstrapper(BootstrapContext bootstrapContext) {
	Class<?> testClass = bootstrapContext.getTestClass();

	Class<? extends TestContextBootstrapper> clazz = null;
	try {

		MultiValueMap<String, Object> attributesMultiMap = AnnotatedElementUtils.getAllAnnotationAttributes(
			testClass, BootstrapWith.class.getName());
		List<Object> values = (attributesMultiMap == null ? null : attributesMultiMap.get(AnnotationUtils.VALUE));

		if (values != null) {
			if (values.size() != 1) {
				String msg = String.format(
					"Configuration error: found multiple declarations of @BootstrapWith on test class [%s] with values %s",
					testClass.getName(), values);
				throw new IllegalStateException(msg);
			}
			clazz = (Class<? extends TestContextBootstrapper>) values.get(0);
		}
		else {
			clazz = (Class<? extends TestContextBootstrapper>) ClassUtils.forName(
				DEFAULT_TEST_CONTEXT_BOOTSTRAPPER_CLASS_NAME, BootstrapUtils.class.getClassLoader());
		}

		if (logger.isDebugEnabled()) {
			logger.debug(String.format("Instantiating TestContextBootstrapper for test class [%s] from class [%s]",
				testClass.getName(), clazz.getName()));
		}

		TestContextBootstrapper testContextBootstrapper = instantiateClass(clazz, TestContextBootstrapper.class);
		testContextBootstrapper.setBootstrapContext(bootstrapContext);

		return testContextBootstrapper;
	}
	catch (Throwable t) {
		if (t instanceof IllegalStateException) {
			throw (IllegalStateException) t;
		}

		throw new IllegalStateException("Could not load TestContextBootstrapper [" + clazz
				+ "]. Specify @BootstrapWith's 'value' attribute "
				+ "or make the default bootstrapper class available.", t);
	}
}