Object Type Definition: Overview

Within your agent code, you can define an object type using either of two implementation styles—interface style or annotation style. Your choice of style depends on the characteristics of the product that the agent manages.

Aspect Interface Style Annotation Style
Defining Object Types Define an object type by defining a class that implements interfaces such as TopLevelTeaObject, TeaObject or SingletonTeaObject. Define a class, then annotate it as an object type using TeaObjectType or TeaObjectTypes.
Representing Product Objects To represent an object in the product, your agent code creates a Java instance of a corresponding class. To represent an object in the product, your agent code can use an object identifier that indexes into a database.
Objects in the Agent Library Your agent code can pass these Java instances to the agent library through a provider object.

The agent library calls the interface methods of these instances.

Note: Your agent code and the agent library share access to these instances, which could affect memory management.
Your agent code passes only object identifiers to the agent library.
Advantages Java coding style is straightforward. Object identifiers are inexpensive strings.

One database query can retrieve many objects.

Disadvantages Instantiating many objects can be costly. If a product has many managed objects, then the agent instantiates many Java objects to represent them. Translating between object identifier strings and object information adds an additional layer of complexity to your agent code.
Choosing a Style Appropriate for products with relatively few managed objects

Appropriate for rapid prototyping

Appropriate for products with many managed objects

Appropriate for products that already store objects in a database (including a flat-file database or a non-persistent database)

Related tasks