|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jfw.util.GenericCache
public abstract class GenericCache
Extended by classes used for cache data.
Is an observer of UpdateObservable
.
The sub classes must implement the singleton pattern.
Example of sub class
public final class MyCache extends GenericCache
{
//Used for logging
private static String className = "package.MyCache";
//The only instance of the class
private static MyCache instance = new MyCache();
//Cached data container
private Object data;
private MyCache()
{
super();
}
public static MyCache getInstance()
{
return instance;
}
protected void initialize() throws Exception
{
//get the data to cache and save them in attribute data
...
data = ...;
}
public Object getData(Object object) throws Exception
{
return data;
}
}
Field Summary | |
---|---|
protected boolean |
isObserver
Set to true when this instance set as observer. |
protected UpdateObservable |
updateObservable
The observable object. |
Constructor Summary | |
---|---|
protected |
GenericCache()
Sub class constructor must call using super() this constructor at first. |
Method Summary | |
---|---|
abstract java.lang.Object |
getData(java.lang.Object object)
Return cached data. |
protected abstract void |
initialize()
Read from a source the data to cache. |
protected void |
update()
Call method initialize() . |
void |
update(java.util.Observable observable,
java.lang.Object obj)
Called by the Observable object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected UpdateObservable updateObservable
protected boolean isObserver
Constructor Detail |
---|
protected GenericCache()
Method Detail |
---|
protected abstract void initialize() throws java.lang.Exception
update()
.
java.lang.Exception
public abstract java.lang.Object getData(java.lang.Object object) throws java.lang.Exception
object
- input object to use or null.
java.lang.Exception
protected final void update()
initialize()
.
public void update(java.util.Observable observable, java.lang.Object obj)
update()
.
update
in interface java.util.Observer
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |