Defining an Object Type in Annotation Style

In annotation style, agent code models a managed object type by defining a class, and marking it with annotations, such as @TeaObjectType.

Procedure

  1. Annotate the object type class as @TeaObjectType. Supply the required attributes—name, description and concept.
    @TeaObjectType(name="TOMCAT_SERVER",
        description="Tomcat Server"
        concept=TeaConcept.PROCESS,)
    public class TomcatServerManager {
        ...
    } 
  2. Define a method that translates from an object key to basic information about the object, and annotate that method as @TeaGetInfo.
    This method must return an instance of AgentObjectInfo.
    @TeaObjectType(name="TOMCAT_SERVER",
        description="Tomcat Server"
        concept=TeaConcept.PROCESS,)
    public class TomcatServerManager {
     
        @TeaGetInfo
        public AgentObjectInfo getInfo(@KeyParam final 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
        }
    } 

    For top-level object types, this method does not accept any arguments. (An object key would be superfluous because a top-level type can have only one instance.)

  3. If the object type has state, define a method that returns the current state of an instance, and annotate it as @TeaGetStatus.
  4. If the object type has configuration, define a method that returns the configuration, and annotate it as @TeaGetConfig.
  5. If the object type can contain members, define a method that returns the members, and annotate it as @TeaGetMembers.