com.tibco.tea.agent.server

## Class TeaAgentServer

- java.lang.Object
- - com.tibco.tea.agent.internal.BaseTeaAgent
  - - com.tibco.tea.agent.internal.server.BaseTeaAgentServer
    - - com.tibco.tea.agent.server.TeaAgentServer

-     public class TeaAgentServer
      extends com.tibco.tea.agent.internal.server.BaseTeaAgentServer

  A Jetty based server for hosting the `TeaAgent`.

  Example:

       TeaAgentServer server = new TeaAgentServer("HelloWorldAgent", "1.0", "Hellow World Agent", 1234, "/helloworldagent");
       server.registerInstance(new HelloWorldAgent());
       server.start();

  If metrics are enabled in the `TeaAgentServer constructor`, metrics such as uptime, heap memory, non-heap memory etc. would be added for the TeaAgentServer.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEFAULT_SERVER_PORT` Default server port on which the TeaAgentServer would listen for requests.
    `static String` | `DEFAULT_SERVLET_CONTEXT_PATH` Default path for the servlet context.
    `static String` | `HTTP_RESOLVE_HOST_NAME`

    - ### Fields inherited from class com.tibco.tea.agent.internal.server.BaseTeaAgentServer

      `TEA_CORRELATION_ID_HEADER`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TeaAgentServer(String name, String version, String agentInfo)` Constructs a TeaAgentServer.
    `TeaAgentServer(String name, String version, String agentInfo, int port)` Constructs a TeaAgentServer.
    `TeaAgentServer(String name, String version, String agentInfo, int port, String contextPath)` Constructs a TeaAgentServer.
    `TeaAgentServer(String name, String version, String agentInfo, int port, String contextPath, boolean enableMetrics)` Constructs a TeaAgentServer
    `TeaAgentServer(String name, String version, String agentInfo, int port, String contextPath, boolean enableMetrics, SSLContext sslContextForHttpServer, SSLContext sslContextForHttpClient)` Constructs a TeaAgentServer
    `TeaAgentServer(String name, String version, String agentInfo, String hostName, int port, String contextPath, boolean enableMetrics)` Constructs a TeaAgentServer
    `TeaAgentServer(String name, String version, String agentInfo, String hostName, int port, String contextPath, boolean enableMetrics, SSLContext sslContextForHttpServer, SSLContext sslContextForHttpClient)`
    `TeaAgentServer(TeaAgent teaAgent)` Deprecated.
    `TeaAgentServer(TeaAgent teaAgent, int port)` Deprecated.
    `TeaAgentServer(TeaAgent teaAgent, int port, String contextPath)` Deprecated.
    `TeaAgentServer(TeaAgent teaAgent, int port, String contextPath, boolean enableMetrics)` Deprecated.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `autoRegisterAgent(String agentName, String serverURL)` Register an agent with a given agentName with the TEA server running at the given serverURL
    `void` | `enableJVMInfo(boolean enable)`
    `void` | `enableMonitor(String key, int port)` Enable a monitoring thread which would listen on the `port` for requests authenticated with the `key` specified.
    `com.tibco.tea.agent.metrics.MetricsRegistry` | `getMetricsRegistry()` Returns instance of `MetricsRegistry` which can be used for managing metrics
    `Map<String,List<com.tibco.tea.agent.internal.RequestDispatcherEntry>>` | `getRequestDispatcherEntries()`
    `void` | `init()` Deprecated. From 1.0, this will be a private method
    `void` | `registerAgentAutoRegisterListener(String serverURL)` Override the method in super class by adding the server started check
    `<T> void` | `registerInstance(T instance)` Register an object instance of agent extender class.
    `<T> void` | `registerInstances(T... instances)` Register multiple object instances of classes created by the agent extender.
    `void` | `registerResourceLocation(File resourceLocation)` Register the folder where the various UI resources for customizing the agent are located.
    `boolean` | `resolveHostName()`
    `void` | `setAcceptors(int acceptors)`
    `void` | `setCertAlias(String certAlias)`
    `void` | `setExcludeProtocols(String excludeProtocols)`
    `void` | `setHttpClientCertAlias(String certAlias)`
    `void` | `setHttpClientKeyManagerPassword(String keyManagerPassword)`
    `void` | `setHttpClientKeyStorePassword(String password)`
    `void` | `setHttpClientKeyStorePath(String keyStorePath)`
    `void` | `setHttpClientTrustStorePassword(String trustStorePassword)`
    `void` | `setHttpClientTrustStorePath(String trustStorePath)`
    `void` | `setIdleTimeout(int idleTimeout)` Set the maximum Idle time for a connection, which roughly translates to the Socket.setSoTimeout(int) call.
    `void` | `setKeyManagerPassword(String keyManagerPassword)`
    `void` | `setKeyStorePassword(String password)`
    `void` | `setKeyStorePath(String keyStorePath)`
    `void` | `setNeedClientAuth(boolean needClientAuth)`
    `void` | `setSelectors(int selectors)`
    `void` | `setTrustStorePassword(String trustStorePassword)`
    `void` | `setTrustStorePath(String trustStorePath)`
    `void` | `setWantClientAuth(boolean wantClientAuth)`
    `void` | `setWebSocketIdleTimeout(long timeout)`
    `void` | `setWebSocketMaxMessageSize(int size)`
    `void` | `start()` Start the TeaAgentServer
    `void` | `stop()` Stop the TeaAgentServer

    - ### Methods inherited from class com.tibco.tea.agent.internal.server.BaseTeaAgentServer

      `autoRegisterAgent, getPersistence, processRequest, setAgentId, setExposePythonAPI, unregisterAgent`

    - ### Methods inherited from class com.tibco.tea.agent.internal.BaseTeaAgent

      `addEventListener, disableIndex, getAgentDispatcher, getNotificationService, getProtocol, getSeparator, registerSolution, registerSolutions, setEventNotificationBatchSize, setEventNotificationInterval, setProtocol, setSeparator, setTibcoHome, unregisterSolution, unregisterSolutions, withDocumentation, withProductExtension`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_SERVER_PORT

          public static final int DEFAULT_SERVER_PORT

      Default server port on which the TeaAgentServer would listen for requests.
      See Also:
        Constant Field Values

    - #### DEFAULT_SERVLET_CONTEXT_PATH

          public static final String DEFAULT_SERVLET_CONTEXT_PATH

      Default path for the servlet context.
      See Also:
        Constant Field Values

    - #### HTTP_RESOLVE_HOST_NAME

          public static final String HTTP_RESOLVE_HOST_NAME

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### TeaAgentServer

          @Deprecated
          public TeaAgentServer(TeaAgent teaAgent)

      Deprecated.
      Constructs a TeaAgentServer. Port for the TeaAgentServer would default to `DEFAULT_SERVER_PORT`. Path for the ServletContext would default to `DEFAULT_SERVLET_CONTEXT_PATH`. Metrics for the core agent functionality would not be enabled.
      Parameters:
        `teaAgent` - `TeaAgent` which would be hosted by the TeaAgentServer

    - #### TeaAgentServer

          @Deprecated
          public TeaAgentServer(TeaAgent teaAgent,
                                            int port)

      Deprecated.
      Constructs a TeaAgentServer. Path for the ServletContext would default to `DEFAULT_SERVLET_CONTEXT_PATH`. Metrics for the core agent functionality would not be enabled.
      Parameters:
        `teaAgent` - `TeaAgent` which would be hosted by the TeaAgentServer
        `port` - port at which the TeaAgentServer would listen for requests

    - #### TeaAgentServer

          @Deprecated
          public TeaAgentServer(TeaAgent teaAgent,
                                            int port,
                                            String contextPath)

      Deprecated.
      Constructs a TeaAgentServer. Metrics for the core agent functionality would not be enabled.
      Parameters:
        `teaAgent` - `TeaAgent` which would be hosted by the TeaAgentServer
        `port` - port at which the TeaAgentServer would listen for requests
        `contextPath` - path for ServletContext

    - #### TeaAgentServer

          @Deprecated
          public TeaAgentServer(TeaAgent teaAgent,
                                            int port,
                                            String contextPath,
                                            boolean enableMetrics)

      Deprecated.
      Constructs a TeaAgentServer
      Parameters:
        `teaAgent` - `TeaAgent` which would be hosted by the TeaAgentServer
        `port` - port at which the TeaAgentServer would listen for requests
        `contextPath` - path for ServletContext
        `enableMetrics` - Add metrics for the core agent functionality.

    - #### TeaAgentServer

          public TeaAgentServer(String name,
                                String version,
                                String agentInfo)

      Constructs a TeaAgentServer. Port for the TeaAgentServer would default to `DEFAULT_SERVER_PORT`. Path for the ServletContext would default to `DEFAULT_SERVLET_CONTEXT_PATH`. Metrics for the core agent functionality would not be enabled.

    - #### TeaAgentServer

          public TeaAgentServer(String name,
                                String version,
                                String agentInfo,
                                int port)

      Constructs a TeaAgentServer. Path for the ServletContext would default to `DEFAULT_SERVLET_CONTEXT_PATH`. Metrics for the core agent functionality would not be enabled.
      Parameters:
        `port` - port at which the TeaAgentServer would listen for requests

    - #### TeaAgentServer

          public TeaAgentServer(String name,
                                String version,
                                String agentInfo,
                                int port,
                                String contextPath)

      Constructs a TeaAgentServer. Metrics for the core agent functionality would not be enabled.
      Parameters:
        `port` - port at which the TeaAgentServer would listen for requests
        `contextPath` - path for ServletContext

    - #### TeaAgentServer

          public TeaAgentServer(String name,
                                String version,
                                String agentInfo,
                                int port,
                                String contextPath,
                                boolean enableMetrics)

      Constructs a TeaAgentServer
      Parameters:
        `port` - port at which the TeaAgentServer would listen for requests
        `contextPath` - path for ServletContext
        `enableMetrics` - Add metrics for the core agent functionality.

    - #### TeaAgentServer

          public TeaAgentServer(String name,
                                String version,
                                String agentInfo,
                                int port,
                                String contextPath,
                                boolean enableMetrics,
                                SSLContext sslContextForHttpServer,
                                SSLContext sslContextForHttpClient)

      Constructs a TeaAgentServer
      Parameters:
        `port` - port at which the TeaAgentServer would listen for requests
        `contextPath` - path for ServletContext
        `enableMetrics` - Add metrics for the core agent functionality.

    - #### TeaAgentServer

          public TeaAgentServer(String name,
                                String version,
                                String agentInfo,
                                String hostName,
                                int port,
                                String contextPath,
                                boolean enableMetrics)

      Constructs a TeaAgentServer
      Parameters:
        `hostName` - host name to bound this server to
        `port` - port at which the TeaAgentServer would listen for requests
        `contextPath` - path for ServletContext
        `enableMetrics` - Add metrics for the core agent functionality.

    - #### TeaAgentServer

          public TeaAgentServer(String name,
                                String version,
                                String agentInfo,
                                String hostName,
                                int port,
                                String contextPath,
                                boolean enableMetrics,
                                SSLContext sslContextForHttpServer,
                                SSLContext sslContextForHttpClient)

  - ### Method Detail

    - #### init

          @Deprecated
          public void init()

      Deprecated. From 1.0, this will be a private method
      Initialize the TeaAgent to start accepting requests
      Overrides:
        `init` in class `com.tibco.tea.agent.internal.server.BaseTeaAgentServer`

    - #### getRequestDispatcherEntries

          public Map<String,List<com.tibco.tea.agent.internal.RequestDispatcherEntry>> getRequestDispatcherEntries()

      Overrides:
        `getRequestDispatcherEntries` in class `com.tibco.tea.agent.internal.server.BaseTeaAgentServer`

    - #### enableMonitor

          public void enableMonitor(String key,
                                    int port)

      Enable a monitoring thread which would listen on the `port` for requests authenticated with the `key` specified. This can be used to stop the underlying jetty server.
      Parameters:
        `key` - key for authenticating the request
        `port` - port where the monitoring thread would listen for requests

    - #### start

          public void start()
                     throws Exception

      Start the TeaAgentServer
      Throws:
        `Exception`

    - #### stop

          public void stop()
                    throws Exception

      Stop the TeaAgentServer
      Throws:
        `Exception`

    - #### registerInstances

          public <T> void registerInstances(T... instances)

      Register multiple object instances of classes created by the agent extender. TeaAgent will go through the classes and process all the annotations declared for the agent extender class. The methods with `TeaOperation` would be added as REST endpoints. To service requests for these endpoints, method would be invoked on the instances that the user registered.
      Overrides:
        `registerInstances` in class `com.tibco.tea.agent.internal.BaseTeaAgent`
      Parameters:
        `instances` -

    - #### registerInstance

          public <T> void registerInstance(T instance)

      Register an object instance of agent extender class. TeaAgent will go through the class and process all the annotations declared for the agent extender class. The methods with `TeaOperation` would be added as REST endpoints. To service requests for these endpoints, method would be invoked on the instance that the user registered.

      IllegalStateException would be thrown if the TeaAgent is already initialized.
      Overrides:
        `registerInstance` in class `com.tibco.tea.agent.internal.BaseTeaAgent`
      Parameters:
        `instance` - object instance of agent extender class

    - #### registerResourceLocation

          public void registerResourceLocation(File resourceLocation)

      Register the folder where the various UI resources for customizing the agent are located. These resources would be downloaded by the TEA server and made available for customized UI to access.
      Overrides:
        `registerResourceLocation` in class `com.tibco.tea.agent.internal.BaseTeaAgent`
      Parameters:
        `resourceLocation` - location of the UI resources

    - #### getMetricsRegistry

          public com.tibco.tea.agent.metrics.MetricsRegistry getMetricsRegistry()

      Returns instance of `MetricsRegistry` which can be used for managing metrics
      Overrides:
        `getMetricsRegistry` in class `com.tibco.tea.agent.internal.BaseTeaAgent`
      Returns:
        the metricsRegistry

    - #### registerAgentAutoRegisterListener

          public void registerAgentAutoRegisterListener(String serverURL)
                                                 throws Exception

      Override the method in super class by adding the server started check
      Throws:
        `Exception`

    - #### autoRegisterAgent

          public void autoRegisterAgent(String agentName,
                                        String serverURL)
                                 throws IllegalArgumentException

      Register an agent with a given agentName with the TEA server running at the given serverURL
      Overrides:
        `autoRegisterAgent` in class `com.tibco.tea.agent.internal.server.BaseTeaAgentServer`
      Parameters:
        `agentName` - agentName for this agent
        `serverURL` - URL of TEA server to register this agent with
      Throws:
        `IllegalArgumentException`

    - #### setAcceptors

          public void setAcceptors(int acceptors)

      Parameters:
        `acceptors` - The number of acceptor threads to set.

    - #### setSelectors

          public void setSelectors(int selectors)

      Parameters:
        `acceptors` - The number of selector threads to set.

    - #### setIdleTimeout

          public void setIdleTimeout(int idleTimeout)

      Set the maximum Idle time for a connection, which roughly translates to the Socket.setSoTimeout(int) call.
      Parameters:
        `idleTimeout` - The maxIdleTime to set.

    - #### setKeyStorePath

          public void setKeyStorePath(String keyStorePath)

      Overrides:
        `setKeyStorePath` in class `com.tibco.tea.agent.internal.server.BaseTeaAgentServer`
      Parameters:
        `keyStorePath` - The file or URL of the SSL Key store.

    - #### setKeyStorePassword

          public void setKeyStorePassword(String password)

      Overrides:
        `setKeyStorePassword` in class `com.tibco.tea.agent.internal.server.BaseTeaAgentServer`
      Parameters:
        `password` - The password for the key store.

    - #### setCertAlias

          public void setCertAlias(String certAlias)

      Overrides:
        `setCertAlias` in class `com.tibco.tea.agent.internal.server.BaseTeaAgentServer`
      Parameters:
        `certAlias` - Alias of SSL certificate for the connector.

    - #### setKeyManagerPassword

          public void setKeyManagerPassword(String keyManagerPassword)

      Overrides:
        `setKeyManagerPassword` in class `com.tibco.tea.agent.internal.server.BaseTeaAgentServer`
      Parameters:
        `keyManagerPassword` - The password (if any) for the specific key within the key store.

    - #### setTrustStorePath

          public void setTrustStorePath(String trustStorePath)

      Overrides:
        `setTrustStorePath` in class `com.tibco.tea.agent.internal.server.BaseTeaAgentServer`
      Parameters:
        `trustStorePath` - The file name or URL of the trust store location.

    - #### setTrustStorePassword

          public void setTrustStorePassword(String trustStorePassword)

      Overrides:
        `setTrustStorePassword` in class `com.tibco.tea.agent.internal.server.BaseTeaAgentServer`
      Parameters:
        `trustStorePassword` - The password for the trust store.

    - #### setWantClientAuth

          public void setWantClientAuth(boolean wantClientAuth)

    - #### setNeedClientAuth

          public void setNeedClientAuth(boolean needClientAuth)

    - #### setExcludeProtocols

          public void setExcludeProtocols(String excludeProtocols)

    - #### setHttpClientKeyStorePath

          public void setHttpClientKeyStorePath(String keyStorePath)

      Parameters:
        `keyStorePath` - The file or URL of the SSL Key store.

    - #### setHttpClientKeyStorePassword

          public void setHttpClientKeyStorePassword(String password)

      Parameters:
        `password` - The password for the key store.

    - #### setHttpClientCertAlias

          public void setHttpClientCertAlias(String certAlias)

      Parameters:
        `certAlias` - Alias of SSL certificate for the connector.

    - #### setHttpClientKeyManagerPassword

          public void setHttpClientKeyManagerPassword(String keyManagerPassword)

      Parameters:
        `keyManagerPassword` - The password (if any) for the specific key within the key store.

    - #### setHttpClientTrustStorePath

          public void setHttpClientTrustStorePath(String trustStorePath)

      Parameters:
        `trustStorePath` - The file name or URL of the trust store location.

    - #### setHttpClientTrustStorePassword

          public void setHttpClientTrustStorePassword(String trustStorePassword)

      Parameters:
        `trustStorePassword` - The password for the trust store.

    - #### setWebSocketIdleTimeout

          public void setWebSocketIdleTimeout(long timeout)

    - #### setWebSocketMaxMessageSize

          public void setWebSocketMaxMessageSize(int size)

    - #### enableJVMInfo

          public void enableJVMInfo(boolean enable)

    - #### resolveHostName

          public boolean resolveHostName()

Copyright © 2022 TIBCO Software Inc.. All Rights Reserved.