Interface JolokiaContext
- All Superinterfaces:
LogHandler,Restrictor
- All Known Implementing Classes:
JolokiaContextImpl
The context providing access to all Jolokia internal services. This context
will be given through during request handling to the various methods.
It is also a restrictor used for access restriction handling and responsible
for logging aspects.
- Since:
- 09.04.13
- Author:
- roland
-
Method Summary
Modifier and TypeMethodDescriptionGet the details which specify the current agent.Get a configuration value if set as configuration or the default value if notGet a configuration value if set as configuration or the default value if notGet all keys stored in this configuration<T extends JolokiaService<?>>
TgetMandatoryService(Class<T> pType) Get a single, mandatory, service.Get anMBeanServerAccessfor easy access of the JMX subsystem even when there are multiple MBeanServers available.<T extends JolokiaService<?>>
TgetService(Class<T> pType) Get a single service.<T extends JolokiaService<?>>
SortedSet<T>getServices(Class<T> pType) Get Jolokia services of a certain kind.registerMBean(Object pMBean, String... pOptionalName) Register an MBean which gets automatically unregistered during shutdown.voidunregisterMBean(ObjectName pObjectName) Unregister an MBean explicitly.Methods inherited from interface org.jolokia.server.core.service.api.LogHandler
debug, error, info, isDebugMethods inherited from interface org.jolokia.server.core.service.api.Restrictor
isAttributeReadAllowed, isAttributeWriteAllowed, isHttpMethodAllowed, isOperationAllowed, isOriginAllowed, isRemoteAccessAllowed, isTypeAllowed
-
Method Details
-
getServices
Get Jolokia services of a certain kind. The returned list might be empty, but never null. The set is sorted according to the service order (seeJolokiaService.getOrder()).- Parameters:
pType- requested service type- Returns:
- sorted set of services or an empty set
-
getService
Get a single service. If more than one service of the given type has been registered, return the one with the highest order. If no one has been registered returnnull- Parameters:
pType- requested service type- Returns:
- the requested service or null if none has been registered
-
getMandatoryService
Get a single, mandatory, service. If not present, then an exception is thrown. Also, an exception is raised if more than one service exist- Parameters:
pType- requested service type- Returns:
- the requested service
- Throws:
IllegalStateException- if no service is present
-
getConfig
Get a configuration value if set as configuration or the default value if not- Parameters:
pKey- the configuration key to lookup- Returns:
- the configuration value or the default value if no configuration was given.
-
getConfig
Get a configuration value if set as configuration or the default value if not- Parameters:
pKey- the configuration key to lookupcheckSysOrEnv- whether system property / environment variable should be checked first- Returns:
- the configuration value or the default value if no configuration was given.
-
getConfigKeys
Get all keys stored in this configuration -
getAgentDetails
AgentDetails getAgentDetails()Get the details which specify the current agent. The returned details should not be kept but instead each time details are needed this interface should be queried again.- Returns:
- the details for this agent.
-
registerMBean
ObjectName registerMBean(Object pMBean, String... pOptionalName) throws MalformedObjectNameException, NotCompliantMBeanException, InstanceAlreadyExistsException, MBeanRegistrationException Register an MBean which gets automatically unregistered during shutdown.- Parameters:
pMBean- MBean to registerpOptionalName- optional name under which the bean should be registered. If not provided, it depends on whether the MBean to register implementsMBeanRegistrationor not.- Returns:
- the name under which the MBean is registered.
- Throws:
MalformedObjectNameExceptionNotCompliantMBeanExceptionInstanceAlreadyExistsExceptionMBeanRegistrationException
-
unregisterMBean
Unregister an MBean explicitly. This is typically not necessary but becomes necessary if a module goes down without shutting down the agen- Parameters:
pObjectName- name of the mbean to unregister- Throws:
MBeanRegistrationException
-
getMBeanServerAccess
MBeanServerAccess getMBeanServerAccess()Get anMBeanServerAccessfor easy access of the JMX subsystem even when there are multiple MBeanServers available. It uses a template mechanism with callback- Returns:
- the executor to use
-