Defining TIBCO Enterprise Administrator Object Types Using Annotations

User defined classes can be annotated to define TIBCO Enterprise Administrator Object Types. One Java class can be used to define one or more TIBCO Enterprise Administrator Object Types.

The main annotation that defines the TEA Object Type is @TeaObjectType. While defining it in the java class, specify the name of the type, concept, and description. The object type should at least have a method with @TeaGetInfo annotation. When a key is passed to the method, it should return basic information about the object. An exception to this rule is the TOP_LEVEL type. Since there is only one instance of the TOP_LEVEL type per agent, the getInfo() method does not take a key as an argument. You can define a key that helps you identify the instances of an object type. A key is a String that is not processed by the server and not visible on the UI.

Procedure

  1. To define TIBCO Enterprise Administrator Object Type, mark the java class with the @TeaObjectType annotation. Specify the name of the type, concept, and description. You can use the @TeaObjectTypes annotation to define multiple types on the same class. The getInfo() method is mandatory for all types, except for top level objects where the method does not take a key as an argument. You can also have domain-specific implementation of obtaining the actual object. For example:
    @TeaObjectType(name="TOMCAT_SERVER", concept=TeaConcept.PROCESS, 
    description="Tomcat Server")
    public class TomcatServerManager {
     
        @TeaGetInfo
        public AgentObjectInfo getInfo(String key) {
     
             Server server = lookupTomcatServer(key);
     
            AgentObjectInfo result = new AgentObjectInfo();
            result.setName(server.getName());
            result.setDesc(server.getDescription);
            return result;
        }
     
         Server lookupTomcatServer(String key) {
            // domain specific implementation
        }
    } 
  2. For an Object Type with many types on the same java class, the minimal implementation is that there is a method marked with the @TeaGetInfo annotation. The annotation on the methods has the type they belong to using the objectType attribute. This attribute is mandatory when more than one type is defined on a class. Mark the method that takes a key as a parameter and returns basic information about an object, with the @TeaGetInfo annotation.

    For example,

    @TeaObjectTypes({
        @TeaObjectType(name = "TOMCAT_SERVER", concept = TeaConcept.PROCESS, description = "Tomcat Server"),
        @TeaObjectType(name = "TOMCAT_WEBAPP", concept = TeaConcept.APPLICATION, description = "Tomcat Web Application") })
    public class TomcatServerManager {
     
        @TeaGetInfo(objectType = "TOMCAT_SERVER")
        AgentObjectInfo getServerInfo(String key) {
        // ...
        }
     
        @TeaGetInfo(objectType = "TOMCAT_WEBAPP")
        AgentObjectInfo getWebappInfo(String key) {
        // ...
        }
    }
  3. (Optional) Mark the method with the @TeaGetConfig annotation to retrieve the configuration. Configuration is a Java Bean object that can be displayed on the TIBCO Enterprise Administrator server. For example,
    @TeaGetConfig
    MyJavaBean getConfiguration(String key) {
        // ...
    }
  4. (Optional) Mark the method with the @TeaGetStatus annotation to retrieve the current state of the object. State is a custom label that is associated with an object. The label can be defined by the agent and it should represent a state in the life-cycle of the object. Some operations can be linked to particular states of the object. For example, you should not start an application that is already running. The getStatus()method returns the AgentObjectStatus instance with the state name and description.
    @TeaGetStatus
    AgentObjectStatus getStatus(String key) {
        // sample code, it should depend on the state of actual object
        AgentObjectStatus result = new AgentObjectStatus();
        result.setState("DEPLOYED");
        result.setDesc("Application is deployed successfully");
        return result;
        }
  5. (Optional) Mark the method with the @TeaGetMembers annotation to retrieve the members list. The getMembers() method returns an array of AgentObjectIdentifier instances.
            @TeaGetMembers
            AgentObjectIdentifier[] getMembers(String key) {
            // ...
            }