The Navigation Path Registry
Original Publication Date: 2005-Dec-15
Included in the Prior Art Database: 2005-Dec-15
The present publication relates to the field of object oriented programming and discloses a method for notifying listeners of model changes in an object oriented environment.
The Navigation Path Registry
The present publication discloses a method for:
1. registering Navigation Paths between model objects (a Navigation Path is a list of ordered reference steps starting from the object type to the object feature).
2. notifying the set of objects interested of a changed feature of an object according to: - the changed (interesting) feature in the object - the set of navigation paths that point to this interesting changed feature.
a. Problem: With reference to the following model:
E m ployee
D epartm ent
* 1 1
+ c e rtific a tio ns
C e rtific a tio n
is Certified : boolean noO fC erts : int
If we assumme that there is a business rule for this model telling that the organization is certified when the total number of employee certifications is 10 or more, the problem is that the "Organization" object needs to be notified when a new "Certification" to "Employee" is added in order to increment the "noOfCerts" counter. When the counter reaches 10, the "Organization" sets its "isCertified" attribute to "true".
b. Known Solutions:
1. The "Organization" object registers a listener on all "Department" objects. When a new "Employee" is added to a "Department", the "Organization" knows it and registers another listener on the newly added "Employee".According to the well-known Listener pattern, the object subject to change: - declares an interface (e.g. Listener), - accepts to register objects that implement that interface, and - when the object subject to change changes, calls back the registered listeners to notify them the change.
The problem is that there are many listeners and the "Organization" will be notified of
any change (insteed of being notified of new "Certifications" only).
2. Every change must be notified to the whole model and the performance is not optimized.
c. Solution :
1. Meta Model,
2. Reference Registry,
3. Path Registry,
4. Interested Interface.
The "Reference Registry" is a singleton that registers a listener on all model objects. When a model object refers to another object, this registry keeps a record for this reference. A client (an object that is interested in a specific reference change) must implement the "Interested Interface" and must register itself in the "Path Registry" in conjunction with the "Meta Model" reference object and the navigation path to that reference. This navigation path is a string with a specific format.
The "Path Registry" is also a singleton that can be called upon reception of a model change notification or upon reception of a batch of notifications, to callback (through the "Interested Interface") the registered clients interested in a specific model change. The "Path Registery" gives to the clients the objects that it gets by navigating the registered path backwards.
1. No need to manage several listeners. Onl...