Interface ResourceContext
 Resource Monitoring Clients can use the
 ResourceMonitoringService.createContext(String, ResourceContext)
 method to create ResourceContext instances.
 
 
 Resource Monitoring Clients can use the getMonitor(String) method to
 get ResourceMonitor instances for the supported resource types. These
 instances can then be used to monitor the usage of the resources, or the set
 usage limits.
 
 
 ResourceContexts are retrieved through the ResourceMonitoringService
 OSGi service.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddBundle(long bundleId) Adds a bundle to the resource context.voidaddResourceMonitor(ResourceMonitor<?> resourceMonitor) Adds a new ResourceMonitor instance monitoring resource for this resource context.booleanA ResourceContext rc1 is equals to ResourceContext rc2 if rc1.getName() is equals to rc2.getName().long[]Returns the bundle identifiers belonging to this Resource Context.getMonitor(String resourceType) Returns a ResourceMonitor instance for the specified resource type.ResourceMonitor<?>[]Retrieves all the existing ResourceMonitor belonging to this context.getName()Returns the name of the resource context.inthashCode()Retrieves the hashCode value of a ResourceContext.voidremoveBundle(long bundleId) Removes the bundle identified by bundleId from the Resource Context.voidremoveBundle(long bundleId, ResourceContext destination) Removes the bundle from this resource context.voidremoveContext(ResourceContext destination) Removes a resource context.voidremoveResourceMonitor(ResourceMonitor<?> resourceMonitor) Removes a ResourceMonitor instance from the context.
- 
Method Details- 
getNameString getName()Returns the name of the resource context. Resource context names are unique within a framework instance.- Returns:
- The resource context name
 
- 
getBundleIdslong[] getBundleIds()Returns the bundle identifiers belonging to this Resource Context.- Returns:
- An array of Bundleobjects, or an empty array if no bundles are currently members of this context
 
- 
addBundleAdds a bundle to the resource context. The bundle will be a member of the context until it is uninstalled, or explicitly removed from the context withremoveBundle(long)method orremoveBundle(long, ResourceContext)method.Resources previously allocated by this bundle (in another resource context) will not be moved to this resource context. The change applies only for future allocations. A ResourceContextEventwith typeResourceContextEvent.BUNDLE_ADDEDwill be sent.- Parameters:
- bundleId- The bundle to add to this resource context
- Throws:
- ResourceContextException- For example, when the bundle can't be added to the ResourceContext.
 
- 
removeBundleRemoves the bundle identified by bundleId from the Resource Context. The bundle is no longer to this Resource Context.- Parameters:
- bundleId- bundle identifier
- Throws:
- ResourceContextException- For example, when the bundle can't be removed from the ResourceContext.
 
- 
removeBundleRemoves the bundle from this resource context. If adestinationcontext is specified, the bundle will be added in it.Resources previously allocated by this bundle will not be removed from the resource context. The change applies only for future allocations. A ResourceContextEventwith typeResourceContextEvent.BUNDLE_REMOVEDwill be sent.- Parameters:
- bundleId- the identifier of the bundle to be removed from the Resource Context
- destination- A resource context in which to add the bundle, after removing it from this context. If no destination is provided (that is null), the bundle is not associated to a new Resource Context.
- Throws:
- ResourceContextException- For example, when the bundle can't be removed from the ResourceContext.
 
- 
getMonitorReturns a ResourceMonitor instance for the specified resource type. If theResourceMonitoringServiceimplementation does not support this resource type, null is returned- Parameters:
- resourceType- The resource type, for which a resource monitor is requested
- Returns:
- A ResourceMonitor instance, or null, if this resource type is not supported
- Throws:
- ResourceContextException- For example, when the monitor(s) can't be retrieved from the ResourceContext.
 
- 
getMonitorsRetrieves all the existing ResourceMonitor belonging to this context.- Returns:
- an array of ResourceMonitor. May be empty if no ResourceMonitor
- Throws:
- ResourceContextException- For example, when the monitor(s) can't be retrieved from the ResourceContext.
 
- 
addResourceMonitorAdds a new ResourceMonitor instance monitoring resource for this resource context. This method should be called only by ResourceMonitorFactory instance.- Parameters:
- resourceMonitor- resourceMonitor instance to be added
- Throws:
- ResourceContextException- For example, when the monitor can't be added to the ResourceContext.
 
- 
removeResourceMonitorRemoves a ResourceMonitor instance from the context.- Parameters:
- resourceMonitor- resource monitor instance to be removed
- Throws:
- ResourceContextException- For example, when the monitor can't be removed from the ResourceContext.
 
- 
removeContextRemoves a resource context. All resources allocated in this resource context will be moved to thedestinationcontext. Ifdestinationisnull, these resources will no longer be monitored.A ResourceContextEventwith typeResourceContextEvent.RESOURCE_CONTEXT_REMOVEDwill be sent.- Parameters:
- destination- The- ResourceContextwhere the resources currently allocated by this resource context will be moved.
- Throws:
- ResourceContextException- For example, when the resource context can't be removed.
 
- 
equalsA ResourceContext rc1 is equals to ResourceContext rc2 if rc1.getName() is equals to rc2.getName().
- 
hashCodeint hashCode()Retrieves the hashCode value of a ResourceContext. The hashCode value of a ResourceContext is only based on the hashcode value of the name of the context.
 
-