Module net.shibboleth.ext.spring
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 ofServiceableComponentthat does most of the work required. It leverages the spring environment to allow easy cleanup.
-
-
Field Summary
Fields Modifier and Type Field Description private ApplicationContextapplicationContextThe context used to load this bean.private org.slf4j.LoggerlogClass logger.private ReentrantReadWriteLockserviceLockLock for this service.
-
Constructor Summary
Constructors Constructor Description AbstractServiceableComponent()Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voiddoDestroy().protected voiddoInitialize()ApplicationContextgetApplicationContext()Get the context used to load this bean.abstract TgetComponent().voidpinComponent()Grab the service lock shared.voidsetApplicationContext(ApplicationContext context)voidunloadComponent().voidunpinComponent()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 Detail
-
log
@Nonnull private final org.slf4j.Logger log
Class logger.
-
applicationContext
@Nullable private ApplicationContext applicationContext
The context used to load this bean.
-
serviceLock
@Nonnull private final ReentrantReadWriteLock serviceLock
Lock for this service. We make it unfair since we will control access and there will only ever be contention during unload.
-
-
Method Detail
-
setApplicationContext
public void setApplicationContext(ApplicationContext context)
- Specified by:
setApplicationContextin interfaceApplicationContextAware
-
getApplicationContext
@Nullable public ApplicationContext getApplicationContext()
Get the context used to load this bean.- Returns:
- the context.
-
getComponent
@Nonnull public abstract T getComponent()
.- Specified by:
getComponentin interfaceServiceableComponent<T>
-
pinComponent
public void pinComponent()
Grab the service lock shared. This will block unloads untilunpinComponent()is called.- Specified by:
pinComponentin interfaceServiceableComponent<T>
-
unpinComponent
public void unpinComponent()
drop the shared lock.- Specified by:
unpinComponentin interfaceServiceableComponent<T>
-
unloadComponent
public void unloadComponent()
. Grab the service lock ex and then call spring to tear everything down.- Specified by:
unloadComponentin 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:
doDestroyin classAbstractInitializableComponent
-
doInitialize
protected void doInitialize() throws ComponentInitializationException- Overrides:
doInitializein classAbstractIdentifiedInitializableComponent- Throws:
ComponentInitializationException
-
-