|
Project Wonder 5.0.0.8795 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecter.extensions.eof.ERXEnterpriseObjectCache<T>
T - public class ERXEnterpriseObjectCache<T extends EOEnterpriseObject>
Caches one entity by a given key. Listens to
EOEditingContextDidSaveChanges notifications to track changes.
Typically you'd have an "identifier" property and you'd fetch values by:
You can supply a timeout after which the cache is to get cleared and all the objects refetched. Note
that this implementation only caches the global IDs, not the actual data.
ERXEnterpriseObjectCache<HelpText> helpTextCache = new ERXEnterpriseObjectCache<HelpText>("HelpText", "pageConfiguration");
...
HelpText helpText = helpTextCache.objectForKey(ec, "ListHelpText");
| Field Summary | |
|---|---|
static String |
ClearCachesNotification
|
protected static EOGlobalID |
NO_GID_MARKER
|
| Constructor Summary | |
|---|---|
ERXEnterpriseObjectCache(Class c,
String keyPath)
Creates the cache for the given entity name and the given keypath. |
|
ERXEnterpriseObjectCache(String entityName,
String keyPath)
Creates the cache for the given entity name and the given keypath. |
|
ERXEnterpriseObjectCache(String entityName,
String keyPath,
EOQualifier qualifier,
long timeout)
Creates the cache for the given entity, keypath and timeout value in milliseconds. |
|
ERXEnterpriseObjectCache(String entityName,
String keyPath,
long timeout)
Creates the cache for the given entity, keypath and timeout value in milliseconds. |
|
| Method Summary | |
|---|---|
void |
addObject(T eo)
Add an object to the cache. |
void |
addObjectForKey(T eo,
Object key)
Add an object to the cache with the given key. |
protected ERXExpiringCache<Object,er.extensions.eof.ERXEnterpriseObjectCache.EORecord<T>> |
cache()
Returns the backing cache. |
void |
clearCaches(NSNotification n)
Handler for the clearCaches notification. |
protected er.extensions.eof.ERXEnterpriseObjectCache.EORecord<T> |
createRecord(EOGlobalID gid,
T eo)
|
protected ERXEC |
editingContext()
|
void |
editingContextDidSaveChanges(NSNotification n)
Handler for the editingContextDidSaveChanges notification. |
protected String |
entityName()
|
protected NSArray<T> |
fetchObjectsForKey(EOEditingContext editingContext,
Object key)
Actually performs a fetch for the given key. |
protected EOQualifier |
fetchObjectsQualifier(Object key)
Returns the qualifier to use during for fetching. |
protected void |
handleUnsuccessfullQueryForKey(Object key)
Called when a query hasn't found an entry in the cache. |
protected NSArray<T> |
initialObjects(EOEditingContext ec)
Returns the objects to cache initially. |
protected String |
keyPath()
The key path which should get used for the key of the cache. |
T |
objectForKey(EOEditingContext ec,
Object key)
Retrieves an EO that matches the given key or null if no match is in the cache. |
T |
objectForKey(EOEditingContext ec,
Object key,
boolean handleUnsuccessfulQueryForKey)
Retrieves an EO that matches the given key or null if no match is in the cache. |
EOQualifier |
qualifier()
Returns the additional qualifier for this cache. |
void |
removeObject(T eo)
|
void |
removeObjectForKey(T eo,
Object key)
|
void |
reset()
Resets the cache by clearing the internal map. |
void |
setFetchInitialValues(boolean fetchInitialValues)
Sets whether or not the initial values should be fetched into this cache or whether or should lazy load. |
void |
setResetOnChange(boolean resetOnChange)
Sets whether or not the cache is cleared when any change occurs. |
void |
setRetainObjects(boolean retainObjects)
Sets whether or not the cached EO's themselves are retained versus just their GID's. |
void |
setReuseEditingContext(boolean reuseEditingContext)
Sets whether or not the editing context for this cache is reused for multiple requests. |
void |
start()
|
void |
stop()
|
void |
updateObject(T eo)
|
void |
updateObjectForKey(T eo,
Object key)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static String ClearCachesNotification
protected static final EOGlobalID NO_GID_MARKER
| Constructor Detail |
|---|
public ERXEnterpriseObjectCache(String entityName,
String keyPath)
entityName - keyPath -
public ERXEnterpriseObjectCache(Class c,
String keyPath)
c - keyPath -
public ERXEnterpriseObjectCache(String entityName,
String keyPath,
long timeout)
entityName - keyPath - timeout -
public ERXEnterpriseObjectCache(String entityName,
String keyPath,
EOQualifier qualifier,
long timeout)
entityName - keyPath - qualifier - timeout - | Method Detail |
|---|
public void start()
public void stop()
protected ERXEC editingContext()
public void editingContextDidSaveChanges(NSNotification n)
n - public void clearCaches(NSNotification n)
n - protected String entityName()
protected String keyPath()
protected ERXExpiringCache<Object,er.extensions.eof.ERXEnterpriseObjectCache.EORecord<T>> cache()
protected er.extensions.eof.ERXEnterpriseObjectCache.EORecord<T> createRecord(EOGlobalID gid,
T eo)
protected NSArray<T> initialObjects(EOEditingContext ec)
ec -
public void addObject(T eo)
eo -
public void addObjectForKey(T eo,
Object key)
eo - key - public void removeObject(T eo)
public void removeObjectForKey(T eo,
Object key)
public void updateObject(T eo)
public void updateObjectForKey(T eo,
Object key)
public T objectForKey(EOEditingContext ec,
Object key)
ec - editing context to get the object intokey - key value under which the object is registered
public T objectForKey(EOEditingContext ec,
Object key,
boolean handleUnsuccessfulQueryForKey)
ec - editing context to get the object intokey - key value under which the object is registeredhandleUnsuccessfulQueryForKey - if false, a cache miss returns null rather than fetching
protected void handleUnsuccessfullQueryForKey(Object key)
addObject(EOEnterpriseObject) on it.
key -
protected NSArray<T> fetchObjectsForKey(EOEditingContext editingContext,
Object key)
editingContext - the editingcontext to fetch inkey - the key to fetch with
public EOQualifier qualifier()
protected EOQualifier fetchObjectsQualifier(Object key)
key - the key to fetch
public void reset()
public void setFetchInitialValues(boolean fetchInitialValues)
fetchInitialValues - if true, the initial values are fetched into the cachepublic void setReuseEditingContext(boolean reuseEditingContext)
reuseEditingContext - whether or not the editing context for this cache is reused for multiple requestspublic void setRetainObjects(boolean retainObjects)
retainObjects - if true, the EO's are retainedpublic void setResetOnChange(boolean resetOnChange)
resetOnChange - if true, the cache will clear on changes; if false, the cache will update on changes
|
Last updated: Fri, Jan 9, 2009 04:35 AM EST | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||