All Packages Class Hierarchy This Package Previous Next Index
Every NamedCollection serves as a more granular name space than if there were only one "root" per address space. Since a binding must be unique within a NamedCollection, it can be used in an application when "set" like behavior is desired.
When mapping OOD models to the Managed Object Framework, choose a NamedCollection whenever a qualified relationship is needed between two objects.
After an object has been bound to a NamedContext using a key,
the same object can be accessed via the KeyedCollection
resolve() method. This object can be either a Java Object object
or a Managed object (Managed extends Object). A Java
Object's reference cannot span outside of its address space
(its reference is not distributed and cannot persistent beyond
the life of its address space). A Managed object's reference
can do both. However long a reference lives, the NamedContext
bind lives and will return the same object that was bound.
In the following example, the boolean "same" is true, because
the e1.setSalary(50,000) changes the value of the same object
referenced from outside aNamedCollection (via e1) and with
aNameCollection.
Because a NamedCollection can be a Managed object, it can be bound in another NamedCollection. Because a Managed object can be bound to multiple NamedCollections, a directed graph is formed that includes all KeyedCollections, including both NamedCollections and BaseCollections. In contrast, because a Managed object can have only one BaseCollection, the subset of this directed graph that includes only BaseCollections forms a pure tree.
public abstract boolean bind(String name, Object target) throws InvalidKeyError
The name parameter is the name within the target NamedCollection. Because of the KeyedCollection.resolve() rules, this name cannot contain a "/", so the NamedCollection should return an InvalidKeyError.
For example, if "abc/xyz" were used as the bind() name parameter, then a subsequent resolve() with "abc/xyz" would look for "abc" in the target NamedCollection. If found, then it would forward the resolve("xyz",...) to the found object. If not found, it would return null. Neither of these is the desired result.
string
to bind to the target.
object
to which the name is bound.
boolean
indicating whether the bind occurred.
False indicates that the name was already bound, while more catastrophic
problems should raise a runtime exception or error (and be documented by
the implementor).
public abstract void unbind(String name) throws InvalidKeyError
string
representing the name
to unbind.
public abstract void rebind(String name, Object object) throws InvalidKeyError
string
representing the name
to which the target is bound or rebound.
object
to which the name is bound
or rebound.
All Packages Class Hierarchy This Package Previous Next Index