Skip to content
This repository has been archived by the owner on Jul 9, 2022. It is now read-only.

Reflection-free binding to @ConfigurationProperties #22

Closed
dsyer opened this issue Aug 5, 2020 · 1 comment
Closed

Reflection-free binding to @ConfigurationProperties #22

dsyer opened this issue Aug 5, 2020 · 1 comment
Labels
help wanted Extra attention is needed
Milestone

Comments

@dsyer
Copy link
Contributor

dsyer commented Aug 5, 2020

Might need some changes in Spring Boot, but progress can probably be made by generating a BeanPostProcessor that knows about all the @ConfigurationProperties in the classpath.

@dsyer dsyer added the help wanted Extra attention is needed label Aug 5, 2020
@dsyer
Copy link
Contributor Author

dsyer commented Aug 6, 2020

Added a new interface:

public interface PropertiesBinder<T> {

	T bind(T bean, Environment environment);

}

user registers instances with the InfrastructureUtils, e.g.

public class PropertiesBinderInfrastructureProvider implements InfrastructureProvider {

	@Override
	public Collection<? extends ApplicationContextInitializer<GenericApplicationContext>> getInitializers(
			GenericApplicationContext main) {
		return Arrays.asList(context -> InfrastructureUtils.registerPropertyBinder(context, ServerProperties.class,
				new ServerPropertiesPropertiesBinder()));
	}

}

The "func" and "tunc" samples now bind to server.port through this interface, and therefore work in native images without any additional reflection configuration.

@dsyer dsyer closed this as completed Aug 6, 2020
@dsyer dsyer added this to the 0.0.1 milestone Aug 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed
Development

No branches or pull requests

1 participant