T
- The sort of service this implements.public abstract class AbstractReloadableService<T> extends AbstractIdentifiableInitializableComponent implements ReloadableService<T>, UnmodifiableComponent
ReloadableService
. This base class will use a background thread that will perform a periodic
check, via shouldReload()
, and, if required, invoke the services reload()
method. Modifier and Type | Class and Description |
---|---|
protected class |
AbstractReloadableService.ServiceReloadTask
A watcher that determines if a service should be reloaded and does so as appropriate.
|
Constructor and Description |
---|
AbstractReloadableService()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
doDestroy()
Performs component specific destruction logic.
|
protected void |
doInitialize()
This method checks to ensure that the component ID is not null.
|
protected void |
doReload()
Performs the actual reload.
|
org.joda.time.DateTime |
getLastReloadAttemptInstant()
Gets the time when the service last attempted to reload.
|
org.joda.time.DateTime |
getLastSuccessfulReloadInstant()
Gets the time when the service was last successfully reloaded.
|
protected String |
getLogPrefix()
Return a string which is to be prepended to all log messages.
|
long |
getReloadCheckDelay()
Gets the number of milliseconds between one reload check and another.
|
Throwable |
getReloadFailureCause()
Gets the reason the last reload failed.
|
Timer |
getReloadTaskTimer()
Gets the timer used to schedule configuration reload tasks.
|
boolean |
isFailFast()
Do we fail fast?
|
void |
reload()
Reloads the configuration of the service.
|
void |
setFailFast(boolean value)
Sets whether we fail fast.
|
void |
setReloadCheckDelay(long delay)
Sets the number of milliseconds between one reload check and another.
|
void |
setReloadTaskTimer(Timer timer)
Sets the timer used to schedule configuration reload tasks.
|
protected abstract boolean |
shouldReload()
Called by the
AbstractReloadableService.ServiceReloadTask to determine if the service should be reloaded. |
setId
getId
destroy, initialize, isDestroyed, isInitialized
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getServiceableComponent
initialize, isInitialized
getId
public long getReloadCheckDelay()
Default value: 0
public void setReloadCheckDelay(@Duration long delay)
delay
- number of milliseconds between one reload check and another@Nullable public Timer getReloadTaskTimer()
public void setReloadTaskTimer(@Nullable Timer timer)
timer
- timer used to schedule configuration reload tasks@Nullable public org.joda.time.DateTime getLastReloadAttemptInstant()
ReloadableService.getLastSuccessfulReloadInstant()
.getLastReloadAttemptInstant
in interface ReloadableService<T>
@Nullable public org.joda.time.DateTime getLastSuccessfulReloadInstant()
getLastSuccessfulReloadInstant
in interface ReloadableService<T>
@Nullable public Throwable getReloadFailureCause()
getReloadFailureCause
in interface ReloadableService<T>
public boolean isFailFast()
public void setFailFast(boolean value)
value
- what to set.protected void doInitialize() throws ComponentInitializationException
doInitialize
in class AbstractIdentifiedInitializableComponent
ComponentInitializationException
- thrown if there is a problem initializing the componentprotected void doDestroy()
doDestroy
in class AbstractInitializableComponent
public final void reload()
reload
in interface ReloadableService<T>
protected abstract boolean shouldReload()
AbstractReloadableService.ServiceReloadTask
to determine if the service should be reloaded.
No lock is held when this method is called, so any locking needed should be handled internally.
protected void doReload()
No lock is held when this method is called, so any locking needed should be handled internally.
ServiceException
- thrown if there is a problem reloading the serviceCopyright © 2016 JBoss by Red Hat. All rights reserved.