How to Get Shared TeaObjects
Any TeaObjects that are shared by an agent can be used by other agents that are registered with the same TIBCO Enterprise Administrator server. The objects are returned in JSON format.
To get a single shared TeaObject use the getObject() method as shown in the example below:
@TeaOperation(name = "getJohn", description = "getJohn") public String getJohn() throws IOException { //teaAgentServer is an instance of com.tibco.tea.agent.server.TeaAgentServer or com.tibco.tea.agent.server.TeaAgentServlet final TeaPersistence persistence = teaAgentServer.getPersistence(); // We query the method getObject(String agentTypeName, String agentTypeVersion, String objectTypeName, // String key); // That returns a org.json.JSONObject, in this case the Json Representation of Person with key John final JSONObject object = persistence.getObject("agentTypeNameHere", "Person", "john"); return object.toString(); }
Below is an example of how to get all shared TeaObjects for a specific TeaObjectType:
@TeaOperation(name = "getAllPersons", description = "getAllPersons") public String getAllPersons() throws IOException { //teaAgentServer is an instance of com.tibco.tea.agent.server.TeaAgentServer or com.tibco.tea.agent.server.TeaAgentServlet final TeaPersistence persistence = teaAgentServer.getPersistence(); final Map<String, JSONObject> allPersons = persistence.getObjects("agentTypeNameHere", "Person"); return Joiner.on(",").join(allPersons.values()); }
Copyright © Cloud Software Group, Inc. All Rights Reserved.