Creating the Requestor's Object

For a requestor to interact with the Time-based Alarm, we need a representation of the provider. Here we create a DOFObject to represent the provider.

DOF Objects

Both providers and requestors need an instance of DOFObject to initiate or process operations involved with interface functionality. Instantiating the DOFObject class requires that you first have an instance of two other classes: DOFSystem and DOFObjectID.

Obtaining DOFSystem Instances

To create a DOFObject, you must use a method of DOFSystem, so you need an instance of DOFSystem on which to call the method. In general, creating DOFSystem instances is a concern for system developers and it is assumed that a system developer will pass it to you or will have created a class with a method in it for creating the system. If you want to use the code sample from the training, there is a DOF abstraction class that has a method in it for creating a system that you can use in your project to get a DOFSystem instance. If you copy DOFAbstraction.java into your project and instantiate this class in an initialization routine, you can use the DOFSystem createSystem(String) method to get an instance of DOFSystem. The input parameter represents a name for the system and can be anything you want; however, if you create multiple systems, you must use unique names.

Creating DOFObjectID Instances

The DOFObjectID class in the DOF libraries is used to create unique object identifiers (OIDs) for any type of object that needs one. In the simple scenario of a single provider and a single requestor, the provider is identified by the OID. Additionally, note the following:

In more advanced scenarios, each requestor might need its own OID. For example, many services are essentially provider applications capable of creating multiple DOFObjects that provide the same functionality for multiple requestors, while maintaining separate state or database information for each individual requestor.

Creating DOFObject Instances

The DOFObject class essentially represents a provider on the network. Even in requestor code, it is conceptualized as the provider you want to talk to. In the DOF Object Model, the DOFObject instance is the DOF object. The methods that enable you to initiate and process operations are contained in this class. In addition, the DOFObject is used by the internal library for addressing and routing. The create methods for DOFObject require an instance of DOFObjectID.

How It Works

Before we can create a requestor and a provider, you need to understand how objects in the OpenDOF library are created. The objects are created using the DOFObject class, and they must be created from DOFSystem.

The DOFSystem.createObject(DOFObjectID oid) method is used to create it. The providerObject field stores the DOFObject that represents the provider, and the Object Identifier that represents the provider is defined by the oid parameters.