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 ApplicationContextThe context used to load this bean.private final org.slf4j.LoggerClass logger.private final ReentrantReadWriteLockLock for this service. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void.protected voidGet the context used to load this bean.abstract T.voidGrab the service lock shared.voidsetApplicationContext(ApplicationContext context) void.voiddrop the shared lock.Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent
setIdMethods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
getIdMethods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, initialize, isDestroyed, isInitializedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
setApplicationContextin interfaceApplicationContextAware
-
getApplicationContext
Get the context used to load this bean.- Returns:
- the context.
-
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
- Overrides:
doInitializein classAbstractIdentifiedInitializableComponent- Throws:
ComponentInitializationException
-