Package org.jolokia.service.jmx.api
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 TypeMethodDescriptionvoiddestroy()Lifecycle method called when agent goes down.org.jolokia.server.core.util.RequestTypegetType()The type of request which can be handledhandleAllServerRequest(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 previousRequestHandlerat once for processing the request (like need for merging info as for alistcommand).booleanhandleAllServersAtOnce(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.handleSingleServerRequest(MBeanServerConnection pServer, R pRequest) Handle a request for a singleMBeanServerConnection.voidLifecycle 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
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 theRequestHandlerand this command handler is called throughhandleSingleServerRequest(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) orhandleAllServerRequest(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 singleMBeanServerConnection. Coordination of the servers and other request handlers is taken care of externally.- Parameters:
pServer- server to send the request topRequest- request to process- Returns:
- the result of sending a request to the MBean server
- Throws:
IOException- when there's an error invokingMBeanServerConnectionJMException- JMX checked exception, because most requests are handled by dealing with MBeansJMRuntimeException- JMX unchecked exception, because most requests are handled by dealing with MBeansorg.jolokia.server.core.request.NotChangedException- when (according to request parameters) user wants HTTP 304 if nothing has changedorg.jolokia.server.core.request.BadRequestException- because some commands do more user input parsing in addition to what was checked when theJolokiaRequestwas createdorg.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 previousRequestHandlerat once for processing the request (like need for merging info as for alistcommand). This method is only called whenhandleAllServersAtOnce(JolokiaRequest)returnstrue- Parameters:
pServerManager- server manager holding all MBeans servers detectedrequest- request to processpPreviousResult- a previous result which for merging requests can be used to merge files- Returns:
- the object found
- Throws:
IOExceptionJMException- for any JMX exceptionorg.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) failsorg.jolokia.server.core.request.EmptyResponseException- for Jolokia notification stream handling
-
init
Lifecycle method in order to initialize the handler- Parameters:
pContext- the jolokia contextpProvider- provider to use for returned names. Handlers can use this for returning meta data with the proper provider prefixed.
-
destroy
Lifecycle method called when agent goes down. Should be overridden by a handler if required.- Throws:
JMException
-