Module net.shibboleth.ext.spring
Class ReloadableSpringService<T>
- java.lang.Object
-
- net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
-
- net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
-
- net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent
-
- net.shibboleth.utilities.java.support.service.AbstractReloadableService<T>
-
- net.shibboleth.ext.spring.service.ReloadableSpringService<T>
-
- Type Parameters:
T- The precise service being implemented.
- All Implemented Interfaces:
Component,DestructableComponent,IdentifiableComponent,IdentifiedComponent,InitializableComponent,UnmodifiableComponent,ReloadableService<T>,Aware,BeanNameAware,ApplicationContextAware,Lifecycle
@ThreadSafe public class ReloadableSpringService<T> extends AbstractReloadableService<T> implements ApplicationContextAware, BeanNameAware, Lifecycle
This class provides a reloading interface to aServiceableComponentvia Spring. This class extendsLifecycle. and thus it acts as the bridge between this interface andInitializableComponentandDestructableComponent
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.shibboleth.utilities.java.support.service.AbstractReloadableService
AbstractReloadableService.ServiceReloadTask
-
-
Field Summary
Fields Modifier and Type Field Description private StringbeanNameThe bean name.private Collection<String>beanProfilesBean profiles to enable.private ServiceableComponent<T>cachedComponentThe last known good component.private ConversionServiceconversionServiceConversion service to use.private List<BeanFactoryPostProcessor>factoryPostProcessorsList of bean factory post processors for this service's content.private booleanlastLoadFailedDid the last load fail? An optimization only.private org.slf4j.LoggerlogClass logger.private ApplicationContextparentContextApplication context owning this engine.private List<BeanPostProcessor>postProcessorsList of bean post processors for this service's content.private Instant[]resourceLastModifiedTimesTime when the service configuration for the given index was last observed to have changed.private List<Resource>serviceConfigurationsList of configuration resources for this service.private Function<ApplicationContext,ServiceableComponent<T>>serviceStrategyHow to summon up theServiceableComponentfrom theApplicationContext.private Class<T>theClazThe class we are looking for.
-
Constructor Summary
Constructors Constructor Description ReloadableSpringService(Class<T> claz)Constructor.ReloadableSpringService(Class<T> claz, Function<ApplicationContext,ServiceableComponent<T>> strategy)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoDestroy()protected voiddoInitialize()protected voiddoReload()ApplicationContextgetParentContext()Gets the application context that is the parent to this service's context.ServiceableComponent<T>getServiceableComponent()Get the serviceable component.List<Resource>getServiceConfigurations()Gets an unmodifiable list of configurations for this service.booleanisRunning().voidsetApplicationContext(ApplicationContext applicationContext)voidsetBeanFactoryPostProcessors(List<BeanFactoryPostProcessor> processors)Set the list of bean factory post processors for this service.voidsetBeanName(String name)voidsetBeanPostProcessors(List<BeanPostProcessor> processors)Set the list of bean post processors for this service.voidsetBeanProfiles(Collection<String> profiles)Set the bean profiles for this service.voidsetConversionService(ConversionService service)Set a conversion service to use.voidsetParentContext(ApplicationContext context)Sets the application context that is the parent to this service's context.voidsetServiceConfigurations(List<Resource> configs)Set the list of configurations for this service.voidsetServiceConfigurationStrategy(Function<?,List<Resource>> strategy)Set the strategy by which the Service can locate the resources it needs to know about.protected booleanshouldReload()voidstart()voidstop()-
Methods inherited from class net.shibboleth.utilities.java.support.service.AbstractReloadableService
getLastReloadAttemptInstant, getLastSuccessfulReloadInstant, getLogPrefix, getReloadCheckDelay, getReloadFailureCause, getReloadTaskTimer, isFailFast, reload, setFailFast, setReloadCheckDelay, setReloadTaskTimer
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent
setId
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
getId
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, initialize, isDestroyed, isInitialized
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.shibboleth.utilities.java.support.component.IdentifiedComponent
getId
-
Methods inherited from interface net.shibboleth.utilities.java.support.component.InitializableComponent
initialize, isInitialized
-
-
-
-
Field Detail
-
log
@Nonnull private final org.slf4j.Logger log
Class logger.
-
serviceConfigurations
@Nonnull @NonnullElements private List<Resource> serviceConfigurations
List of configuration resources for this service.
-
factoryPostProcessors
@Nonnull @NonnullElements private List<BeanFactoryPostProcessor> factoryPostProcessors
List of bean factory post processors for this service's content.
-
postProcessors
@Nonnull @NonnullElements private List<BeanPostProcessor> postProcessors
List of bean post processors for this service's content.
-
beanProfiles
@Nonnull @NonnullElements private Collection<String> beanProfiles
Bean profiles to enable.
-
conversionService
@Nullable private ConversionService conversionService
Conversion service to use.
-
serviceStrategy
@Nonnull private final Function<ApplicationContext,ServiceableComponent<T>> serviceStrategy
How to summon up theServiceableComponentfrom theApplicationContext.
-
parentContext
@Nullable private ApplicationContext parentContext
Application context owning this engine.
-
beanName
@Nullable private String beanName
The bean name.
-
cachedComponent
@Nullable private ServiceableComponent<T> cachedComponent
The last known good component.
-
lastLoadFailed
private boolean lastLoadFailed
Did the last load fail? An optimization only.
-
resourceLastModifiedTimes
@Nullable private Instant[] resourceLastModifiedTimes
Time when the service configuration for the given index was last observed to have changed. A null indicates the configuration resource did not exist.
-
-
Constructor Detail
-
ReloadableSpringService
public ReloadableSpringService(@Nonnull @ParameterName(name="claz") Class<T> claz)
Constructor.- Parameters:
claz- The interface being implemented.
-
ReloadableSpringService
public ReloadableSpringService(@Nonnull @ParameterName(name="claz") Class<T> claz, @Nonnull @ParameterName(name="strategy") Function<ApplicationContext,ServiceableComponent<T>> strategy)
Constructor.- Parameters:
claz- The interface being implemented.strategy- the strategy to use to look up servicable component to look for.
-
-
Method Detail
-
getParentContext
@Nullable public ApplicationContext getParentContext()
Gets the application context that is the parent to this service's context.- Returns:
- application context that is the parent to this service's context
-
setParentContext
public void setParentContext(@Nullable ApplicationContext context)Sets the application context that is the parent to this service's context. This setting can not be changed after the service has been initialized.- Parameters:
context- context that is the parent to this service's context, may be null
-
getServiceConfigurations
@Nonnull public List<Resource> getServiceConfigurations()
Gets an unmodifiable list of configurations for this service.- Returns:
- unmodifiable list of configurations for this service
-
setServiceConfigurations
public void setServiceConfigurations(@Nonnull @NonnullElements List<Resource> configs)
Set the list of configurations for this service. This setting can not be changed after the service has been initialized.- Parameters:
configs- list of configurations for this service
-
setServiceConfigurationStrategy
public void setServiceConfigurationStrategy(@Nonnull Function<?,List<Resource>> strategy)Set the strategy by which the Service can locate the resources it needs to know about.Not implemented.
- Parameters:
strategy- the way to get the resources. Precise details are tbd.
-
setBeanFactoryPostProcessors
public void setBeanFactoryPostProcessors(@Nonnull @NonnullElements List<BeanFactoryPostProcessor> processors)
Set the list of bean factory post processors for this service.- Parameters:
processors- bean factory post processors to apply
-
setBeanPostProcessors
public void setBeanPostProcessors(@Nonnull @NonnullElements List<BeanPostProcessor> processors)
Set the list of bean post processors for this service.- Parameters:
processors- bean post processors to apply
-
setBeanProfiles
public void setBeanProfiles(@Nonnull @NonnullElements Collection<String> profiles)
Set the bean profiles for this service.- Parameters:
profiles- bean profiles to apply- Since:
- 5.4.0
-
setConversionService
public void setConversionService(@Nullable ConversionService service)Set a conversion service to use.- Parameters:
service- conversion service- Since:
- 5.4.0
-
shouldReload
protected boolean shouldReload()
- Specified by:
shouldReloadin classAbstractReloadableService<T>
-
doReload
protected void doReload()
- Overrides:
doReloadin classAbstractReloadableService<T>
-
doDestroy
protected void doDestroy()
- Overrides:
doDestroyin classAbstractReloadableService<T>
-
getServiceableComponent
public ServiceableComponent<T> getServiceableComponent()
Get the serviceable component. We do this under interlock and grab the lock on the component.- Specified by:
getServiceableComponentin interfaceReloadableService<T>- Returns:
- the pinned component.
-
setApplicationContext
public void setApplicationContext(ApplicationContext applicationContext)
- Specified by:
setApplicationContextin interfaceApplicationContextAware
-
setBeanName
public void setBeanName(String name)
- Specified by:
setBeanNamein interfaceBeanNameAware
-
doInitialize
protected void doInitialize() throws ComponentInitializationException- Overrides:
doInitializein classAbstractReloadableService<T>- Throws:
ComponentInitializationException
-
-