Defining Multiple Object Types on One Class
In annotation style, you can use one Java class to model two or more managed object types.
Procedure
-
Annotate the class as
@TeaObjectTypes, and include within it a separate
@TeaObjectType annotation for each of the object types that the class can represent.
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 { ... }
-
For each object type, define a method that translates from an object key to basic information about the object, and annotate that method as
@TeaGetInfo. You must include the
objectType attribute in the annotation, to distinguish the object type to which each such method applies.
@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) { ... } }
- Similarly, include the objectType attribute when modeling aspects such as state, configuration, members, operations and references.
Copyright © Cloud Software Group, Inc. All Rights Reserved.