|
Project Wonder 5.0 | |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecter.extensions.eof.ERXEnterpriseObjectArrayCache<T>
public class ERXEnterpriseObjectArrayCache<T extends com.webobjects.eocontrol.EOEnterpriseObject>
Caches objects of one entity by a given key. Listens to
EOEditingContextDidSaveChanges notifications to track changes.
Typically 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.
ERXEnterpriseObjectArrayCache<HelpText> helpTextCache = new ERXEnterpriseObjectArrayCache<HelpText>("HelpText") {
protected void handleUnsuccessfullQueryForKey(Object key) {
NSArray helpTexts = ... fetch from somewhere
setObjectsForKey(helpTexts, key);
}
};
...
NSArray<HelpText> helpTexts = helpTextCache.objectsForKey(ec, "AllTexts");
...
Nested Class Summary | |
---|---|
static class |
ERXEnterpriseObjectArrayCache.NotFoundArray
|
Field Summary | |
---|---|
protected static com.webobjects.foundation.NSArray |
NOT_FOUND_MARKER
|
Constructor Summary | |
---|---|
ERXEnterpriseObjectArrayCache(java.lang.Class c)
Creates the cache for the given entity name and the given keypath. |
|
ERXEnterpriseObjectArrayCache(java.lang.String entityName)
Creates the cache for the given entity name and the given keypath. |
|
ERXEnterpriseObjectArrayCache(java.lang.String entityName,
long timeout)
Creates the cache for the given entity, keypath and timeout value in milliseconds. |
Method Summary | |
---|---|
protected com.webobjects.foundation.NSArray<com.webobjects.eocontrol.EOGlobalID> |
cachedArrayForKey(java.lang.Object key)
|
void |
clearCaches(com.webobjects.foundation.NSNotification n)
Handler for the clearCaches notification. |
void |
editingContextDidSaveChanges(com.webobjects.foundation.NSNotification n)
Handler for the editingContextDidSaveChanges notification. |
protected java.lang.String |
entityName()
|
protected static java.lang.String |
entityNameForClass(java.lang.Class c)
|
protected long |
fetchTime()
|
protected void |
handleUnsuccessfullQueryForKey(java.lang.Object key)
Called when a query hasn't found an entry in the cache. |
protected boolean |
isNotFound(com.webobjects.foundation.NSArray<com.webobjects.eocontrol.EOGlobalID> gids)
|
com.webobjects.foundation.NSArray<T> |
objectsForKey(com.webobjects.eocontrol.EOEditingContext ec,
java.lang.Object key)
Retrieves a list of EOs that matches the given key or null if no match is in the cache. |
protected void |
registerForNotifications()
|
void |
reset()
Resets the cache by clearing the internal map. |
protected void |
setCachedArrayForKey(com.webobjects.foundation.NSArray<com.webobjects.eocontrol.EOGlobalID> gids,
java.lang.Object key)
|
void |
setObjectsForKey(com.webobjects.foundation.NSArray<? extends com.webobjects.eocontrol.EOEnterpriseObject> bugs,
java.lang.Object key)
Add a list of objects to the cache with the given key. |
protected long |
timeout()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final com.webobjects.foundation.NSArray NOT_FOUND_MARKER
Constructor Detail |
---|
public ERXEnterpriseObjectArrayCache(java.lang.String entityName)
entityName
- public ERXEnterpriseObjectArrayCache(java.lang.Class c)
public ERXEnterpriseObjectArrayCache(java.lang.String entityName, long timeout)
entityName
- timeout
- Method Detail |
---|
protected static java.lang.String entityNameForClass(java.lang.Class c)
protected void registerForNotifications()
public void editingContextDidSaveChanges(com.webobjects.foundation.NSNotification n)
n
- public void clearCaches(com.webobjects.foundation.NSNotification n)
n
- protected java.lang.String entityName()
public void setObjectsForKey(com.webobjects.foundation.NSArray<? extends com.webobjects.eocontrol.EOEnterpriseObject> bugs, java.lang.Object key)
bugs
- array of objectsprotected void setCachedArrayForKey(com.webobjects.foundation.NSArray<com.webobjects.eocontrol.EOGlobalID> gids, java.lang.Object key)
protected com.webobjects.foundation.NSArray<com.webobjects.eocontrol.EOGlobalID> cachedArrayForKey(java.lang.Object key)
public com.webobjects.foundation.NSArray<T> objectsForKey(com.webobjects.eocontrol.EOEditingContext ec, java.lang.Object key)
ec
- editing context to get the objects intokey
- key value under which the objects are registeredprotected boolean isNotFound(com.webobjects.foundation.NSArray<com.webobjects.eocontrol.EOGlobalID> gids)
protected void handleUnsuccessfullQueryForKey(java.lang.Object key)
setObjectsForKey(NSArray, Object)
on it.
key
- public void reset()
protected long timeout()
protected long fetchTime()
|
Last updated: Tue, Feb 21, 2017 05:45 PM CET | |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |