Interface Closable

All Known Subinterfaces:
BidirectionalConnectionComponent<INPUT,​OUTPUT>, BidirectionalConnectionComponent.BidirectionalConnectionAutomaton<INPUT,​OUTPUT>, Closable.CloseAutomaton, CompositeComponent, CompositeComponent.ExtendedCompositeComponent<CTX,​CON>, ConnectableComponent, ConnectableComponent.ConnectableAutomaton, ConnectionComponent<CON>, ConnectionComponent.ConnectionAutomaton<CON>, ConnectionComponent.ConnectionComponentBuilder<CON,​B>, LinkComponent, LinkComponent.LinkAutomaton, LinkComponent.LinkComponentBuilder<B>
All Known Implementing Classes:
AbstractConnectableAutomaton, AbstractDeviceAutomaton, CompositeComponentImpl, CompositeComponentImpl.ExtendedCompositeComponentImpl, ConnectionAutomatonImpl, LinkAutomatonImpl

public interface Closable
This mixin might be implemented by a component in order to provide closing connection(s) facilities.
  • Nested Class Summary

    Nested Classes
    Modifier and Type Interface Description
    static interface  Closable.CloseAutomaton
    The Closable.CloseAutomaton interface defines those methods related to the closing of connection(s) life-cycle.
    static interface  Closable.CloseBuilder<B extends Closable.CloseBuilder<B>>
    To enable the Closable functionality to be invoked in a builder chain.
  • Method Summary

    Modifier and Type Method Description
    void close()
    Closes the component's connection(s).
    default void closeIn​(int aCloseInMillis)
    Tries to close the component's connection(s) after the given time in milliseconds.
    default void closeQuietly()
    Tries to close the component's connection(s).
    default void closeUnchecked()
    Closes the component by calling close() without you to require catching an IOException.
  • Method Details

    • close

      void close() throws IOException
      Closes the component's connection(s). Throws a IOException as upon close we may have to do things like flushing buffers which can fail (and would otherwise fail unhandled or even worse unnoticed).
      Throws:
      IOException - thrown in case closing failed.
    • closeUnchecked

      default void closeUnchecked()
      Closes the component by calling close() without you to require catching an IOException.
      Throws:
      org.refcodes.exception.IORuntimeException - encapsulates the cause and is thrown upon encountering a IOException exception
    • closeQuietly

      default void closeQuietly()
      Tries to close the component's connection(s). Ignores any problems which normally would be reported by the close() method with an according exception. The default implementation tries to invoke a "flush()" in case the implementing instance implements the Flushable interface before invoking close(). Additionally the default implementation tries IoRetryCount.NORM number of times to invoke close() till a timeout of IoTimeout.NORM is reached. In any case this method will return quietly without throwing any exception.
    • closeIn

      default void closeIn​(int aCloseInMillis)
      Tries to close the component's connection(s) after the given time in milliseconds. This method doesn't throw an exception as it immediately returns and closes after the given time expired. In case of an exception it will be wrapped in a HiddenException. Use (if implemented) ClosedAccessor.isClosed() to finally determine whether the close operation succeeded.
      Parameters:
      aCloseInMillis - The time in milliseconds to pass till close() is called.