Class ResourceMgr

java.lang.Object
org.aksw.commons.util.lifecycle.ResourceMgr
All Implemented Interfaces:
AutoCloseable

public class ResourceMgr extends Object implements AutoCloseable
A class where resources can be added. Upon closing the resource manager, all registered resources will be freed.
  • Constructor Details

    • ResourceMgr

      public ResourceMgr()
  • Method Details

    • register

      public <T extends AutoCloseable> T register(T closable)
    • register

      public <T> T register(T obj, FinallyRunAll.ThrowingConsumer<? super T> closer)
    • register

      public <T> T register(T obj, ThrowingRunnable closeAction)
      If the resource manager has already been closed then resources are immediately closed upon registration.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • isClosed

      public boolean isClosed()
    • toPath

      public static Path toPath(ResourceMgr resourceMgr, Class<?> clz, String classPath) throws IOException
      Create a path and register the filesystem with the resource manager.
      Throws:
      IOException
    • toPath

      public static Path toPath(ResourceMgr resourceMgr, URL url) throws IOException
      Create a path and register the filesystem with the resource manager.
      Throws:
      IOException
    • toPath

      public static Path toPath(ResourceMgr resourceMgr, URI uri) throws IOException
      Create a path and register the filesystem with the resource manager.
      Throws:
      IOException
    • fixPath

      public static Path fixPath(Path path)