L - the type of the protocol specific location, typically a subclass of NodeLocationpublic final class ResourceManager<L> extends Object
ResourceManager rather provides
methods to retrieve data from the graph and to change the data in the graph.
Concurrency:
ResourceManager is immutable
ResourceManager uses a ReadWriteLock internally so that all public read and write operations can
be performed from concurrent threads| Modifier and Type | Class and Description |
|---|---|
static class |
ResourceManager.AddResult<L>
Indicates the results of the
addResource(Resource) method. |
| Constructor and Description |
|---|
ResourceManager() |
| Modifier and Type | Method and Description |
|---|---|
ResourceManager.AddResult<L> |
addResource(Resource<L> newResource)
Adds the given resource to the resource hierarchy, replacing the resource if it already exist but
has changed.
|
List<Resource<L>> |
findResources(L query,
LocationResolver<L> locationResolver)
Find the resources in
resourcesGraph matching the given query. |
List<Resource<L>> |
getAllResources(Collection<ID> filter) |
Set<Resource<L>> |
getChildren(Resource<L> resource)
Returns an immutable
Set of the direct children of the given resource. |
Resource<L> |
getParent(Resource<L> resource)
Returns the direct parent of the given resource.
|
Resource<L> |
getResource(ID resourceId)
Given a resource ID this will return the resource with that ID that is found in the internal
hierarchical graph or
null if there is no resource with that ID in the graph. |
List<Resource<L>> |
getResourcesBreadthFirst()
|
Set<Resource<L>> |
getRootResources()
|
void |
logTreeGraph(String logMsg,
long duration) |
List<Resource<L>> |
removeResource(Resource<L> doomedResource)
Remove the resource from
resourcesGraph, including all its descendants. |
List<Resource<L>> |
removeResources(L query,
LocationResolver<L> locationResolver)
Remove the resources from
resourcesGraph matching the given query including all direct and
indirect descendants. |
int |
size() |
int |
size(Resource<L> relativeTo) |
public int size()
public int size(Resource<L> relativeTo)
public ResourceManager.AddResult<L> addResource(Resource<L> newResource) throws IllegalArgumentException
effect has the following semantics:
resource is the resource object stored in the
internal hierarchical graph, which may or may not be the same as the newResource
that was passed into this method.newResource - the new resource to be addedIllegalArgumentException - if the new resource's parent does not yet exist in the hierarchypublic List<Resource<L>> removeResource(Resource<L> doomedResource)
resourcesGraph, including all its descendants.doomedResource - the resource to removeResources that were removed by this methodpublic List<Resource<L>> findResources(L query, LocationResolver<L> locationResolver)
resourcesGraph matching the given query.query - a location eventually containing wildcardslocationResolver - the LocationResolver to perform the matching of graph nodes against the given
queryResources that match the given querypublic Set<Resource<L>> getChildren(Resource<L> resource)
Set of the direct children of the given resource.resource - the resource whose children are to be returnedSet if direct children of the given resourcepublic Resource<L> getParent(Resource<L> resource)
resource - the resource whose parent is to be returnedIllegalArgumentException - if the resource itself is not found in the graphpublic Resource<L> getResource(ID resourceId)
null if there is no resource with that ID in the graph.resourceId - the ID of the resource to retrievenullpublic List<Resource<L>> getResourcesBreadthFirst()
Resourcespublic List<Resource<L>> getAllResources(Collection<ID> filter)
filter - if not null, any resources whose IDs are in here will not exist in the returned collectionpublic void logTreeGraph(String logMsg, long duration)
public List<Resource<L>> removeResources(L query, LocationResolver<L> locationResolver)
resourcesGraph matching the given query including all direct and
indirect descendants.query - a location eventually containing wildcardslocationResolver - the LocationResolver to perform the matching of graph nodes against the given
queryResources that were removed by this methodCopyright © 2015–2017 Red Hat, Inc.. All rights reserved.