Running TIBCO Enterprise Administrator Agent Library in the Servlet mode

TIBCO Enterprise Administrator provides an abstract servlet that needs be subclassed to register object instances.

Procedure

  1. Extend the abstract servlet of TIBCO Enterprise Administrator to define the object that needs to be registered.

    The following example code defines only one object to register in the server.

    public class HelloWorldServlet extends TeaAgentServlet {
    
        /*
         * (non-Javadoc)
         *
         * @see com.tibco.tea.agent.server.TeaAgentServlet#getObjectInstances()
         */
        @Override
        protected Object[] getObjectInstances() throws ServletException {
            return new Object[]{new HelloWorldAgent()};
        }
    }
  2. Configure the servlet with proper parameters using web.xml. Map the agent servlet to /* as further dispatches are done by the servlet.
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" version="2.4">
    
        <display-name>HelloWorld Agent</display-name>
    
        <servlet>
            <servlet-name>HelloWorldAgent</servlet-name>
            <servlet-class>HelloWorldServlet</servlet-class>
            <init-param>
                <param-name>name</param-name>
                <param-value>HelloWorldAgent</param-value>
            </init-param>
            <init-param>
                <param-name>version</param-name>
                <param-value>1.1</param-value>
            </init-param>
            <init-param>
                <param-name>agent-info</param-name>
                <param-value>HelloWorld Agent</param-value>
            </init-param>
        </servlet>
    
        <servlet-mapping>
            <servlet-name>HelloWorldAgent</servlet-name>
            <url-pattern>/*</url-pattern>
        </servlet-mapping>
    
    </web-app>     
    
  3. Deploy the servlet using the standard servlet container mechanisms. To verify, you can start an embedded Jetty server, with the programmatically deployed servlet. For a standalone agent process, configuration through the server mode is a better approach.
    public static void main(final String[] args) throws Exception {
    							
        Server server = new Server(1234);
        ServletContextHandler servletContextHandler = new ServletContextHandler(server, "/helloworldagent", false, false);
    
        ServletHolder servletHolder = servletContextHandler.addServlet(HelloWorldServlet.class, "/*");
        servletHolder.setInitParameter("name", "HelloWorldAgent");
        servletHolder.setInitParameter("version", "1.1");
        servletHolder.setInitParameter("agent-info", "HelloWorld Agent");
        server.start();
    
        server.join();
    }
    Note: It is recommended that you do not set the load-on-startup flag to false otherwise the servlet is not loaded on startup.