Class AgentServlet

java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
org.jolokia.server.core.http.AgentServlet
All Implemented Interfaces:
jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable
Direct Known Subclasses:
OsgiAgentServlet

public class AgentServlet extends jakarta.servlet.http.HttpServlet
Agent servlet which connects to a local JMX MBeanServer for JMX operations.

It uses a REST based approach which translates a GET Url into a request. See the reference documentation for a detailed description of this servlet's features.

Since:
Apr 18, 2009
Author:
roland@jolokia.org
See Also:
  • Constructor Details

    • AgentServlet

      public AgentServlet()
      No argument constructor, used e.g. by a servlet descriptor when creating the servlet out of web.xml
    • AgentServlet

      public AgentServlet(Restrictor pRestrictor)
      Constructor taking a restrictor to use
      Parameters:
      pRestrictor - restrictor to use or null if the restrictor should be created in the default way by doing a lookup and use the standard restrictors.
  • Method Details

    • init

      public void init(jakarta.servlet.ServletConfig pServletConfig) throws jakarta.servlet.ServletException
      Specified by:
      init in interface jakarta.servlet.Servlet
      Overrides:
      init in class jakarta.servlet.GenericServlet
      Parameters:
      pServletConfig - servlet configuration
      Throws:
      jakarta.servlet.ServletException
    • destroy

      public void destroy()
      Specified by:
      destroy in interface jakarta.servlet.Servlet
      Overrides:
      destroy in class jakarta.servlet.GenericServlet
    • initServices

      protected void initServices(jakarta.servlet.ServletConfig pServletConfig, JolokiaServiceManager pServiceManager)
      Initialize services and register service factories
      Parameters:
      pServletConfig - servlet configuration
      pServiceManager - service manager to which to add services
    • getServerDetectorLookup

      protected ServerDetectorLookup getServerDetectorLookup()
      Hook for allowing a custome detector lookup
      Returns:
      detector lookup class to use in addition to the standard classpath scanning or null if this is not needed
    • createConfig

      protected Configuration createConfig(jakarta.servlet.ServletConfig pServletConfig)
      Examines servlet config and servlet context for configuration parameters. Configuration from the servlet context overrides servlet parameters defined in web.xml. This method can be subclassed in order to provide an own mechanism for providing a configuration.
      Parameters:
      pServletConfig - servlet configuration
      Returns:
      generated configuration
    • createLogHandler

      protected LogHandler createLogHandler(jakarta.servlet.ServletConfig pServletConfig, Configuration pConfig)
      Create a log handler using this servlet's logging facility for logging. This method can be overridden to provide a custom log handler.
      Parameters:
      pServletConfig - servlet config
      pConfig - jolokia config
      Returns:
      a default log handler
    • createRestrictor

      protected Restrictor createRestrictor(Configuration pConfig, LogHandler pLogHandler)
      Create a restrictor to use. By default, this method returns the restrictor given in the constructor or does a lookup for a policy fule, but thie can be overridden in order to fine tune the creation.
      Returns:
      the restrictor to use
    • doGet

      protected void doGet(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) throws IOException
      Overrides:
      doGet in class jakarta.servlet.http.HttpServlet
      Throws:
      IOException
    • doPost

      protected void doPost(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) throws IOException
      Overrides:
      doPost in class jakarta.servlet.http.HttpServlet
      Throws:
      IOException
    • doOptions

      protected void doOptions(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
      OPTION requests are treated as CORS preflight requests
      Overrides:
      doOptions in class jakarta.servlet.http.HttpServlet
      Parameters:
      req - the original request
      resp - the response the answer are written to