Class ScopedServiceFactory

java.lang.Object
net.fabricmc.loom.util.service.ScopedServiceFactory
All Implemented Interfaces:
Closeable, AutoCloseable, ServiceFactory

public class ScopedServiceFactory extends Object implements ServiceFactory, Closeable
An implementation of ServiceFactory that creates services scoped to the factory instance. When the factory is closed, all services created by it are closed and discarded.
  • Constructor Details

    • ScopedServiceFactory

      public ScopedServiceFactory()
  • Method Details

    • get

      public <O extends Service.Options, S extends Service<O>> S get(O options)
      Description copied from interface: ServiceFactory
      Gets or creates a service instance with the given options.
      Specified by:
      get in interface ServiceFactory
      Type Parameters:
      O - The options type.
      S - The service type.
      Parameters:
      options - The options to use.
      Returns:
      The service instance.
    • getEffectiveServiceFactory

      @VisibleForTesting protected ServiceFactory getEffectiveServiceFactory()
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException