edu.internet2.middleware.shibboleth.common.config
Class BaseService

java.lang.Object
  extended by edu.internet2.middleware.shibboleth.common.config.BaseService
All Implemented Interfaces:
Service, org.springframework.beans.factory.BeanNameAware, org.springframework.context.ApplicationContextAware
Direct Known Subclasses:
BaseReloadableService, ShibbolethSAML1AttributeAuthority, ShibbolethSAML2AttributeAuthority

public abstract class BaseService
extends Object
implements Service, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.BeanNameAware

A service whose Spring beans are loaded into a service specific ApplicationContext that is a child of the context provided in setApplicationContext(ApplicationContext). Services derived from this base class may not be re-initialized after they have been destroyed.


Field Summary
private  boolean isDestroyed
          Indicates if the service has been destroyed.
private  boolean isInitialized
          Indicates if the service has been initialized already.
private  org.slf4j.Logger log
          Class logger.
private  org.springframework.context.ApplicationContext owningContext
          Application context owning this engine.
private  ArrayList<org.opensaml.util.resource.Resource> serviceConfigurations
          List of configuration resources for this service.
private  org.springframework.context.support.GenericApplicationContext serviceContext
          Context containing loaded with service content.
private  ReentrantReadWriteLock serviceContextRWLock
          Read/Write lock for the context.
private  String serviceName
          Unique name of this service.
 
Constructor Summary
BaseService()
          Constructor.
 
Method Summary
 void destroy()
          Destroys a service, freeing any resources it may currently be using.
 org.springframework.context.ApplicationContext getApplicationContext()
          Gets the application context that is the parent to this service's context.
 String getId()
          Gets the ID of this service.
protected  ReadWriteLock getReadWriteLock()
          Gets the read-write lock guarding the service context.
 List<org.opensaml.util.resource.Resource> getServiceConfigurations()
          Gets an unmodifiable list of configurations for this service.
 org.springframework.context.ApplicationContext getServiceContext()
          Gets this service's context.
 void initialize()
          Initializes this service.
 boolean isDestroyed()
          Gets whether the service has been destroyed.
 boolean isInitialized()
          Gets whether the service is initialized and ready for use.
protected  void loadContext()
          Loads the service context.
protected abstract  void onNewContextCreated(org.springframework.context.ApplicationContext newServiceContext)
          Called after a new context has been created but before it set as the service's context.
 void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
          Sets the application context that is the parent to this service's context.
 void setBeanName(String name)
          
protected  void setInitialized(boolean initialized)
          Sets whether this service has been initialized.
 void setServiceConfigurations(List<org.opensaml.util.resource.Resource> configurations)
          Sets the service's configuration resources.
protected  void setServiceContext(org.springframework.context.support.GenericApplicationContext context)
          Sets this service's context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private final org.slf4j.Logger log
Class logger.


serviceName

private String serviceName
Unique name of this service.


serviceContextRWLock

private ReentrantReadWriteLock serviceContextRWLock
Read/Write lock for the context.


owningContext

private org.springframework.context.ApplicationContext owningContext
Application context owning this engine.


serviceContext

private org.springframework.context.support.GenericApplicationContext serviceContext
Context containing loaded with service content.


serviceConfigurations

private ArrayList<org.opensaml.util.resource.Resource> serviceConfigurations
List of configuration resources for this service.


isInitialized

private boolean isInitialized
Indicates if the service has been initialized already.


isDestroyed

private boolean isDestroyed
Indicates if the service has been destroyed.

Constructor Detail

BaseService

public BaseService()
Constructor.

Method Detail

destroy

public void destroy()
             throws ServiceException
Destroys a service, freeing any resources it may currently be using. Whether a service can be re-initialized after being destroyed is implementation dependent.

Specified by:
destroy in interface Service
Throws:
ServiceException - thrown if there is a problem destroying the service

getApplicationContext

public org.springframework.context.ApplicationContext getApplicationContext()
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

getId

public String getId()
Gets the ID of this service.

Specified by:
getId in interface Service
Returns:
ID of this service

getReadWriteLock

protected ReadWriteLock getReadWriteLock()
Gets the read-write lock guarding the service context.

Returns:
read-write lock guarding the service context

getServiceConfigurations

public List<org.opensaml.util.resource.Resource> getServiceConfigurations()
Gets an unmodifiable list of configurations for this service.

Returns:
unmodifiable list of configurations for this service

getServiceContext

public org.springframework.context.ApplicationContext getServiceContext()
Gets this service's context.

Returns:
this service's context

initialize

public void initialize()
                throws ServiceException
Initializes this service. Calling this on an initialized service should return immediately without affecting any service state.

Specified by:
initialize in interface Service
Throws:
ServiceException - thrown if there is a problem initializing the service

isInitialized

public boolean isInitialized()
Gets whether the service is initialized and ready for use.

Specified by:
isInitialized in interface Service
Returns:
true if the service is ready for use, false it not

isDestroyed

public boolean isDestroyed()
Gets whether the service has been destroyed.

Specified by:
isDestroyed in interface Service
Returns:
true if the service has been destroyed

loadContext

protected void loadContext()
                    throws ServiceException
Loads the service context.

Throws:
ServiceException - thrown if the configuration for this service could not be loaded

onNewContextCreated

protected abstract void onNewContextCreated(org.springframework.context.ApplicationContext newServiceContext)
                                     throws ServiceException
Called after a new context has been created but before it set as the service's context. If an exception is thrown the new context will not be set as the service's context and the current service context will be retained.

Parameters:
newServiceContext - the newly created context for the service
Throws:
ServiceException - thrown if there is a problem with the given service context

setApplicationContext

public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
Sets the application context that is the parent to this service's context.

Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware

setBeanName

public void setBeanName(String name)

Specified by:
setBeanName in interface org.springframework.beans.factory.BeanNameAware

setInitialized

protected void setInitialized(boolean initialized)
Sets whether this service has been initialized.

Parameters:
initialized - whether this service has been initialized

setServiceConfigurations

public void setServiceConfigurations(List<org.opensaml.util.resource.Resource> configurations)
Sets the service's configuration resources.

Parameters:
configurations - configuration resources for the service

setServiceContext

protected void setServiceContext(org.springframework.context.support.GenericApplicationContext context)
Sets this service's context.

Parameters:
context - this service's context


Copyright © 1999-2012. All Rights Reserved.