Java Code Examples for org.springframework.beans.factory.parsing.ProblemReporter#error()

The following examples show how to use org.springframework.beans.factory.parsing.ProblemReporter#error() . 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: BeanMethod.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void validate(ProblemReporter problemReporter) {
	if (getMetadata().isStatic()) {
		// static @Bean methods have no constraints to validate -> return immediately
		return;
	}

	if (this.configurationClass.getMetadata().isAnnotated(Configuration.class.getName())) {
		if (!getMetadata().isOverridable()) {
			// instance @Bean methods within @Configuration classes must be overridable to accommodate CGLIB
			problemReporter.error(new NonOverridableMethodError());
		}
	}
}
 
Example 2
Source File: ConfigurationClass.java    From spring-analysis-note with MIT License 5 votes vote down vote up
public void validate(ProblemReporter problemReporter) {
	// A configuration class may not be final (CGLIB limitation) unless it declares proxyBeanMethods=false
	Map<String, Object> attributes = this.metadata.getAnnotationAttributes(Configuration.class.getName());
	if (attributes != null && (Boolean) attributes.get("proxyBeanMethods")) {
		if (this.metadata.isFinal()) {
			problemReporter.error(new FinalConfigurationProblem());
		}
		for (BeanMethod beanMethod : this.beanMethods) {
			beanMethod.validate(problemReporter);
		}
	}
}
 
Example 3
Source File: BeanMethod.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public void validate(ProblemReporter problemReporter) {
	if (getMetadata().isStatic()) {
		// static @Bean methods have no constraints to validate -> return immediately
		return;
	}

	if (this.configurationClass.getMetadata().isAnnotated(Configuration.class.getName())) {
		if (!getMetadata().isOverridable()) {
			// instance @Bean methods within @Configuration classes must be overridable to accommodate CGLIB
			problemReporter.error(new NonOverridableMethodError());
		}
	}
}
 
Example 4
Source File: ConfigurationClass.java    From java-technology-stack with MIT License 5 votes vote down vote up
public void validate(ProblemReporter problemReporter) {
	// A configuration class may not be final (CGLIB limitation)
	if (getMetadata().isAnnotated(Configuration.class.getName())) {
		if (getMetadata().isFinal()) {
			problemReporter.error(new FinalConfigurationProblem());
		}
	}

	for (BeanMethod beanMethod : this.beanMethods) {
		beanMethod.validate(problemReporter);
	}
}
 
Example 5
Source File: BeanMethod.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void validate(ProblemReporter problemReporter) {
	if (getMetadata().isStatic()) {
		// static @Bean methods have no constraints to validate -> return immediately
		return;
	}

	if (this.configurationClass.getMetadata().isAnnotated(Configuration.class.getName())) {
		if (!getMetadata().isOverridable()) {
			// instance @Bean methods within @Configuration classes must be overridable to accommodate CGLIB
			problemReporter.error(new NonOverridableMethodError());
		}
	}
}
 
Example 6
Source File: ConfigurationClass.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public void validate(ProblemReporter problemReporter) {
	// A configuration class may not be final (CGLIB limitation)
	if (getMetadata().isAnnotated(Configuration.class.getName())) {
		if (getMetadata().isFinal()) {
			problemReporter.error(new FinalConfigurationProblem());
		}
	}

	for (BeanMethod beanMethod : this.beanMethods) {
		beanMethod.validate(problemReporter);
	}
}
 
Example 7
Source File: BeanMethod.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void validate(ProblemReporter problemReporter) {
	if (getMetadata().isStatic()) {
		// static @Bean methods have no constraints to validate -> return immediately
		return;
	}

	if (this.configurationClass.getMetadata().isAnnotated(Configuration.class.getName())) {
		if (!getMetadata().isOverridable()) {
			// instance @Bean methods within @Configuration classes must be overridable to accommodate CGLIB
			problemReporter.error(new NonOverridableMethodError());
		}
	}
}
 
Example 8
Source File: ConfigurationClass.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
public void validate(ProblemReporter problemReporter) {
	// A configuration class may not be final (CGLIB limitation)
	if (getMetadata().isAnnotated(Configuration.class.getName())) {
		if (getMetadata().isFinal()) {
			problemReporter.error(new FinalConfigurationProblem());
		}
	}

	for (BeanMethod beanMethod : this.beanMethods) {
		beanMethod.validate(problemReporter);
	}
}