Defining an Object Type

Any object type other than the top level object can be defined using the com.tibco.tea.agent.api.TeaObject. The instances of these object types are represented by the object instanciated by the class implementing com.tibco.tea.agent.api.TeaObject.

Procedure

  1. To define an object type using the com.tibco.tea.agent.api.TeaObject, provide a class which implements com.tibco.tea.agent.api.TeaObjectProvider.

    For example,

    public class MyObjectTypeProvider implements TeaObjectProvider<MyObjectType> {
    
        public String getTypeName() {
        	//..
        }
    
        public String getTypeDescription() {
        	//..
        }
    
        public TeaConcept getConcept() {
        	//..
        }
    
        public MyObjectType getInstance(final String key) {
        	//..
        }
    }

    code explanation:

    • Create a class that implements com.tibco.tea.agent.api.TeaObjectProvider.
    • com.tibco.tea.agent.api.TeaObjectProvider.getTypeName() and com.tibco.tea.agent.api.TeaObjectProvider.getTypeDescription() should be used for describing the object type.
    • com.tibco.tea.agent.api.TeaObjectProvider.getConcept() should be used for defining the concept type for this object type. The various concept types are explained later in the document.
    • com.tibco.tea.agent.api.TeaObjectProvider.getInstance() should be used for key to instance mapping. When the TIBCO Enterprise Administrator agent library needs to obtain an instance corresponding to a given key for an object type, it will depend on the getInstance() method. For example, when an operation needs to be invoked on a particular instance of an object type, the TIBCO Enterprise Administrator agent library depends on this method for getting the instance by passing the key as a parameter.
  2. Define the object type by implementing the com.tibco.tea.agent.api.TeaObject.

    For example,

    public class MyObjectType implements TeaObject {
    
        public String getName() {
        	//..
        }
    
        public String getDescription() {
        	//..
        }
    
        public String getKey() {
        	//..
        }
    
        @TeaOperation(description = "get", methodType = MethodType.READ)
        public Result get() {
        	//..
        }
    }

    code explanation:

    • Create a class which implements com.tibco.tea.agent.api.TeaObject.
    • com.tibco.tea.agent.api.TeaObject.getName() and com.tibco.tea.agent.api.TeaObject.getDescription() should be used for describing the instance of the object type.
    • com.tibco.tea.agent.api.TeaObject.getKey() should be used for returning the key of the instance of the object type.
    • Any TeaOperation should be defined using the TeaOperation annotation.
  3. Register the object type definition with the TIBCO Enterprise Administrator Agent library.

    For example, create an instance of the object type provider that you created and register that with the TeaAgentServer.

    TeaAgentServer server = //..
    // register other instances including the top level object type
    MyObjectTypeProvider myObjectTypeProvider = //..
    server.registerInstance(myObjectTypeProvider);
    server.start();