Starting the Sample TIBCO Enterprise Administrator Agent

TIBCO Enterprise Administrator SDK ships with samples that demonstrate the various aspects of developing product agents. This procedure lists how to start the sample, HelloWorldAgent.java that is located under TIBCO_HOME/tea/<version>/samples/helloworld.

Procedure

  1. Navigate to TIBCO_HOME/tea/<version>/samples/helloworld.
  2. Open TIBCO_HOME/tea/<version>/samples/helloworld/helloworld/src/com/tibco/tea/agent/HelloWorldAgent.java. By default, the following code is displayed. You can make your changes to the code to suit your needs.
    import com.tibco.tea.agent.TeaAgent;
    import com.tibco.tea.agent.TeaAgentServer;
    import com.tibco.tea.agent.api.TeaObjectType;
    import com.tibco.tea.agent.api.TeaConcept;
    import com.tibco.tea.agent.api.TeaGetInfo;
    import com.tibco.tea.agent.api.TeaOperation;
    import com.tibco.tea.agent.api.TeaParam;
    import com.tibco.tea.agent.types.AgentObjectInfo;
    import java.io.IOException;
     
    @TeaObjectType(name = "HelloWorldAgent", concept = TeaConcept.TOP_LEVEL, 
    description = "Hello World Agent")
    
    public class HelloWorldAgent {
        @TeaGetInfo
        public AgentObjectInfo getInfo() {
            AgentObjectInfo agentObject = new AgentObjectInfo();
            agentObject.setName("helloworld");
            agentObject.setDesc("Hellow World Agent");
            return agentObject;
        }
        @TeaOperation(name = "helloworld", description = "Send greetings")
        public String helloworld(
        @TeaParam(name = "greetings", description = "Greetins parameter")final String greetings) 
         throws IOException {
            return "Hello " + greetings;
        }
        public static void main(final String[] args) throws Exception {
            TeaAgent agent = new TeaAgent("HelloWorldAgent", "1.1", "Hellow World Agent");
            agent.registerInstance(new HelloWorldAgent());
            TeaAgentServer server = new TeaAgentServer(agent, 1234, "/helloworldagent");
            server.start();
        }
    }
  3. Open the TIBCO_HOME/tea/<version>/samples/helloworld/build.xml.By default, the following code is displayed. You can make your changes to the code to suit your needs.
    <?xml version="1.0" encoding="UTF-8"?>
    <project name="agent" default="compile">
      <target name="compile">
        <javac srcdir="src" destdir="dist">
          <classpath>
            <fileset dir="../../lib">
              <include name="*.jar"/>
            </fileset>
          </classpath>
        </javac>
      </target>
     
      <target name="start">
        <java classname="HelloWorldAgent" fork="yes">
          <classpath>
            <pathelement location="dist/"/>
            <fileset dir="../../lib">
              <include name="*.jar"/>
            </fileset>
          </classpath>
        </java>
      </target>
    </project>
  4. From the command prompt, navigate to TIBCO_HOME/tea/<version>/samples/helloworld. To build the java file, run ant.
  5. To start the agent, run ant start.
  6. To register the agent with the TIBCO Enterprise Administrator, perform the following steps:
    1. Login to TIBCO Enterprise Administrator.
    2. From the Agents panel, click Register .
    3. In the Register Agent window, enter the Agent Name as helloworld.
    4. Enter the Agent URL as http://localhost:1234/helloworldagent.
    5. Click Register.
    The Agent pane is displayed and the helloworld agent appears as a registered agent.
  7. To access the agent, from the Agent pane, click HelloWorldTopLevelType.

Result

You can access the agent registered on the server.
Note: After registering an agent with the server, objects exposed by the server may not be available for searching within the first 30 seconds after registration. To change this setting, open the <TEA_CONFIG_HOME>\tibco\cfgmgmt\conf\tea.conf file and change the value in the tea.indexing.interval property. The default value is 30000 milliseconds.