Package net.shibboleth.shared.spring.service

# Class ReloadableSpringService<T>

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
net.shibboleth.shared.service.AbstractReloadableService<T>
net.shibboleth.shared.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`

@ThreadSafe public class ReloadableSpringService<T> extends AbstractReloadableService<T> implements ApplicationContextAware, BeanNameAware
This class provides a reloading interface to a `ServiceableComponent` via Spring. This class extends `Lifecycle`. and thus it acts as the bridge between this interface and `InitializableComponent` and `DestructableComponent`

## Nested Class Summary

## Nested classes/interfaces inherited from class net.shibboleth.shared.service.AbstractReloadableService

`AbstractReloadableService.ServiceReloadTask`

## Field Summary

Fields
Modifier and Type
Field
Description
`private String`
`beanName`
The bean name.
`private Collection<String>`
`beanProfiles`
Bean profiles to enable.
`private AbstractServiceableComponent<T>`
`cachedComponent`
The last known good component.
`private ConversionService`
`conversionService`
Conversion service to use.
`private List<BeanFactoryPostProcessor>`
`factoryPostProcessors`
List of bean factory post processors for this service's content.
`private boolean`
`lastLoadFailed`
Did the last load fail? An optimization only.
`private final org.slf4j.Logger`
`log`
Class logger.
`private ApplicationContext`
`parentContext`
Application context owning this engine.
`private List<BeanPostProcessor>`
`postProcessors`
List of bean post processors for this service's content.
`private Instant[]`
`resourceLastModifiedTimes`
Time when the service configuration for the given index was last observed to have changed.
`private List<Resource>`
`serviceConfigurations`
List of configuration resources for this service.
`private final NonnullFunction<ApplicationContext,AbstractServiceableComponent<T>>`
`serviceStrategy`
How to summon up the `ServiceableComponent` from the `ApplicationContext`.
`private final Class<T>`
`theClaz`
The class we are looking for.

## Constructor Summary

Constructors
Constructor
Description
`ReloadableSpringService(Class<T> claz)`
Constructor.
`ReloadableSpringService(Class<T> claz, NonnullFunction<ApplicationContext,AbstractServiceableComponent<T>> strategy)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`protected void`
`doDestroy()`
Performs component specific destruction logic.
`protected void`
`doInitialize()`
This method checks to ensure that the component ID is not null.
`protected void`
`doReload()`
Performs the actual reload.
`ApplicationContext`
`getParentContext()`
Gets the application context that is the parent to this service's context.
`AbstractServiceableComponent<T>`
`getServiceableComponent()`
Get the serviceable component that this service supports.
`List<Resource>`
`getServiceConfigurations()`
Gets an unmodifiable list of configurations for this service.
`void`
`setApplicationContext(ApplicationContext applicationContext)`
`void`
`setBeanFactoryPostProcessors(List<BeanFactoryPostProcessor> processors)`
Set the list of bean factory post processors for this service.
`void`
`setBeanName(String name)`
`void`
`setBeanPostProcessors(List<BeanPostProcessor> processors)`
Set the list of bean post processors for this service.
`void`
`setBeanProfiles(Collection<String> profiles)`
Set the bean profiles for this service.
`void`
`setConversionService(ConversionService service)`
Set a conversion service to use.
`void`
`setParentContext(ApplicationContext context)`
Sets the application context that is the parent to this service's context.
`void`
`setServiceConfigurations(List<Resource> configs)`
Set the list of configurations for this service.
`void`
`setServiceConfigurationStrategy(Function<?,List<Resource>> strategy)`
Set the strategy by which the Service can locate the resources it needs to know about.
`protected boolean`
`shouldReload()`
Called by the `AbstractReloadableService<T>.ServiceReloadTask` to determine if the service should be reloaded.

### Methods inherited from class net.shibboleth.shared.service.AbstractReloadableService

`getLastReloadAttemptInstant, getLastSuccessfulReloadInstant, getLogPrefix, getReloadCheckDelay, getReloadFailureCause, getReloadTaskTimer, isFailFast, reload, setFailFast, setReloadCheckDelay, setReloadTaskTimer`

### Methods inherited from class net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent

`setId`

### Methods inherited from class net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent

`ensureId, getId, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException`

### Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent

`checkComponentActive, checkSetterPreconditions, 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.shared.component.IdentifiedComponent

`getId`

### Methods inherited from interface net.shibboleth.shared.component.InitializableComponent

`initialize, isInitialized`

## Field Details

### log

@Nonnull private final org.slf4j.Logger log
Class logger.

### serviceConfigurations

@Nonnull private List<Resource> serviceConfigurations
List of configuration resources for this service.

### factoryPostProcessors

@Nonnull private List<BeanFactoryPostProcessor> factoryPostProcessors
List of bean factory post processors for this service's content.

### postProcessors

@Nonnull private List<BeanPostProcessor> postProcessors
List of bean post processors for this service's content.

### beanProfiles

@Nonnull private Collection<String> beanProfiles
Bean profiles to enable.

### conversionService

@Nullable private ConversionService conversionService
Conversion service to use.

### theClaz

@Nonnull private final Class<T> theClaz
The class we are looking for.

### serviceStrategy

@Nonnull private final NonnullFunction<ApplicationContext,AbstractServiceableComponent<T>> serviceStrategy
How to summon up the `ServiceableComponent` from the `ApplicationContext`.

### parentContext

@Nullable private ApplicationContext parentContext
Application context owning this engine.

### beanName

@Nullable private String beanName
The bean name.

### cachedComponent

@Nullable private AbstractServiceableComponent<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 Details

### 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") NonnullFunction<ApplicationContext,AbstractServiceableComponent<T>> strategy)
Constructor.

Parameters:
  `claz` - The interface being implemented.
  `strategy` - the strategy to use to look up servicable component to look for.

## Method Details

### 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 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 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 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 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()
Called by the `AbstractReloadableService<T>.ServiceReloadTask` to determine if the service should be reloaded.

No lock is held when this method is called, so any locking needed should be handled internally.

Specified by:
  `shouldReload` in class `AbstractReloadableService<T>`
Returns:
  true iff the service should be reloaded

### doReload

protected void doReload()
Performs the actual reload.

No lock is held when this method is called, so any locking needed should be handled internally.

Overrides:
  `doReload` in class `AbstractReloadableService<T>`

### doDestroy

protected void doDestroy()
Performs component specific destruction logic. This method is executed within the lock on the object being destroyed. The default implementation of this method is a no-op.

Overrides:
  `doDestroy` in class `AbstractReloadableService<T>`

### getServiceableComponent

@Nonnull public AbstractServiceableComponent<T> getServiceableComponent() throws ServiceException
Get the serviceable component that this service supports. If the component hasn't been successfully loaded yet or if this service does not support a ServiceableComponent, a `ServiceException` is raised.

On a non-null value, the returned component will be pinned and MUST be closed. This can be done by exploiting the fact that a ServiceableComponent implements `AutoCloseable`

Get the serviceable component. We do this under interlock and grab the lock on the component.

Specified by:
  `getServiceableComponent` in interface `ReloadableService<T>`
Returns:
  the pinned component.
Throws:
  `ServiceException` - if the component is not available

### setApplicationContext

public void setApplicationContext(@Nonnull ApplicationContext applicationContext)

Specified by:
  `setApplicationContext` in interface `ApplicationContextAware`

### setBeanName

public void setBeanName(@Nonnull String name)

Specified by:
  `setBeanName` in interface `BeanNameAware`

### doInitialize

protected void doInitialize() throws ComponentInitializationException
This method checks to ensure that the component ID is not null. Performs the initialization of the component. This method is executed within the lock on the object being initialized. The default implementation of this method is a no-op.

Overrides:
  `doInitialize` in class `AbstractReloadableService<T>`
Throws:
  `ComponentInitializationException` - thrown if there is a problem initializing the component