public class PeriodicRefresherImpl extends AbstractLoggableComponent implements PeriodicRefresher, Runnable, Closeable
PeriodicRefresher
.Modifier and Type | Field and Description |
---|---|
private boolean |
active |
private static int |
DEFAULT_REFRESH_DELAY_IN_SECONDS
The default
refresh-delay . |
private Executor |
executor |
private static Integer |
MIN_DELAY
The minimum value allowed for
refreshDelayInSeconds . |
private Set<Refreshable> |
refreshableSet
The
Set of Refreshable s. |
private int |
refreshDelayInSeconds |
private Thread |
refreshThread |
private boolean |
shutdown |
Constructor and Description |
---|
PeriodicRefresherImpl()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addRefreshable(Refreshable refreshable)
This method will register the given
refreshable so it will be refreshed
periodically. |
void |
close() |
protected void |
doInitialize()
This method performs the actual
initialization . |
protected Executor |
getExecutor() |
int |
getRefreshDelaySeconds() |
protected String |
getThreadName()
This method gets the thread-name.
|
void |
removeRefreshable(Refreshable refreshable)
This method removes the given
refreshable from this PeriodicRefresher . |
void |
run() |
void |
setExecutor(Executor executor) |
void |
setRefreshDelayInSeconds(int refreshDelayInSeconds)
This method sets the refresh-delay in seconds.
|
void |
startup()
This method will initialize and startup this refresher.
|
createLogger, getLogger
doInitialized, getInitializationState, initialize
private static final int DEFAULT_REFRESH_DELAY_IN_SECONDS
refresh-delay
.private static final Integer MIN_DELAY
refreshDelayInSeconds
.private Executor executor
private int refreshDelayInSeconds
private boolean active
private volatile boolean shutdown
private Set<Refreshable> refreshableSet
Set
of Refreshable
s.private Thread refreshThread
protected void doInitialize()
AbstractComponent
initialization
. It is called when AbstractComponent.initialize()
is
invoked for the first time. super.
AbstractComponent.doInitialize()
.doInitialize
in class AbstractLoggableComponent
public void startup()
closed
.
AbstractComponent.initialize()
so the startup only happens if
explicitly required and not accidently because this component if found and managed by some container.public void addRefreshable(Refreshable refreshable)
PeriodicRefresher
refreshable
so it will be refreshed
periodically. Refreshable
is added here.
Refreshable
if this is really desired and its
implementation of Refreshable.refresh()
is fast or only takes performance if something that rarely changes
has been modified. Refreshable
has to have a proper implementation of Object.equals(Object)
and
Object.hashCode()
as it may be stored in a Collection
.addRefreshable
in interface PeriodicRefresher
refreshable
- is the Refreshable
to register and refresh periodically.public void removeRefreshable(Refreshable refreshable)
PeriodicRefresher
refreshable
from this PeriodicRefresher
. This will typically happen
when the according Refreshable
shall be closed
or disposed. searchEngine
has never been registered
, this method has
no effect.removeRefreshable
in interface PeriodicRefresher
refreshable
- is the Refreshable
to de-register.@PreDestroy public void close()
close
in interface Closeable
close
in interface AutoCloseable
protected String getThreadName()
protected Executor getExecutor()
@Inject public void setExecutor(Executor executor)
executor
- is the executor to setpublic int getRefreshDelaySeconds()
public void setRefreshDelayInSeconds(int refreshDelayInSeconds)
refreshDelayInSeconds
- is the refreshDelayInSeconds to setCopyright © 2001–2016 mmm-Team. All rights reserved.