Receive Agent Registration Notifications

An agent can store the server URL which is used to register itself with the TIBCO Enterprise Administrator server. This is especially useful when you have a failover mechanism in place. When the secondary agent comes up, the agent can use the URL information that is stored to register with TIBCO Enterprise Administrator.

The agent must implement the TeaAgentRegistrationListener interface to send the URL information from the TIBCO Enterprise Administrator server to the agent.
public interface TeaAgentRegistrationListener
extends EventListener{
void onAgentRegistered(TeaServerInfo event);
} 

Sample Code that Implements TeaAgentRegistrationListener

The following is a sample code snippet that shows how a standalone agent API adds the AgentRegistrationListener. It is assumed that you have created an instance of TeaAgentServer as follows:
TeaAgentServer server = new TeaAgentServer("HelloWorldAgent", "1.1", 
"Hello World Agent", 1234, "/helloworldagent", true);

//Add AgentRegistrationListener to the server.
server.addEventListener(new SampleAgentRegistrationListener());
The following is a sample code snippet that shows how a servlet API adds the AgentRegistrationListener. It is assumed that SampleTeaAgentServlet extends TeaAgentServlet and you have an instance of it.
 
SampleTeaAgentServlet servlet = new SampleTeaAgentServlet();

//Add AgentRegistrationListener to servlet
servlet.addEventListener(new SampleAgentRegistrationListener());
The following class implements TeaAgentRegistrationListener:

import com.tibco.tea.agent.api.TeaAgentRegistrationListener;
import com.tibco.tea.agent.api.TeaServerInfo;

public class SampleAgentRegistrationListener implements TeaAgentRegistrationListener {

@Override
public void onAgentRegistered(TeaServerInfo serverInfo) {
 System.out.println("TeaServerInfo Event Tea Server URL :" + serverInfo.getServerUrl()); }

}