Project Wonder 5.0

er.extensions.eof
Class ERXEnterpriseObjectChangeListener<T extends com.webobjects.eocontrol.EOEnterpriseObject>

java.lang.Object
  extended by er.extensions.eof.ERXEnterpriseObjectChangeListener<T>

public abstract class ERXEnterpriseObjectChangeListener<T extends com.webobjects.eocontrol.EOEnterpriseObject>
extends java.lang.Object

Listens to EOEditingContextDidSaveChanges notifications to track changes on a given entity and calls the entitiesChanged method when the entity changes.

Author:
mschrag (mostly taken from ERXEnterpriseObjectCache, though)

Field Summary
static java.lang.String ClearCacheNotification
           
 
Constructor Summary
ERXEnterpriseObjectChangeListener(java.lang.Class c, boolean trackAllChanges, boolean deep)
          Constructs an ERXEnterpriseChangeListener.
ERXEnterpriseObjectChangeListener(java.lang.String entityName, boolean trackAllChanges, boolean deep)
          Constructs an ERXEnterpriseChangeListener.
 
Method Summary
abstract  void clearCache()
          Called when a clear cache request has been received.
 void clearCache(com.webobjects.foundation.NSNotification n)
          Handler for the clearCaches notification.
 void editingContextDidSaveChanges(com.webobjects.foundation.NSNotification n)
          Handler for the editingContextDidSaveChanges notification.
abstract  void entitiesChanged(com.webobjects.foundation.NSArray<T> entitiesInserted, com.webobjects.foundation.NSArray<T> entitiesUpdated, com.webobjects.foundation.NSArray<T> entitiesDeleted)
          Called when the entity being listened to changes.
protected  java.lang.String entityName()
          Returns the name of the entity this cache is watching.
protected  boolean isRelevant(com.webobjects.eocontrol.EOEditingContext editingContext, java.lang.String changedEntityName)
          Returns true if the changed entity name matches the watched entity name, or if this change listener is "deep," if the changed entity name is a
protected  void registerForNotifications()
           
protected  com.webobjects.foundation.NSArray<T> relevantChanges(com.webobjects.eocontrol.EOEditingContext editingContext, com.webobjects.foundation.NSDictionary dict, java.lang.String key)
          Helper to check if an array of EOs contains the handled entity or its subclasses (if deep).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ClearCacheNotification

public static java.lang.String ClearCacheNotification
Constructor Detail

ERXEnterpriseObjectChangeListener

public ERXEnterpriseObjectChangeListener(java.lang.Class c,
                                         boolean trackAllChanges,
                                         boolean deep)
Constructs an ERXEnterpriseChangeListener.

Parameters:
c - the class name of the entity to watch for changes
trackAllChanges - if true, entitiesChanged will pass the array of all changed EO's (slightly slower)
deep - if true, subentities of the given entity will be considered relevent to this change listener

ERXEnterpriseObjectChangeListener

public ERXEnterpriseObjectChangeListener(java.lang.String entityName,
                                         boolean trackAllChanges,
                                         boolean deep)
Constructs an ERXEnterpriseChangeListener.

Parameters:
entityName - the entity name to watch for changes
trackAllChanges - if true, entitiesChanged will pass the array of all changed EO's (slightly slower)
deep - if true, subentities of the given entity will be considered relevent to this change listener
Method Detail

registerForNotifications

protected void registerForNotifications()

relevantChanges

protected com.webobjects.foundation.NSArray<T> relevantChanges(com.webobjects.eocontrol.EOEditingContext editingContext,
                                                               com.webobjects.foundation.NSDictionary dict,
                                                               java.lang.String key)
Helper to check if an array of EOs contains the handled entity or its subclasses (if deep).

Parameters:
editingContext - the editingContext containing the changes
dict - the notification's userInfo dictionary
key - the inserted/updated/deleted key
Returns:
an array of changed EOs (if not trackAllChanges, this will only ever return at most one)

isRelevant

protected boolean isRelevant(com.webobjects.eocontrol.EOEditingContext editingContext,
                             java.lang.String changedEntityName)
Returns true if the changed entity name matches the watched entity name, or if this change listener is "deep," if the changed entity name is a

Parameters:
editingContext - the editing context containing the changes
changedEntityName - the name of the changed entity
Returns:
true if this change is relevant to this change listener

editingContextDidSaveChanges

public void editingContextDidSaveChanges(com.webobjects.foundation.NSNotification n)
Handler for the editingContextDidSaveChanges notification. Calls entitiesChanged if an object of the given entity (or its subentities) were changed.

Parameters:
n -

clearCache

public void clearCache(com.webobjects.foundation.NSNotification n)
Handler for the clearCaches notification. Calls reset if n.object is the entity name.

Parameters:
n -

entityName

protected java.lang.String entityName()
Returns the name of the entity this cache is watching.

Returns:
the name of the entity this cache is watching

entitiesChanged

public abstract void entitiesChanged(com.webobjects.foundation.NSArray<T> entitiesInserted,
                                     com.webobjects.foundation.NSArray<T> entitiesUpdated,
                                     com.webobjects.foundation.NSArray<T> entitiesDeleted)
Called when the entity being listened to changes. If trackAllChanges is false, all of the arrays will be null.

Parameters:
entitiesInserted - entities of this type were inserted, if null, it was not checked
entitiesUpdated - entities of this type were updated, if null, it was not checked
entitiesDeleted - entities of this type were deleted, if null, it was not checked

clearCache

public abstract void clearCache()
Called when a clear cache request has been received.


Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.