Class JolokiaContextImpl
java.lang.Object
org.jolokia.server.core.service.impl.JolokiaContextImpl
- All Implemented Interfaces:
JolokiaContext,LogHandler,Restrictor
Central implementation of the
JolokiaContext- Since:
- 09.04.13
- Author:
- roland
-
Method Summary
Modifier and TypeMethodDescriptionvoidLog a debug messagesvoidLog an errorGet 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.voidLog informal messagebooleanisAttributeReadAllowed(ObjectName pName, String pAttribute) Check whether reading of an attribute is allowedbooleanisAttributeWriteAllowed(ObjectName pName, String pAttribute) Check whether writing of an attribute is allowedbooleanisDebug()Check whether debug is switched onbooleanisHttpMethodAllowed(HttpMethod pMethod) Check whether the HTTP method with which the request was sent is allowed.booleanisOperationAllowed(ObjectName pName, String pOperation) Check whether execution of an operation is allowedbooleanisOriginAllowed(String pOrigin, boolean pStrictCheck) Check whether cross browser access via CORS is allowed.booleanisRemoteAccessAllowed(String... pHostOrAddress) Check whether access from the connected client is allowed.booleanisTypeAllowed(RequestType pType) Check whether the provided command type is allowed in principalregisterMBean(Object pMBean, String... pOptionalName) Register an MBean which gets automatically unregistered during shutdown.voidsetDebugStore(DebugStore debugStore) voidunregisterMBean(ObjectName pObjectName) Unregister an MBean explicitly.
-
Method Details
-
setDebugStore
-
registerMBean
public ObjectName registerMBean(Object pMBean, String... pOptionalName) throws MalformedObjectNameException, NotCompliantMBeanException, InstanceAlreadyExistsException, MBeanRegistrationException Register an MBean which gets automatically unregistered during shutdown.- Specified by:
registerMBeanin interfaceJolokiaContext- 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- Specified by:
unregisterMBeanin interfaceJolokiaContext- Parameters:
pObjectName- name of the mbean to unregister- Throws:
MBeanRegistrationException
-
getMBeanServerAccess
Get anMBeanServerAccessfor easy access of the JMX subsystem even when there are multiple MBeanServers available. It uses a template mechanism with callback- Specified by:
getMBeanServerAccessin interfaceJolokiaContext- Returns:
- the executor to use
-
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.- Specified by:
getAgentDetailsin interfaceJolokiaContext- Returns:
- the details for this agent.
-
getConfig
Get a configuration value if set as configuration or the default value if not- Specified by:
getConfigin interfaceJolokiaContext- Parameters:
pOption- 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- Specified by:
getConfigin interfaceJolokiaContext- Parameters:
pOption- 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- Specified by:
getConfigKeysin interfaceJolokiaContext
-
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()).- Specified by:
getServicesin interfaceJolokiaContext- 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- Specified by:
getServicein interfaceJolokiaContext- 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- Specified by:
getMandatoryServicein interfaceJolokiaContext- Parameters:
pType- requested service type- Returns:
- the requested service
-
isDebug
public boolean isDebug()Check whether debug is switched on- Specified by:
isDebugin interfaceLogHandler- Returns:
- true if debugging is enabled
-
debug
Log a debug messages- Specified by:
debugin interfaceLogHandler- Parameters:
message- debug message
-
info
Log informal message- Specified by:
infoin interfaceLogHandler- Parameters:
message- message to log
-
error
Log an error- Specified by:
errorin interfaceLogHandler- Parameters:
message- error messaget- exception causing this error
-
isHttpMethodAllowed
Check whether the HTTP method with which the request was sent is allowed.- Specified by:
isHttpMethodAllowedin interfaceRestrictor- Parameters:
pMethod- method to check- Returns:
- true if there is no restriction on the method with which the request was sent, false otherwise
-
isTypeAllowed
Check whether the provided command type is allowed in principal- Specified by:
isTypeAllowedin interfaceRestrictor- Parameters:
pType- type to check- Returns:
- true, if the type is allowed, false otherwise
-
isAttributeReadAllowed
Check whether reading of an attribute is allowed- Specified by:
isAttributeReadAllowedin interfaceRestrictor- Parameters:
pName- MBean namepAttribute- attribute to check- Returns:
- true if access is allowed
-
isAttributeWriteAllowed
Check whether writing of an attribute is allowed- Specified by:
isAttributeWriteAllowedin interfaceRestrictor- Parameters:
pName- MBean namepAttribute- attribute to check- Returns:
- true if access is allowed
-
isOperationAllowed
Check whether execution of an operation is allowed- Specified by:
isOperationAllowedin interfaceRestrictor- Parameters:
pName- MBean namepOperation- attribute to check- Returns:
- true if access is allowed
-
isRemoteAccessAllowed
Check whether access from the connected client is allowed. If at least one of the given parameters matches, then this method returns true.- Specified by:
isRemoteAccessAllowedin interfaceRestrictor- Parameters:
pHostOrAddress- one or more host or address names.- Returns:
- true is access is allowed
-
isOriginAllowed
Check whether cross browser access via CORS is allowed. See the CORS specification for details- Specified by:
isOriginAllowedin interfaceRestrictor- Parameters:
pOrigin- the "Origin:" header provided within the requestpStrictCheck- whether by-pass check when strict checking is disabled- Returns:
- true if this cross browser request allowed, false otherwise
-