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
- 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.
For details, see Modeling State in Annotation Style.
- If the object type has configuration, define a method that returns the configuration, and annotate it as
@TeaGetConfig.
For details, see Modeling Configuration in Annotation Style.
- If the object type can contain members, define a method that returns the members, and annotate it as
@TeaGetMembers.
For details, see Modeling Members in Annotation Style.
What to do next
Annotations:
To model aspects of object types in annotation style, see these topics:
Subtopics