Class ReadHandler

java.lang.Object
org.jolokia.service.jmx.handler.AbstractCommandHandler<org.jolokia.server.core.request.JolokiaReadRequest>
org.jolokia.service.jmx.handler.ReadHandler
All Implemented Interfaces:
CommandHandler<org.jolokia.server.core.request.JolokiaReadRequest>

public class ReadHandler extends AbstractCommandHandler<org.jolokia.server.core.request.JolokiaReadRequest>
Handler for managing READ requests for reading attributes.
Since:
Jun 12, 2009
Author:
roland
  • Constructor Details

    • ReadHandler

      public ReadHandler()
  • Method Details

    • getType

      public org.jolokia.server.core.util.RequestType getType()
      Description copied from interface: CommandHandler
      The type of request which can be handled
      Returns:
      the request type of this handler
    • checkForRestriction

      protected void checkForRestriction(org.jolokia.server.core.request.JolokiaReadRequest pRequest)
      Description copied from class: AbstractCommandHandler
      Check whether there is a restriction on the type to apply. This method should be overwritten by specific handlers if they support a more sophisticated check than only for the type
      Specified by:
      checkForRestriction in class AbstractCommandHandler<org.jolokia.server.core.request.JolokiaReadRequest>
      Parameters:
      pRequest - request to check
    • handleAllServersAtOnce

      public boolean handleAllServersAtOnce(org.jolokia.server.core.request.JolokiaReadRequest pRequest)
      For simple requests (one MBean, no pattern, one attribute) we use the MBeanServerAccess.call(ObjectName, MBeanServerAccess.MBeanAction, Object...) to quickly return first available result. If the request is for an MBean pattern or multiple (or all) attributes are required, we combine multiple requests for multiple servers.
      Specified by:
      handleAllServersAtOnce in interface CommandHandler<org.jolokia.server.core.request.JolokiaReadRequest>
      Overrides:
      handleAllServersAtOnce in class AbstractCommandHandler<org.jolokia.server.core.request.JolokiaReadRequest>
      Parameters:
      pRequest - request to decide on whether to handle all request at once
      Returns:
      true if this is a multi attribute request, has an MBean pattern to look for or is a request for all attributes.
    • doHandleSingleServerRequest

      public Object doHandleSingleServerRequest(MBeanServerConnection pServer, org.jolokia.server.core.request.JolokiaReadRequest pRequest) throws IOException, JMException
      Used for a request for a single attribute from a single MBean.
      Specified by:
      doHandleSingleServerRequest in class AbstractCommandHandler<org.jolokia.server.core.request.JolokiaReadRequest>
      Parameters:
      pServer - server on which to request the attribute
      pRequest - the request itself.
      Returns:
      the attribute's value
      Throws:
      IOException - when there's an error invoking MBeanServerConnection
      JMException - JMX checked exception, because most requests are handled by dealing with MBeans
    • doHandleAllServerRequest

      public Object doHandleAllServerRequest(org.jolokia.server.core.util.jmx.MBeanServerAccess jmxAccess, org.jolokia.server.core.request.JolokiaReadRequest pRequest, Object pPreviousResult) throws IOException, JMException
      Description copied from class: AbstractCommandHandler
      Default implementation for handling a request for multiple servers at once. A subclass, which returns, true from AbstractCommandHandler.handleAllServersAtOnce(JolokiaRequest), needs to override this method. If AbstractCommandHandler.handleAllServersAtOnce(JolokiaRequest) returns false, the iteration over available connections is performed by the caller (RequestHandler).
      Overrides:
      doHandleAllServerRequest in class AbstractCommandHandler<org.jolokia.server.core.request.JolokiaReadRequest>
      Parameters:
      jmxAccess - all MBean servers found in this JVM
      pRequest - the original request
      pPreviousResult - a previous result which for merging requests can be used to merge the data
      Returns:
      the result of the the request.
      Throws:
      IOException - when there's an error invoking MBeanServerConnection
      JMException - JMX checked exception, because most requests are handled by dealing with MBeans