Interface ICloseableInstance<T>

  • Type Parameters:
    T - the type of service
    All Superinterfaces:
    AutoCloseable

    public interface ICloseableInstance<T>
    extends AutoCloseable

    Provides a wrapper of instance created by IProcessManager.getInstance(String, Class) method which implements AutoCloseable. An instance of this interface should be obtained by IProcessManager.getCloseableInstance(String, Class) method. The close() method disposes wrapped instance from process manager with that the instance was created.

    An example of using:

     
     try (ICloseableInstance<YourService> closeableInstance = processManager.getCloseableInstance(key, YourService.class))
     {
           YourService service = closeableInstance.getInstance();
    
           // Do something with service
           // ...
     }
     catch (IllegalStateException e){...}
     catch (RemoteException e){...}
     catch (InstantiationException e){...}
     catch (IllegalAccessException e){...}
     catch (URISyntaxException e){...}
     catch (IOException e){...}
     catch (InterruptedException e){...}
     
     

    See Also:
    IProcessManager.getCloseableInstance(String, Class)
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void close()
      Disposes the wrapped instance from process manager with that this instance was created.
      T getInstance()
      Returns a wrapped instance of T service.
    • Method Detail

      • getInstance

        T getInstance()

        Returns a wrapped instance of T service.

        Returns:
        a wrapped instance of T service
      • close

        void close()

        Disposes the wrapped instance from process manager with that this instance was created.

        Specified by:
        close in interface AutoCloseable