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
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of the special, optional resource context, representing the whole OSGi framework.static final StringThe name of the CPU resource type, used to monitor and control the CPU time used by a resource context.static final StringThe 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 StringThe name of the memory resource type, used to monitor and control the size of the java heap used by a resource context.static final StringThe name of the socket resource type, used to monitor and control the number of existing sockets used by a resource context.static final StringThe name of the threads resource type, used to monitor and control the number of threads created by a resource context.static final StringThe 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 theResourceContextassociated 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.ResourceMonitoringServiceimplementations must createThreadMonitorinstances 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.ResourceMonitoringServiceimplementations must createCPUMonitorinstances 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.ResourceMonitoringServiceimplementations must createDiskStorageMonitorinstances 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.ResourceMonitoringServiceimplementations must createMemoryMonitorinstances 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.ResourceMonitoringServiceimplementations must createSocketMonitorinstances 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_NAMEcontext and theSYSTEM_CONTEXT_NAMEcontext, if it is supported.- Returns:
- An array of
ResourceContextobjects, or an empty array, if no contexts have been created.
-
createContext
Creates a newResourceContext.A
ResourceContextEventwith typeResourceContextEvent.RESOURCE_CONTEXT_CREATEDwill 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
ResourceContextinstance. - 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
ResourceContextwith the specified name, or null if such a context doesn't exist
-
getContext
Returns theResourceContextassociated to the provided bundle id.- Parameters:
bundleId- bundle identifier- Returns:
- the
ResourceContextassociated 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
ResourceMonitoringServiceimplementation supports.
-