Previous Table of Contents Next


23.3.9 GenericFactory


   The GenericFactory interface is generic in that it allows the creation of replicated objects (object groups), replicas (members of object groups), and unreplicated objects. It is inherited by the Replication Manager to allow the application to invoke the Replication Manager to create replicated objects. It is implemented by the application’s local factory objects on the various hosts to allow the Replication Manager to invoke the local factory objects of the application to create individual members of an object group and to allow the application to invoke the local factory objects to create individual (unreplicated) objects.

   The GenericFactory interface, inherited by the Replication Manager, is programmed by the vendor of the Fault Tolerance Infrastructure. In contrast, the local factory objects, that implement the GenericFactory interface, are programmed by the application programmer, rather than by the vendor of the Fault Tolerance Infrastructure; they can be regarded in the same light as the Monitorable, Checkpointable, and Updateable interfaces.

   The GenericFactory interface provides create_object() and delete_object() operations for creating and deleting objects and object groups.

   The application program invokes the create_object() operation of the GenericFactory interface inherited by the Replication Manager to create an object group, whether it is application-controlled or infrastructure-controlled, and similarly for the delete_object() operation.

   If the MembershipStyle is MEMB_INF_CTRL, the Replication Manager in turn invokes the create_object() operation of the GenericFactory interface of the appropriate local factories to create the members of the object group and then adds them to the group.

   If the MembershipStyle is MEMB_APP_CTRL, the application or an application-level manager may invoke the create_member() operation of the ObjectGroupManager interface which, in turn, causes the Replication Manager to invoke the create_object() operation of the GenericFactory interface of the local factory, using the given location and criteria, and then to add the member to the group. Alternatively, the application or an application-level manager itself may invoke the create_object() operation of the GenericFactory interface of the local factory to create the object and may then invoke the add_member() operation of the ObjectGroupManager interface to cause the Replication Manager to add the object to the group.

   To create an unreplicated object, the application invokes the create_object() operation of the GenericFactory interface of a specific local factory.

   module FT {

   interface GenericFactory {

   typedef any FactoryCreationId;

   Object create_object(in TypeId type_id,

   in Criteria the_criteria,

   out FactoryCreationId factory_creation_id)

   raises (NoFactory,

   ObjectNotCreated,

   InvalidCriteria,

   InvalidProperty,

   CannotMeetCriteria);

   void delete_object(in FactoryCreationId factory_creation_id) raises (ObjectNotFound); }; };

   There may be multiple different implementations of the GenericFactory interface. Each such factory implementation may create objects of one or more types at one or more locations.

   The create_object() operation takes a type_id as an in parameter. It also takes the_criteria as an in parameter, which allows a user to specify additional criteria, such as initialization values for the object implementation, constraints on the object, or preferred location of the object. The type_id and the_criteria in parameters of the create_object() operation contribute to the genericity and the flexibility of the GenericFactory interface.

   The create_object() operation of the GenericFactory interface, implemented by the application’s local factory objects, accepts a criterion with the reserved name org.omg.ft.ObjectLocation. The value of this criterion instructs the factory where to create the object.

   The create_object() operation of the GenericFactory interface, inherited by the Replication Manager, accepts fault tolerance properties within the_criteria parameter. These fault tolerance properties are contained in a single criterion with the reserved name org.omg.ft.FTProperties. Such properties, if any, override the corresponding fault tolerance properties that are specified as defaults or based on the type of the object. The Replication Manager removes the org.omg.ft.FTProperties criterion from the_criteria passed to it by the application in the create_object() operation and adds the org.omg.ft.ObjectLocation criterion to the criteria before passing the_criteria as a parameter of the create_object() operation to the application’s local factory.

   The create_object() operation of the GenericFactory interface, implemented by the application’s local factory objects, returns an object reference as a result.

   The create_object() operation of the GenericFactory interface, inherited by the Replication Manager, returns an object group reference as a result. If the MembershipStyle is MEMB_APP_CTRL, the Replication Manager creates an object group with no members. Consequently, the returned object group reference contains no TAG_INTERNET_IOP profiles but, instead, contains a TAG_MULTIPLE_COMPONENTS profile with the TAG_FT_GROUP component in it.

   The create_object() operation has an out parameter, factory_creation_id, that is retained by the entity that invoked the method so that it can later invoke the delete_object() operation of the factory using the factory_creation_id as an in parameter, to cause the factory to delete the object. The factory must also retain this identification information so that it can actually delete the object.

   Because the factory retains the identification information that is needed to delete an object that it created, the factory has state. The local factories that create the members of an object group are not replicas of one another. To protect each of these local factories against faults, the application deployer either may replicate each of the factories using the COLD_PASSIVE ReplicationStyle, or may assume that the failure of a local factory at a location (for example, process or host) is equivalent to the failure of that location.

   The application deployer registers a sequence of factories with the Property Manager as the Factories property of the object group, which contains a sequence of factory reference, the_location and the_criteria, which determine where the factory may create an object and the criteria for the object that it is to create.

   If the MembershipStyle is MEMB_INF_CTRL, the Replication Manager uses the locations to choose one or more factories from the Factories sequence and uses the factory references to invoke the create_object() operation of the GenericFactory interface that the factories implement to create the members of the object group.

   If the MembershipStyle is MEMB_APP_CTRL and the application itself invokes the create_member() operation of the ObjectGroupManager interface, citing a location that it selected, the Replication Manager invokes the create_object() operation of the GenericFactory interface implemented by the factory (provided by the Factories property) for that location to create the new member of the object group at that location.

   If the MembershipStyle is MEMB_APP_CTRL and the application invokes the create_object() operation of the GenericFactory interface for a particular factory to create an object, it may then invoke the add_member() operation of the ObjectGroupManager interface to add the object to the group.

   Similarly, to create an unreplicated object, the application may invoke the create_object() operation of the GenericFactory interface of one of its own factories.

   23.3.9.1 Identifiers

   typedef any FactoryCreationId;

   An identifer that is assigned to an object by the factory that creates the object and that is used by the factory to delete the object subsequently.

   23.3.9.2 Operations

   create_object

   This operation of the GenericFactory interface creates an object, using the type_id parameter to determine which type of object to create and the_criteria parameter to determine restrictions on how and where to create the object. The out parameter, factory_creation_id, allows the entity that invoked the factory, and the factory itself, to identify the object for subsequent deletion.

   If the application or the Replication Manager invokes the create_object() operation on the GenericFactory interface, implemented by the application’s local factory object, then it creates a single object.

   If the application invokes the create_object() operation on the GenericFactory interface, inherited by the Replication Manager, then it creates an object group. For an object group with the MEMB_APP_CTRL MembershipStyle, the Replication Manager returns an object group reference containing only the TAG_MULTIPLE_COMPONENTS profile with the TAG_FT_GROUP component in it.

   One of the name-value pairs in the_criteria, passed to the Replication Manager as a parameter of create_object(), may have the name org.omg.ft.FTProperties (which is reserved for specifying fault tolerance properties). The Replication Manager removes that entry of the sequence, adds the org.omg.ft.ObjectLocation entry (which is reserved for specifying the location at which the factory is to create the object), and appends any location-specific criteria (specified in the Factories property for the particular location) before it invokes create_object() operation on the application’s local factory object.

   Object create_object(in TypeId type_id, in Criteria the_criteria, out FactoryCreationId factory_creation_id)

   raises (NoFactory, ObjectNotCreated, InvalidCriteria, InvalidProperty, CannotMeetCriteria);

   Parameters

type_id The repository identifier of the object to be created by the factory.
the_criteria Information passed to the factory, which the factory evaluates before creating the object. Examples of criteria are initialization values, constraints on the object, preferred location of the object, fault tolerance properties for an object group, etc.
factory_creation_id An identifier that allows the factory to delete the object subsequently.

   Return Value

   The reference to the object created by the GenericFactory. When the GenericFactory interface is implemented by the application’s local factory object, the create_object() operation returns an object reference as a result. When the GenericFactory interface is inherited by the Replication Manager, the create_object() operation returns an object group reference as a result.

   Raises

   NoFactory if the object cannot be created. When the GenericFactory interface is implemented by the application’s local factory object, the raised exception indicates that the factory cannot create an individual object of the type_id at the location. When the GenericFactory interface is inherited by the Replication Manager, the raised exception indicates that the Replication Manager cannot create the object group because it cannot find a factory that is capable of constructing a member of the object group of the type_id at the location.

   ObjectNotCreated if the factory cannot create the object.

   InvalidCriteria if the factory does not understand the criteria.

   InvalidProperty if a property passed in as criteria is invalid.

   CannotMeetCriteria if the factory understands the criteria but cannot satisfy it.

   delete_object

   This operation deletes the object with the given identifier. If the application or the Replication Manager invokes this operation on the GenericFactory interface, implemented by the application’s local factory object, then it deletes a single object.

   If the application invokes this operation on the GenericFactory interface, inherited by the Replication Manager, then it deletes an object group. When this operation is invoked on it, the Replication Manager must first remove each of the members from the object group, and delete each of them, before it deletes the object group itself.

   void delete_object(in FactoryCreationId factory_creation_id) raises(ObjectNotFound);

   Parameters


   Raises

   ObjectNotFound if the object cannot be found.