In
annotation style, agent code models a managed object type by defining a class, and marking it with annotations, such as
@TeaObjectType.
Procedure
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 {
...
}
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.)
If the object type has state, define a method that returns the current state of an instance, and annotate it as
@TeaGetStatus.