Procedure for sharing data

The general procedure for sharing data is:

  1. Create or retrieve references to collections – the component must first create a collection before creating a shared variable in that collection. Creating a collection automatically retrieves a reference to the new collection. If the collection already exists, the component must retrieve a reference to the collection before creating a shared variable.

  2. Lock collections – before creating a shared variable or reading and updating shared variables, lock the collection. Locking a collection ensures that the integrity of a shared variable will be maintained when the shared variable is read and updated by the same method multiple times. The component does not have to lock a collection if you are executing only one read or update on a shared variable.

  3. Create or retrieve references to shared variables – the component must first create a shared variable before reading or updating the shared variable. Creating a shared variable automatically retrieves a reference to the new shared variable. If the shared variable already exists, the component must retrieve a reference to the shared variable before reading or updating a shared variable.

  4. Read and update shared variables – after creating or retrieving a reference to a shared variable, the component can read and update the shared variable.

  5. Unlock collections – after reading and updating all shared variables in a collection, unlock the collection. Unlocking a collection immediately after the component instance has completed all operations on a shared variable allows other component instances to access the shared variable right away.

  6. Release shared variable and collection references – after reading and updating shared variables, release the reference to the shared variable. After all operations on shared variables in a collection have been completed, release the reference to the collection. Component objects use memory efficiently by releasing references immediately after the component object has completed operations on a shared variable or collection.

You can also list all collection names on the server by calling the JagGetCollectionList routine. For more information see “List all collections”.