Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sharing Object Reference among COM Objects
Message
 
 
À
16/01/2002 22:06:56
Joel Leach
Memorial Business Systems, Inc.
Tennessie, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00605886
Message ID:
00606043
Vues:
29
>Suppose I have several business COM objects that use the same class to perform data services. Is there a way to create the object once and share it among the various business objects? I could set a property on the business object after I instantiate it, but then it wouldn't be stateless. I really don't want to pass the reference in as a parameter to every method. Does anyone do this, or is it typical to create a new data object for each business object? That seems like a waste.
>
>Thanks.

Joel,
What would be the problem of having code in the Init set the data services object for you? The Init could make a call out to a data services manager object that gives it an existing data services object for its use. It then sets its own internal property. The internal property would exist for the life of your method call and it could set the property to NULL in the Destroy.

This raises a question for me. How stateless do you want your objects to be? If you instantiate a COM+ object and don't make any calls to it, the only method to fire in the object is the Init (and any methods the Init calls). The object is active and has state. If in your methods, you have code to call either SetAbort or SetComplete then the object's state goes away. The next time you initiate a call, the object will have to be reinstantiated in the COM+ server.

This leads to the following scenario:

1. Create object in application (Init fires)
2. Init calls method to set data services object (method does not have SetAbort/SetComplete)
3. Call method that requires the use of data services object and method has SetAbort/SetComplete in it

Does this work for you?
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform