Interface ComponentSource
-
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface ComponentSource
A functional interface used for contributingComponents
to an application.This interface can be registered as a bean within a Spring Boot application in order to contribute components to the application. This interface can be registered as a lambda expression within the configuration class, for example:
@Configuration public class MyMetadataConfiguration { @Bean public ComponentSource myComponents() { return registry -> registry .add("items:list", getItemsList()); } private View> getItemsList() { // return items list view } }
Alternatively, if lambda expressions are not ideal, this interface can be implemented as a concrete class and then registered as a bean, for example:
@Configuration public class MyMetadataConfiguration { @Bean public ComponentSource myComponents() { return new MyComponentSource(); } public static class MyComponentSource extends ComponentSource { @Override public void register(ComponentRegistry> registry) { register.add("items:list", getItemsList()); } private View> getItemsList() { // return items list view } } }
- Author:
- Nick Crum (ncrum)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
register(ComponentRegistry<?> registry)
Used for registering or modifying components within theComponentRegistry
.
-
-
-
Method Detail
-
register
void register(ComponentRegistry<?> registry)
Used for registering or modifying components within theComponentRegistry
.- Parameters:
registry
- the component registry
-
-