Interface ResourceMonitoringService
public interface ResourceMonitoringService
It manages the Resource Context instances. It is available through the OSGi
service registry.
This service holds the existing Resource Context instances. Resource Context
instances are created by calling the
createContext(String, ResourceContext)
method.-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The name of the special, optional resource context, representing the whole OSGi framework.static final String
The name of the CPU resource type, used to monitor and control the CPU time used by a resource context.static final String
The name of the disk storage resource type, used to monitor and control the size of the persistent storage used by a resource context.static final String
The name of the memory resource type, used to monitor and control the size of the java heap used by a resource context.static final String
The name of the socket resource type, used to monitor and control the number of existing sockets used by a resource context.static final String
The name of the threads resource type, used to monitor and control the number of threads created by a resource context.static final String
The name of the Resource Context associated with System bundle (bundle 0). -
Method Summary
Modifier and TypeMethodDescriptioncreateContext
(String name, ResourceContext template) Creates a newResourceContext
.getContext
(long bundleId) Returns theResourceContext
associated to the provided bundle id.getContext
(String name) Returns the context with the specified resource context name.String[]
Returns a list with the supported resource type names.Lists all availableresource contexts
.
-
Field Details
-
RES_TYPE_THREADS
The name of the threads resource type, used to monitor and control the number of threads created by a resource context.ResourceMonitoringService
implementations must createThreadMonitor
instances for this resource type.- See Also:
-
RES_TYPE_CPU
The name of the CPU resource type, used to monitor and control the CPU time used by a resource context.ResourceMonitoringService
implementations must createCPUMonitor
instances for this resource type.- See Also:
-
RES_TYPE_DISK_STORAGE
The name of the disk storage resource type, used to monitor and control the size of the persistent storage used by a resource context.ResourceMonitoringService
implementations must createDiskStorageMonitor
instances for this resource type.- See Also:
-
RES_TYPE_MEMORY
The name of the memory resource type, used to monitor and control the size of the java heap used by a resource context.ResourceMonitoringService
implementations must createMemoryMonitor
instances for this resource type.- See Also:
-
RES_TYPE_SOCKET
The name of the socket resource type, used to monitor and control the number of existing sockets used by a resource context.ResourceMonitoringService
implementations must createSocketMonitor
instances for this resource type.- See Also:
-
FRAMEWORK_CONTEXT_NAME
The name of the special, optional resource context, representing the whole OSGi framework.- See Also:
-
SYSTEM_CONTEXT_NAME
The name of the Resource Context associated with System bundle (bundle 0).- See Also:
-
-
Method Details
-
listContext
ResourceContext[] listContext()Lists all availableresource contexts
. The list will contain the specialFRAMEWORK_CONTEXT_NAME
context and theSYSTEM_CONTEXT_NAME
context, if it is supported.- Returns:
- An array of
ResourceContext
objects, or an empty array, if no contexts have been created.
-
createContext
Creates a newResourceContext
.A
ResourceContextEvent
with typeResourceContextEvent.RESOURCE_CONTEXT_CREATED
will be sent.- Parameters:
name
- The name identifying the context. Names must be unique within the framework instance.template
- If a template is provided, the new resource context will inherit all resource monitoring settings (enabled monitors, thresholds) from the template.- Returns:
- A new
ResourceContext
instance. - Throws:
IllegalArgumentException
- if a problem occurred, for example if the name is already used.
-
getContext
Returns the context with the specified resource context name.- Parameters:
name
- The resource context name- Returns:
- An existing
ResourceContext
with the specified name, or null if such a context doesn't exist
-
getContext
Returns theResourceContext
associated to the provided bundle id.- Parameters:
bundleId
- bundle identifier- Returns:
- the
ResourceContext
associated to bundle b or null if the bundle b does not belong to a Resource Context.
-
getSupportedTypes
String[] getSupportedTypes()Returns a list with the supported resource type names.- Returns:
- An array containing the names of all resource types that this
ResourceMonitoringService
implementation supports.
-