All Packages Class Hierarchy This Package Previous Next Index
Select a BaseCollection in your object's methods only when you want to explicitly create the associated Managed objects as part of the business logic captured by that object. Otherwise, choose a QueryableCollection, KeyedCollection, NamedCollection or ReferenceCollection.
For example, a Trip may create Reservations directly in an associated BC for an "addReservation()" method. The other extreme is that it delegates creation through to an associated "TravelService" and uses only a QueryableCollection instead.
When creating or activating one of its Managed object, a BaseCollection does the following:
1) Create a new instance of the correct class. This is typically done via managedClass.newInstance() and, if the BaseCollection uses delegation, manageable.newInstance() which calls the simple (unparameterized) default constructors. This implies that this constructor be defined. Java automatically provides this if no parameterized constructor is defined. However, if a parameterized constructor is defined, then the simple constructor must be explicitly defined. 2) If the Manageable is Dependent, set its dependent context to be the same as the BaseCollection's dependent context: if (instanceof Dependent) .setDependentContext( ); 3) If the BaseCollection uses delegation (eg, filepobc), then it must ensure that the setSelf() method is called on its Manageable object: if ( instanceof IdentityDelegator) .setSelf( ); 4) Internalize the new object: manageable.internalizeFromStream( ); This method is the time when the manageable should do any initialization.
public abstract Managed createFromCopy(String identifierKey, Manageable copy, String interfaceKey) throws InvalidKeyError, MOFWException
This method associates an Identifier key with the Managed object that is unique within the target BaseCollection. The BaseCollection determines this key by some algorthim. It could create its own key, or it could derive the key from the essential data (ED) of the object.
The key parameter is the key within the target BaseCollection. Because of the KeyedCollection.resolve() rules, this name cannot contain a "/", so the BaseCollection should return an InvalidKeyError. For example, if "abc/xyz" were used as the createFromXXX() identifierKey parameter, then a subsequent resolve() with "abc/xyz" would look for "abc" in the target BaseCollection. 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.
Manageable
object containing the
data used to initialize the created Managed object. After this call the
BaseCollection "owns" the passed in object, and the caller
should forget its reference to the object passed in (use the return
value instead).
The BaseCollection either may use the object as the internally cached version of the Managed object, or may just get the data out of the object and throw the object away. In either case, the object needs to support the externalizeToStream() and interalizeFromStream() methods.
String
that the client wants to be the identifier key for
the newly created Managed object. If the
identifierKey is null, then the BaseCollection determines the
key. For identifierKey of null, there are two cases, usually
implemented by different BaseCollections:
String
that can be
used as a key to lookup the class name in the dependent context.
Managed
object that should be used in
place of the object passed in.
public abstract Managed createFromData(String key, InputEDStream initialData, String interfaceKey) throws InvalidKeyError, EDStreamFormatError, MOFWException
The identifierKey parameter is the key within the target BaseCollection. Because of the KeyedCollection.resolve() rules, this name cannot contain a "/", so the BaseCollection should return an InvalidKeyError. For example, if "abc/xyz" were used as the createFromXXX() identifierKey parameter, then a subsequent resolve() with "abc/xyz" would look for "abc" in the target BaseCollection. 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
that the client wants to be the identifier key for
the newly created Managed object. If the
identifierKey is null, then the BaseCollection determines the
key. For a null identifierKey, there are two cases, usually
implemented by different BaseCollections:
InputEDStream
containing the
initial data for the newly created Managed object.
String
that can be
used as a key to lookup the class name in the dependent context.
Managed
object that should be used in
place of the object passed in.
public abstract Managed createFromDefault(String key, Object creator, String interfaceKey) throws InvalidKeyError, MOFWException
The key parameter is the key within the target BaseCollection. Because of the KeyedCollection.resolve() rules, this name cannot contain a "/", so the BaseCollection should return an InvalidKeyError. For example, if "abc/xyz" were used as the createFromXXX() identifierKey parameter, then a subsequent resolve() with "abc/xyz" would look for "abc" in the target BaseCollection. 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
that the client wants to be the identifier key for
the newly created Managed object. If the
identifierKey is null, then the BaseCollection determines the
key from the creator.
Object
that created this
Managed object.
String
that can be
used as a key to lookup the class name in the dependent context.
Managed
object that should be used in
place of the object passed in.
All Packages Class Hierarchy This Package Previous Next Index