Interface CommandHandler<R extends org.jolokia.server.core.request.JolokiaRequest>

All Known Implementing Classes:
AbstractCommandHandler, ExecHandler, ListHandler, NotificationHandler, ReadHandler, SearchHandler, WriteHandler

public interface CommandHandler<R extends org.jolokia.server.core.request.JolokiaRequest>
Final abstraction layer for handling Jolokia requests - actual implementation of Jolokia verbs. Methods may throw JMException or JMRuntimeException exceptions to be handled down the stack. JMX exceptions are explicit here, because most of the commands are about interacting with MBeans.
Since:
09.03.14
Author:
roland
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Lifecycle method called when agent goes down.
    org.jolokia.server.core.util.RequestType
    The type of request which can be handled
    handleAllServerRequest(org.jolokia.server.core.util.jmx.MBeanServerAccess pServerManager, R request, Object pPreviousResult)
    Override this if you want to iterate over all available servers and potentially use a result from a previous RequestHandlerat once for processing the request (like need for merging info as for a list command).
    boolean
    Override this if you want all available MBeanServers to be passed to this command handler, e.g., to query each server on your own.
    Handle a request for a single MBeanServerConnection.
    void
    init(org.jolokia.server.core.service.api.JolokiaContext pContext, String pProvider)
    Lifecycle method in order to initialize the handler
  • Method Details

    • getType

      org.jolokia.server.core.util.RequestType getType()
      The type of request which can be handled
      Returns:
      the request type of this handler
    • handleAllServersAtOnce

      boolean handleAllServersAtOnce(R pRequest)
      Override this if you want all available MBeanServers to be passed to this command handler, e.g., to query each server on your own. By default, iteration over the available MBeanServers is done by the RequestHandler and this command handler is called through handleSingleServerRequest(MBeanServerConnection, JolokiaRequest).
      Parameters:
      pRequest - request to decide on whether to handle all request at once
      Returns:
      whether you want to have handleSingleServerRequest(MBeanServerConnection, JolokiaRequest) (false) or handleAllServerRequest(MBeanServerAccess, JolokiaRequest, Object) (true) called.
    • handleSingleServerRequest

      Object handleSingleServerRequest(MBeanServerConnection pServer, R pRequest) throws IOException, JMException, org.jolokia.server.core.request.NotChangedException, org.jolokia.server.core.request.BadRequestException, org.jolokia.server.core.request.EmptyResponseException
      Handle a request for a single MBeanServerConnection. Coordination of the servers and other request handlers is taken care of externally.
      Parameters:
      pServer - server to send the request to
      pRequest - request to process
      Returns:
      the result of sending a request to the MBean server
      Throws:
      IOException - when there's an error invoking MBeanServerConnection
      JMException - JMX checked exception, because most requests are handled by dealing with MBeans
      JMRuntimeException - JMX unchecked exception, because most requests are handled by dealing with MBeans
      org.jolokia.server.core.request.NotChangedException - when (according to request parameters) user wants HTTP 304 if nothing has changed
      org.jolokia.server.core.request.BadRequestException - because some commands do more user input parsing in addition to what was checked when the JolokiaRequest was created
      org.jolokia.server.core.request.EmptyResponseException - if the response should not be closed (expecting further async/stream data)
    • handleAllServerRequest

      Object handleAllServerRequest(org.jolokia.server.core.util.jmx.MBeanServerAccess pServerManager, R request, Object pPreviousResult) throws IOException, JMException, org.jolokia.server.core.request.NotChangedException, org.jolokia.server.core.request.BadRequestException, org.jolokia.server.core.request.EmptyResponseException
      Override this if you want to iterate over all available servers and potentially use a result from a previous RequestHandlerat once for processing the request (like need for merging info as for a list command). This method is only called when handleAllServersAtOnce(JolokiaRequest) returns true
      Parameters:
      pServerManager - server manager holding all MBeans servers detected
      request - request to process
      pPreviousResult - a previous result which for merging requests can be used to merge files
      Returns:
      the object found
      Throws:
      IOException
      JMException - for any JMX exception
      org.jolokia.server.core.request.NotChangedException - for Jolokia handling of 304 (not changed)
      org.jolokia.server.core.request.BadRequestException - when processing of user input (like path in LIST command) fails
      org.jolokia.server.core.request.EmptyResponseException - for Jolokia notification stream handling
    • init

      void init(org.jolokia.server.core.service.api.JolokiaContext pContext, String pProvider)
      Lifecycle method in order to initialize the handler
      Parameters:
      pContext - the jolokia context
      pProvider - provider to use for returned names. Handlers can use this for returning meta data with the proper provider prefixed.
    • destroy

      void destroy() throws JMException
      Lifecycle method called when agent goes down. Should be overridden by a handler if required.
      Throws:
      JMException