Defining an Object Type with Only One Instance
Procedure
-
To define an object type which only has a single instance, create a class that implements
com.tibco.tea.agent.api.SingletonTeaObject.
For example,
public class MySingleton implements SingletonTeaObject { public String getTypeName() { //.. } public String getTypeDescription() { //.. } public String getName() { //.. } public String getDescription() { //.. } public TeaConcept getConcept() { //.. } @TeaOperation(description = "get", methodType = MethodType.READ) public Result get() { //.. } }Code explanation:
- To define an object type which only has a single instance, create a class which implements com.tibco.tea.agent.api.SingletonTeaObject.
- com.tibco.tea.agent.api.SingletonTeaObject.getTypeName() and com.tibco.tea.agent.api.SingletonTeaObject.getTypeDescription() should be used for describing the singleton object type.
- Since there is only one instance possible for this type, the instance specific methods are merged with object type specific methods. com.tibco.tea.agent.api.SingletonTeaObject.getName() and com.tibco.tea.agent.api.SingletonTeaObject.getDescription() should be used for describing the single instance of the singleton object type.
- com.tibco.tea.agent.api.SingletonTeaObject.getConcept() should be used to return the type of concept of the object type.
- Any TeaOperation should be defined using the TeaOperation annotation(explained later in the developer's guide).
-
Register the singleton object type definition with the TIBCO Enterprise Administrator Agent library.
For example, create an instance of the singleton object type and register it with the TeaAgentServer.
TeaAgentServer server = //.. // register other instances including the top level object type MySingleton mySingleton = //.. server.registerInstance(mySingleton); server.start();
Copyright © Cloud Software Group, Inc. All Rights Reserved.