public 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.
Modifier and Type | Method and Description |
---|---|
void |
addBundle(long bundleId)
Adds a bundle to the resource context.
|
void |
addResourceMonitor(ResourceMonitor resourceMonitor)
Adds a new ResourceMonitor instance monitoring resource for this resource
context.
|
boolean |
equals(Object resourceContext)
A ResourceContext rc1 is equals to ResourceContext rc2 if rc1.getName()
is equals to rc2.getName().
|
long[] |
getBundleIds()
Returns the bundle identifiers belonging to this Resource Context.
|
ResourceMonitor |
getMonitor(String resourceType)
Returns a ResourceMonitor instance for the specified resource type.
|
ResourceMonitor[] |
getMonitors()
Retrieves all the existing ResourceMonitor belonging to this context.
|
String |
getName()
Returns the name of the resource context.
|
int |
hashCode()
Retrieves the hashCode value of a ResourceContext.
|
void |
removeBundle(long bundleId)
Removes the bundle identified by bundleId from the Resource Context.
|
void |
removeBundle(long bundleId,
ResourceContext destination)
Removes the bundle from this resource context.
|
void |
removeContext(ResourceContext destination)
Removes a resource context.
|
void |
removeResourceMonitor(ResourceMonitor resourceMonitor)
Removes a ResourceMonitor instance from the context.
|
String getName()
long[] getBundleIds()
Bundle
objects, or an empty array if no
bundles are currently members of this contextvoid addBundle(long bundleId) throws ResourceContextException
removeBundle(long)
method or
removeBundle(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 ResourceContextEvent
with type
ResourceContextEvent.BUNDLE_ADDED
will be sent.
bundleId
- The bundle to add to this resource contextResourceContextException
- For example, when the bundle can't be
added to the ResourceContext.void removeBundle(long bundleId) throws ResourceContextException
bundleId
- bundle identifierResourceContextException
- For example, when the bundle can't be
removed from the ResourceContext.void removeBundle(long bundleId, ResourceContext destination) throws ResourceContextException
destination
context 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 ResourceContextEvent
with type
ResourceContextEvent.BUNDLE_REMOVED
will be sent.
bundleId
- the identifier of the bundle to be removed from the
Resource Contextdestination
- 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.ResourceContextException
- For example, when the bundle can't be
removed from the ResourceContext.ResourceMonitor getMonitor(String resourceType) throws ResourceContextException
ResourceMonitoringService
implementation does not support
this resource type, null is returnedresourceType
- The resource type, for which a resource monitor is
requestedResourceContextException
- For example, when the monitor(s) can't
be retrieved from the ResourceContext.ResourceMonitor[] getMonitors() throws ResourceContextException
ResourceContextException
- For example, when the monitor(s) can't
be retrieved from the ResourceContext.void addResourceMonitor(ResourceMonitor resourceMonitor) throws ResourceContextException
resourceMonitor
- resourceMonitor instance to be addedResourceContextException
- For example, when the monitor can't be
added to the ResourceContext.void removeResourceMonitor(ResourceMonitor resourceMonitor) throws ResourceContextException
resourceMonitor
- resource monitor instance to be removedResourceContextException
- For example, when the monitor can't be
removed from the ResourceContext.void removeContext(ResourceContext destination) throws ResourceContextException
destination
context. If
destination
is null
, these resources will no
longer be monitored.
A ResourceContextEvent
with type
ResourceContextEvent.RESOURCE_CONTEXT_REMOVED
will be sent.
destination
- The ResourceContext
where the resources
currently allocated by this resource context will be moved.ResourceContextException
- For example, when the resource context
can't be removed.boolean equals(Object resourceContext)
Copyright © OSGi Alliance (2000, 2015). All Rights Reserved. Licensed under the OSGi Specification License, Version 2.0