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

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

public abstract class BaseReloadableService
extends BaseService
implements ReloadableService

An extension to BaseService that allows the service's context to be reloaded if the underlying configuration resources are changed. If, at construction time, polling frequency and retry attempt are given then the configuration resources will be watched for changes. If a change is detected then the current service's context will be dropped and a new one created from all resource files. If there is a problem loading a configuration resource during this process the existing service context is kept and an error is logged. The result of this occuring during the initial configuration load is implementation dependent. NOTE: Service implementations must take out a read lock, through BaseService.getReadWriteLock(), whenever reading or operating on information controlled by the service context. This will ensure that if a configuration change occurs the service context will not be replaced until after all current reads have completed.


Nested Class Summary
protected  class BaseReloadableService.ConfigurationResourceListener
          A listener for policy resource changes that triggers a reloading of the AFP context.
 
Constructor Summary
BaseReloadableService()
          Constructor.
 
Method Summary
 void destroy()
          Destroys a service, freeing any resources it may currently be using.
 long getPollingFrequency()
          Gets the frequency, in milliseconds, that the configuration resources are polled.
 int getPollingRetryAttempts()
          Gets the number of times a resource may error out before it is considered permanently invalid.
 Timer getPollingTimer()
          Gets the timer used to resource polling jobs.
 void initialize()
          Initializes this service.
 void reload()
          Reloads the configuration of the service.
 void setPollingFrequency(long frequency)
          Sets the frequency, in milliseconds, that the configuration resources are polled.
 void setPollingRetryAttempts(int attempts)
          Sets the number of times a resource may error out before it is considered permanently invalid.
 void setPollingTimer(Timer timer)
          Sets the timer used to resource polling jobs.
 
Methods inherited from class edu.internet2.middleware.shibboleth.common.config.BaseService
getApplicationContext, getId, getReadWriteLock, getServiceConfigurations, getServiceContext, isDestroyed, isInitialized, loadContext, onNewContextCreated, setApplicationContext, setBeanName, setInitialized, setServiceConfigurations, setServiceContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.internet2.middleware.shibboleth.common.service.Service
getId, isDestroyed, isInitialized
 

Constructor Detail

BaseReloadableService

public BaseReloadableService()
Constructor. Configuration resources are not monitored for changes. Sets polling frequency to 0 and retry attempts to 0.

Method Detail

getPollingTimer

public Timer getPollingTimer()
Gets the timer used to resource polling jobs.

Returns:
timer used to resource polling jobs

setPollingTimer

public void setPollingTimer(Timer timer)
Sets the timer used to resource polling jobs.

Parameters:
timer - timer used to resource polling jobs

getPollingFrequency

public long getPollingFrequency()
Gets the frequency, in milliseconds, that the configuration resources are polled.

Returns:
frequency, in milliseconds, that the configuration resources are polled

setPollingFrequency

public void setPollingFrequency(long frequency)
Sets the frequency, in milliseconds, that the configuration resources are polled.

Parameters:
frequency - the frequency, in milliseconds, that the configuration resources are polled

getPollingRetryAttempts

public int getPollingRetryAttempts()
Gets the number of times a resource may error out before it is considered permanently invalid.

Returns:
number of times a resource may error out before it is considered permanently invalid

setPollingRetryAttempts

public void setPollingRetryAttempts(int attempts)
Sets the number of times a resource may error out before it is considered permanently invalid.

Parameters:
attempts - number of times a resource may error out before it is considered permanently invalid

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
Overrides:
initialize in class BaseService
Throws:
ServiceException - thrown if there is a problem initializing the service

reload

public void reload()
            throws ServiceException
Reloads the configuration of the service. Whether internal state is maintained between reloads is implementation depedent.

Specified by:
reload in interface ReloadableService
Throws:
ServiceException - thrown if there is a problem reloading the service

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
Overrides:
destroy in class BaseService
Throws:
ServiceException - thrown if there is a problem destroying the service


Copyright © 2006-2011 Internet2. All Rights Reserved.