public class SpringbootDependencyContext
extends java.lang.Object
implements io.flamingock.internal.common.core.context.ContextResolver
ContextResolver that resolves dependencies and properties
using a Spring Boot 2 ApplicationContext.
It supports retrieval of beans by type or name and reads namespaced properties (prefixed with flamingock.)
from the Spring Environment.
| Constructor and Description |
|---|
SpringbootDependencyContext(org.springframework.context.ApplicationContext applicationContext)
Creates a new dependency context backed by the given Spring
ApplicationContext. |
| Modifier and Type | Method and Description |
|---|---|
java.util.Optional<io.flamingock.internal.common.core.context.Dependency> |
getDependency(java.lang.Class<?> type)
Attempts to retrieve a bean from the Spring context by its type.
|
java.util.Optional<io.flamingock.internal.common.core.context.Dependency> |
getDependency(java.lang.String name)
Attempts to retrieve a bean from the Spring context by its name.
|
java.util.Optional<java.lang.String> |
getProperty(java.lang.String key)
Retrieves a property value as a
String from the Spring Environment, using the flamingock. prefix. |
<T> java.util.Optional<T> |
getPropertyAs(java.lang.String key,
java.lang.Class<T> type)
Retrieves a property value and converts it to the specified type using Spring's conversion service,
using the
flamingock. prefix. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpublic SpringbootDependencyContext(org.springframework.context.ApplicationContext applicationContext)
ApplicationContext.applicationContext - the Spring application context to use for dependency and property resolutionpublic java.util.Optional<io.flamingock.internal.common.core.context.Dependency> getDependency(java.lang.Class<?> type)
getDependency in interface io.flamingock.internal.common.core.context.DependencyResolvertype - the class type of the beanOptional containing the dependency if found, otherwise emptypublic java.util.Optional<io.flamingock.internal.common.core.context.Dependency> getDependency(java.lang.String name)
getDependency in interface io.flamingock.internal.common.core.context.DependencyResolvername - the name of the beanOptional containing the dependency if found, otherwise emptypublic java.util.Optional<java.lang.String> getProperty(java.lang.String key)
String from the Spring Environment, using the flamingock. prefix.getProperty in interface io.flamingock.internal.common.core.context.PropertyResolverkey - the property key (without prefix)Optional containing the value if present, otherwise emptypublic <T> java.util.Optional<T> getPropertyAs(java.lang.String key,
java.lang.Class<T> type)
flamingock. prefix.getPropertyAs in interface io.flamingock.internal.common.core.context.PropertyResolverT - the type of the returned valuekey - the property key (without prefix)type - the expected type of the valueOptional containing the converted value if present, otherwise empty