Class JolokiaServiceManagerImpl
java.lang.Object
org.jolokia.server.core.service.impl.JolokiaServiceManagerImpl
- All Implemented Interfaces:
JolokiaServiceManager
The service manager for handling all the service organisation stuff.
- Since:
- 28.03.13
- Author:
- roland
-
Constructor Summary
ConstructorsConstructorDescriptionJolokiaServiceManagerImpl(Configuration pConfig, LogHandler pLogHandler, Restrictor pRestrictor, ServerDetectorLookup pDetectorLookup) Create the implementation of a service manager -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddService(JolokiaService<?> pService) Add a single service.voidaddServiceLookup(JolokiaServiceLookup pLookup) Add a service factory for dynamically looking up services.voidaddServices(JolokiaServiceCreator pServiceCreator) AJolokiaServiceCreatoris responsible for creating one or more service.Return the details of this agentGet the overall configurationGet the loghandler used for loggingGet the restrictor<T extends JolokiaService<?>>
TgetService(Class<T> pType) Get a single service.<T extends JolokiaService<?>>
SortedSet<T>getServices(Class<T> pType) Get all services of a certain type currently registered.final ObjectNameregisterMBean(Object pMBean, String... pOptionalName) Register a MBean under a certain name to the platform MBeanServer.start()Start up the service manager.voidstop()Stop the service manager and all services by calling their lifecycle methodsJolokiaService.destroy()andJolokiaServiceLookup.destroy()on all static and dynamic services.final voidunregisterMBean(ObjectName pObjectName) Unregister an MBean which has been registered formerly via the registry
-
Constructor Details
-
JolokiaServiceManagerImpl
public JolokiaServiceManagerImpl(Configuration pConfig, LogHandler pLogHandler, Restrictor pRestrictor, ServerDetectorLookup pDetectorLookup) Create the implementation of a service manager- Parameters:
pConfig- configuration to usepLogHandler- the loggerpRestrictor- restrictor to applypDetectorLookup- additional lookup server detectors when the services start (in addition to the classpath based lookup) These detectors while have a higher precedence than the classpath based lookup. Might be null.
-
-
Method Details
-
getConfiguration
Get the overall configuration- Returns:
- configuration
-
getLogHandler
Get the loghandler used for logging- Returns:
- loghandler
-
getRestrictor
Get the restrictor- Returns:
- restrictor
-
addService
Add a single service. This service is static in so far as it is in use until the end of this service manager- Specified by:
addServicein interfaceJolokiaServiceManager- Parameters:
pService- service to add
-
addServiceLookup
Add a service factory for dynamically looking up services. This is especially useful when services can come and go dynamically.JolokiaServiceLookup.getServices(Class)will be always called when looking up services within the core.- Specified by:
addServiceLookupin interfaceJolokiaServiceManager- Parameters:
pLookup- lookup for services to add.
-
addServices
AJolokiaServiceCreatoris responsible for creating one or more service. These will be created right during this call and have the same lifecycle as static services added withJolokiaServiceManager.addService(JolokiaService)- Specified by:
addServicesin interfaceJolokiaServiceManager- Parameters:
pServiceCreator- creator for creating the service
-
start
Start up the service manager. All static services are initialized via its lifecycle methodJolokiaService.init(JolokiaContext). For dynamic services, the lookup service obtains a handle to the createdJolokiaContextviaJolokiaServiceLookup.init(JolokiaContext). This method is omnipotent as it can be called multiple in sequence returning always the sameJolokiaContext.- Specified by:
startin interfaceJolokiaServiceManager- Returns:
- the created jolokia context which can be used directly
-
stop
public void stop()Stop the service manager and all services by calling their lifecycle methodsJolokiaService.destroy()andJolokiaServiceLookup.destroy()on all static and dynamic services. The Jolokia context returned on start is not valid anymore.- Specified by:
stopin interfaceJolokiaServiceManager
-
getServices
Get all services of a certain type currently registered. Static services are returned directly, for dynamic services a lookup to the service factory is performed.- Parameters:
pType- service type to fetch- Returns:
- set of services detected or an empty list
-
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
-
getAgentDetails
Return the details of this agent- Returns:
- the nifty details
-
registerMBean
public final ObjectName registerMBean(Object pMBean, String... pOptionalName) throws MalformedObjectNameException, NotCompliantMBeanException, InstanceAlreadyExistsException, MBeanRegistrationException Register a MBean under a certain name to the platform MBeanServer. This method delegates to theMBeanRegistry.- 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 which has been registered formerly via the registry- Parameters:
pObjectName- MBean to unregister- Throws:
MBeanRegistrationException
-