Class AbstractServiceableComponent<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.ext.spring.service.AbstractServiceableComponent<T>
- Type Parameters:
T
- The type of service.
- All Implemented Interfaces:
Component
,DestructableComponent
,IdentifiableComponent
,IdentifiedComponent
,InitializableComponent
,ServiceableComponent<T>
,Aware
,ApplicationContextAware
- Direct Known Subclasses:
ApplicationContextServiceableComponent
public abstract class AbstractServiceableComponent<T>
extends AbstractIdentifiableInitializableComponent
implements ServiceableComponent<T>, ApplicationContextAware
Implementation of
ServiceableComponent
that does most of the work required. It leverages the spring
environment to allow easy cleanup.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ApplicationContext
The context used to load this bean.private final org.slf4j.Logger
Class logger.private final ReentrantReadWriteLock
Lock for this service. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
.protected void
Get the context used to load this bean.abstract T
.void
Grab the service lock shared.void
setApplicationContext
(ApplicationContext context) void
.void
drop the shared lock.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
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
applicationContext
The context used to load this bean. -
serviceLock
Lock for this service. We make it unfair since we will control access and there will only ever be contention during unload.
-
-
Constructor Details
-
AbstractServiceableComponent
public AbstractServiceableComponent()Constructor.
-
-
Method Details
-
setApplicationContext
- Specified by:
setApplicationContext
in interfaceApplicationContextAware
-
getApplicationContext
Get the context used to load this bean.- Returns:
- the context.
-
getComponent
.- Specified by:
getComponent
in interfaceServiceableComponent<T>
-
pinComponent
public void pinComponent()Grab the service lock shared. This will block unloads untilunpinComponent()
is called.- Specified by:
pinComponent
in interfaceServiceableComponent<T>
-
unpinComponent
public void unpinComponent()drop the shared lock.- Specified by:
unpinComponent
in interfaceServiceableComponent<T>
-
unloadComponent
public void unloadComponent(). Grab the service lock ex and then call spring to tear everything down.- Specified by:
unloadComponent
in interfaceServiceableComponent<T>
-
doDestroy
protected void doDestroy(). Force unload; this will usually be a no-op since the component should have been explicitly unloaded, but we do the unload here so that error cases also clean up.- Overrides:
doDestroy
in classAbstractInitializableComponent
-
doInitialize
- Overrides:
doInitialize
in classAbstractIdentifiedInitializableComponent
- Throws:
ComponentInitializationException
-