Skip to content

Purge private classes and interfaces in @Bean methods #13490

Closed
@dsyer

Description

@dsyer

I would like Spring Boot autoconfiguration to be a public (or at least package-private) contract, so that I can use it to create functional bean registrations with all the same features. There's a barrier to doing that, which is that there are some private types that can't be used, even from a class in the same package.

There are a bunch of these in Spring Boot autoconfiguration, generally following one of two patterns. The first is a private class with a public interface, e.g. in ErrorMvcAutoConfiguration:

	@Bean
	public ErrorPageCustomizer errorPageCustomizer() {
		return new ErrorPageCustomizer(this.serverProperties);
	}

	private static class ErrorPageCustomizer implements ErrorPageRegistrar, Ordered {
		...
	}

The second is a private class with a private interface, e.g. in WebMvcAutoConfiguration:

	@Configuration
	@ConditionalOnEnabledResourceChain
	static class ResourceChainCustomizerConfiguration {

		@Bean
		public ResourceChainResourceHandlerRegistrationCustomizer resourceHandlerRegistrationCustomizer() {
			return new ResourceChainResourceHandlerRegistrationCustomizer();
		}

	}

	interface ResourceHandlerRegistrationCustomizer {

		void customize(ResourceHandlerRegistration registration);

	}

	private static class ResourceChainResourceHandlerRegistrationCustomizer
			implements ResourceHandlerRegistrationCustomizer {
		...
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions