T - public class RefreshableThreadObject<T extends Creatable<T>> extends Object
LifeCycle mechanism for configuration refreshes, and
implements Creatable (for use in destroy, etc).In addition to the Thread instance semantics, it compares when the object was created versus the last "refresh(env)" call when getting, for the thread, and if necessary to replace the created object, destroying the previous.
In most cases, it's better to use the new "Pool" mechanism, as it deals with gaining and returning resources on an as needed basis. This, however, remains in the cases where specific Objects need to be retained to specific Threads.
There is no way to do this kind of specialized behavior in ThreadLocal.
| Constructor and Description |
|---|
RefreshableThreadObject(Class<T> clss)
The passed in class must implement the constructor
|
| Modifier and Type | Method and Description |
|---|---|
T |
get(Env env)
Get the "T" class from the current thread
|
void |
refresh(Env env)
Mark the timestamp of refreshed.
|
void |
remove(Env env)
Remove the object from the Thread instances
|
public RefreshableThreadObject(Class<T> clss) throws APIException
public MyClass(Env env) {
...
}
clss - APIExceptionpublic T get(Env env) throws APIException
env - APIExceptionpublic void refresh(Env env)
env - public void remove(Env env)
env - Copyright © 2017. All rights reserved.