Accessing JADE System Objects

You can obtain the OIDs of the JADE system objects by using the GetSystemVariables method of the JoobContext instance, which returns an instance of the SystemVariables class. The properties of a SystemVariables object are the OIDs of the JADE system objects. They are listed in the following table.

JADE System Object Type Description
App

Application subclass (which must be exposed)

The current transient application instance. This is often used to store application‑specific data.
Currentschema

JadeSoftware.Joob.MetaSchema.Schema

Current user-defined schema.
Global Global subclass (which must be exposed)

The persistent object for a schema, which is shared by all applications running from that schema.

This is often used to exchange information between applications or to retain information when an application closes.

Node

JadeSoftware.Joob.Management.JoobNode

The workstation that hosts the execution of the current process. One node object exists for each logical workstation connected to the server node workstation. There is one fixed server node and none or many client nodes. A node represents a workstation that runs a number of processes.
Process

JadeSoftware.Joob.Management.JoobSession

The current thread in a workstation executing the current method.
RootSchema

JadeSoftware.Joob.MetaSchema.Schema

The JADE RootSchema.
System

JadeSoftware.Joob.Management.JoobSystem

The JADE architectural environment consisting of a group of nodes to which the current node belongs.

You must expose the classes of the App and Global system objects for the types to be available to your C# code.

See also "JoobContexts, Sessions, and JoobConnections", in Chapter 2, for details about the C# wrappers for the JADE Object Manager Process, Node, and System classes.

The following code would obtain a reference to the Node object.

JoobContext context = JoobContext.CurrentContext;
SystemVariables sv = context.GetSystemVariables();
ObjectId nodeOid = sv.Node;
JadeSoftware.Joob.Management.JoobNode
    node = context.FindInstance<JadeSoftware.Joob.Management.JoobNode>(nodeOid);

A typical use of the App object is to store a reference to a root object, which is a singleton persistent object that contains collections of all objects in a class. For example, in a banking application, the root object would represent the bank itself and would have a collection of all of the customers of the bank. The following code would obtain a reference to the App object.

JoobContext context = JoobContext.CurrentContext;
SystemVariables sv = context.GetSystemVariables();
ObjectId appOid = sv.App;
ErewhonInvestmentsModelApp
    app = context.FindInstance<ErewhonInvestmentsModelApp>(appOid);

Transient App objects are created when a connection to JADE is first established and the pool of processes is created (typically when an application first creates a JoobContext instance). An App object is associated with each process in the pool. Each App object exists for the lifetime of the process and is retained even when a process is released back to the pool (which happens when the associated JoobContext object is disposed of).

Because the App object for each process is retained, it is available when a JoobContext instance is next created and associated with that process. However, the associated process may be any of the processes in the pool.

If an initialize method is defined for the database application specified in the connection string, it is invoked when each App object is created (typically when the first connection to JADE is established). Similarly, if a finalize method is defined, it is invoked when each App object is deleted (typically when the .NET application terminates).