Class DefaultDiscriminatedPropertyAccessor
java.lang.Object
com.broadleafcommerce.common.extension.environment.DefaultDiscriminatedPropertyAccessor
- All Implemented Interfaces:
DiscriminatedPropertyAccessor
,EventListener
,org.springframework.context.ApplicationListener<org.springframework.cloud.context.environment.EnvironmentChangeEvent>
public class DefaultDiscriminatedPropertyAccessor
extends Object
implements DiscriminatedPropertyAccessor, org.springframework.context.ApplicationListener<org.springframework.cloud.context.environment.EnvironmentChangeEvent>
- See Also:
-
Constructor Summary
ConstructorDescriptionDefaultDiscriminatedPropertyAccessor
(org.springframework.core.env.Environment environment) -
Method Summary
Modifier and TypeMethodDescription<T> T
getProperty
(String key, Class<?> type, Supplier<Object> defaultValue) Fetch a marshalled configuration property instance from the Spring environmentvoid
init()
void
onApplicationEvent
(org.springframework.cloud.context.environment.EnvironmentChangeEvent event) Invalidate the cache for any property that have changed in the environment
-
Constructor Details
-
DefaultDiscriminatedPropertyAccessor
public DefaultDiscriminatedPropertyAccessor(org.springframework.core.env.Environment environment)
-
-
Method Details
-
init
@PostConstruct public void init() -
onApplicationEvent
public void onApplicationEvent(org.springframework.cloud.context.environment.EnvironmentChangeEvent event) Invalidate the cache for any property that have changed in the environment- Specified by:
onApplicationEvent
in interfaceorg.springframework.context.ApplicationListener<org.springframework.cloud.context.environment.EnvironmentChangeEvent>
- Parameters:
event
- the event to respond to
-
getProperty
Description copied from interface:DiscriminatedPropertyAccessor
Fetch a marshalled configuration property instance from the Spring environment- Specified by:
getProperty
in interfaceDiscriminatedPropertyAccessor
- Type Parameters:
T
- The type of the marshalled property value- Parameters:
key
- The basic key to use to check the environment.type
- The type to marshall the environment value todefaultValue
- Supplier for the default value taken from theConfigurationProperties
bean instance variable- Returns:
- The marshalled property value
-