Class ResourceManager

java.lang.Object
com.viam.sdk.core.resource.ResourceManager
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
Server

public class ResourceManager extends Object implements Closeable
Manager containing all resources registered to this server.
  • Field Details

  • Constructor Details

    • ResourceManager

      public ResourceManager(List<Resource> resources)
  • Method Details

    • add

      public void add(Resource resource) throws DuplicateResourceException
      Adds a new resource with the manager. Resources may not have the same name. If a resource is remote and the short name is unique, save a short name version.
      Parameters:
      resource - The resource to add
      Throws:
      DuplicateResourceException
    • getResource

      public <ResourceT> ResourceT getResource(Class<ResourceT> resourceClass, Common.ResourceName name)
      Return a resource from the manager. If a unique short name version is given, return a remote resource with the name.
      Type Parameters:
      ResourceT - The type of the resource
      Parameters:
      name - The name of the resource
      Returns:
      The resource
    • removeResource

      public void removeResource(Common.ResourceName name)
      Remove the resource with the specified ResourceName.
      Parameters:
      name - The ResourceName of the resource
    • isManaging

      public boolean isManaging(Common.ResourceName name)
    • resourceNames

      public Set<Common.ResourceName> resourceNames()
    • close

      public void close()
      Close the resource manager by removing all resources. Please note that any errors will not throw an exception. Errors will still be logged.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable