- All Known Subinterfaces:
BidirectionalConnectionComponent<INPUT,,OUTPUT> BidirectionalConnectionComponent.BidirectionalConnectionAutomaton<INPUT,,OUTPUT> Closable.CloseAutomaton,ComponentComposite,ComponentComposite.ExtendedComponentComposite<CTX,,CON> ConnectableComponent,ConnectableComponent.ConnectableAutomaton,ConnectionComponent<CON>,ConnectionComponent.ConnectionAutomaton<CON>,ConnectionComponent.ConnectionComponentBuilder<CON,,B> LinkComponent,LinkComponent.LinkAutomaton,LinkComponent.LinkComponentBuilder<B>
- All Known Implementing Classes:
AbstractComponentComposite,AbstractComponentComposite.ExtendedCompositeComponentImpl,AbstractConnectableAutomaton,AbstractDeviceAutomaton,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 ClassesModifier and TypeInterfaceDescriptionstatic interfaceTheClosable.CloseAutomatoninterface defines those methods related to the closing of connection(s) life-cycle.static interfaceClosable.CloseBuilder<B extends Closable.CloseBuilder<B>>To enable theClosablefunctionality to be invoked in a builder chain. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the component's connection(s).default voidcloseIn(int aCloseMillis) Tries to close the component's connection(s) after the given time in milliseconds.default voidTries to close the component's connection(s).default voidCloses the component by callingclose()without you to require catching anIOException.
-
Method Details
-
close
Closes the component's connection(s). Throws aIOExceptionas 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 callingclose()without you to require catching anIOException.- Throws:
org.refcodes.exception.RuntimeIOException- encapsulates the aCause and is thrown upon encountering aIOExceptionexception
-
closeQuietly
default void closeQuietly()Tries to close the component's connection(s). Ignores any problems which normally would be reported by theclose()method with an according exception. The default implementation tries to invoke a "flush()" in case the implementing instance implements theFlushableinterface before invokingclose(). Additionally the default implementation triesIoRetryCount.NORMnumber of times to invokeclose()till a timeout ofIoTimeout.NORMis reached. In any case this method will return quietly without throwing any exception. -
closeIn
default void closeIn(int aCloseMillis) 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 anIOExceptionexception it will be wrapped in aRuntimeIOException. Use (if implemented)ClosedAccessor.isClosed()to finally determine whether the close operation succeeded.- Parameters:
aCloseMillis- The time in milliseconds to pass tillclose()is called.
-