Interface CloseableService


public interface CloseableService
A closeable service to add instances of Closeable that are required to be closed.

This interface may be injected onto server-side components using the Context annotation.

The service may be used within the scope of a request to add instances of Closeable that are to be closed when the request goes out of scope, more specifically after the request has been processed and the response has been returned.

Author:
Marek Potociar, Paul Sandoz
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Register a new instance of Closeable that is to be closed when the request goes out of scope.
    void
    Invokes Closeable#close() method on all instances of Closeable added by the #add(Closeable) method.
  • Method Details

    • add

      boolean add(Closeable c)
      Register a new instance of Closeable that is to be closed when the request goes out of scope.

      After close() has been called, this method will not accept any new instance registrations and will return false instead.

      Parameters:
      c - the instance of Closeable.
      Returns:
      true if the closeable service has not been closed yet and the closeable instance was successfully registered with the service, false otherwise.
    • close

      void close()
      Invokes Closeable#close() method on all instances of Closeable added by the #add(Closeable) method. Subsequent calls of this method should not do anything.