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| Constructor and Description |
|---|
ResourceManager() |
| Modifier and Type | Method and Description |
|---|---|
void |
addResource(Resource<L> newResource)
Adds the given resource to the resource hierarchy.
|
List<Resource<L>> |
findResources(L query,
LocationResolver<L> locationResolver)
Find the resources in
resourcesGraph matching the given query. |
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 or
null if there is no resource with
that ID. |
List<Resource<L>> |
getResourcesBreadthFirst()
|
Set<Resource<L>> |
getRootResources()
|
void |
logTreeGraph(String logMsg,
long duration) |
List<Resource<L>> |
removeResources(L query,
LocationResolver<L> locationResolver)
Remove the resources from
resourcesGraph matching the given query including all direct and
indirect descendants. |
void |
replaceResources(List<Resource<L>> newResources)
Replaces the set of
Resources currently available in resourcesGraph with the resources from the
given newResources list. |
public void addResource(Resource<L> newResource) throws IllegalArgumentException
newResource - the new resource to be addedIllegalArgumentException - if the new resource's parent does not yet exist in the hierarchypublic 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 returnedpublic Resource<L> getResource(ID resourceId)
null if there is no resource with
that ID.resourceId - the ID of the resource to retrievepublic List<Resource<L>> getResourcesBreadthFirst()
Resourcespublic 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 methodpublic void replaceResources(List<Resource<L>> newResources) throws IllegalArgumentException
Resources currently available in resourcesGraph with the resources from the
given newResources list. Note that this method eventually replaces the graph instance in
resourcesGraph together with neighborIndex and resourceCache.newResources - a List of resources to replace the set of Resources currently available in
resourcesGraph. newResources must be in breadth first orderIllegalArgumentException - if the parent of any of the added resources is not in the graph.Copyright © 2015 Red Hat, Inc.. All rights reserved.