Object Manager Service
Contributed by Tim Roberts
n_cst_object_factory - Object Manager Service
The PFC does not address an applications need to share business objects at a global, shared or instance level. The object manager will allow any other object (window, nonvisual, visual, etc.) to share business objects with each other.
An example of how this would be useful:
Lets say that a system uses account information in multiple places and can be updated by multiple things (windows, datawindows, etc.). Being a good OO person, you create an account object to encapsulate all of the account methods. But you may have an implementation problem: what happens if one window needs to know if another window (or any place else) made a modification to your account. Some ugly solutions have been defining the object as global or hardcoding window references or even posting a message for all objects to re-retrieve themselves. Using the object factory, you can have each object create a shared instance of the object that is shared between all of them - one update anywhere is instantly available to all others. You can even have multiple shared account objects by assigning each a unique sharename (say the account number or name).
Some of its capabilities:
- Have a single globally shared object (useful for DDDW caches - insert a row and all shared DDDW automatically updated)
- Have multiple shared versions of a single object (useful for business objects like employee, account, etc.)
- Have a single globally shared objects AND multiple shared object (dont ask me if you would need this feature )
- Can tell if object has already created via the of_getusage counts
Helps minimize memory leakage - automatically destroys all valid objects upon destruction
To enable the object manager services:
To enable the help services - in the open/constructor event of the window, place "of_setobjectmanager(true)". This will create the object managers object, inv_factory in the gnv_app variable
How to create/use a globally shared object:
- u_employee lu_employee
- lu_employee = gnv_app.inv_factory.of_createglobal("u_employee")
How to create/use a shared by name object:
- u_employee lu_employee
- lu_employee = gnv_app.inv_factory.of_createshared("u_employee","Joe Smith")
- nonvisualobject OF_CREATEGLOBAL(string classname): Create a globally shared instance of an object (no share name required)
- nonvisualobject OF_CREATESHARED(string classname, string sharename): Create a shared instance of the object with a sharename
- nonvisualobject OF_CREATEUNIQUE(string classname): Create a unique instance of the object.
- long OF_GETUSAGE(string classname): Get the current usage count for a globally shared object
- long OF_GETUSAGE(string classname, string sharename): Get the current usage count for a shared object
- OF_DESTROYOBJECT(nonvisualobject): Destroys (only if its usage count is 0) the passed object
- OF_SETGLOBALDESTROY(boolean): Sets whether to destroy a globally shared object when usage count falls to zero. "True" destroy it, "False" keep it active
Public Instance Variable
- IL_INVALIDIDX- internal error - array index was not valid
(can be returned from OF_GETUSAGE)
- IL_NOTFOUND- passed object could not be found
(can be returned from OF_DESTROYOBJECT or OF_GETUSAGE calls)
- IL_INVALIDOBJ- passed object is invalid
(can be returned from OF_DESTROYOBJECT)
|Download the||About the extension contributor|
|02/07/1998||Initial Revision||Ver. 1.00|
Interested in contributing material to this web site? Send an email to email@example.com, but don't forget to check the contribution guidelines first.
For information or suggestions about this web site please contact firstname.lastname@example.org
sponsored by Dynamic Technology Group.
The information on this site is provided for advice only and not to be considered a contract or a liability against Dynamic Technology Group.