Defining References for Object Types with Interfaces

References allow users to navigate from one object to related objects. To model relationships other than membership, you can expose a method as a reference. That is, define a method that returns the set of related objects, and annotate it as a @TeaReference.

When defining the source object type using interface style, define references as explained in this task.

To model a member relationship, implement the WithMembers interface.

Procedure

  1. Declare the method signature.
    The method cannot have any parameters, and it must return an array or java.util.Collection of objects that implement com.tibco.tea.agent.api.BaseTeaObject.
    For example, in TIBCO ActiveMatrix, administrators can distribute an application to a set of nodes. In the agent, the getNodes() method returns an array or java.util.Collection of those nodes. The Node class implements the BaseTeaObject interface.
     public Node[] getNodes(){
        ...
    }
    public Collection<Node> getNodes(){
    	...
    }
  2. Annotate the method as a reference using @TeaReference.
    @TeaReference(name = "nodes")
    public Node[] getNodes(){
        ...
    }
    @TeaReference(name = "nodes")
    public Collection<Node> getNodes(){
        ...
    }
    If the reference type class defines more than one object type, then include the objectType attribute, to distinguish among them.