Package de.aristaflow.adept2.util.io
Class RereadableContent.RrcCleanup
java.lang.Object
de.aristaflow.adept2.util.CleanupTask.AbstractCleanupTask<IOException>
de.aristaflow.adept2.util.io.RereadableContent.RrcCleanup
- All Implemented Interfaces:
CleanupTask<IOException>
- Enclosing class:
- RereadableContent
protected static final class RereadableContent.RrcCleanup
extends CleanupTask.AbstractCleanupTask<IOException>
The
An instance of this class exists for each
CleanupTask doing the clean-up (RereadableContent.close()) independently from the
RereadableContent. This allows to use it as post-mortem action of the
RereadableContent. An instance of this class exists for each
RereadableContent and for each of its
input streams. When closing or cleaning-up as post-mortem
action, the corresponding instance will be deregistered. If no instance exists for a
RereadableContent, its final clean-up will occur, for instance, the temporary file
will be deleted. Instance tracking is done via an arbitrary Object but since the
cleanup is referenced by the corresponding instance of InputStream (or
RereadableContent) via Cleaner the Object can
be kept internal to this clean-up task.-
Nested Class Summary
Nested classes/interfaces inherited from interface de.aristaflow.adept2.util.CleanupTask
CleanupTask.AbstractCleanupTask<EX extends Exception>, CleanupTask.AtomicCloseTask, CleanupTask.CloseAndResetTask, CleanupTask.MutableCloseTask -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Collection<Object>All objects for which streams (rather their clean-up tasks) have been created.protected final CloseableThe final clean-up to be executed after all streams and theRereadableContentitself have been closed/cleaned up.protected final ObjectThe (object of the) stream for which thisCleanupTaskhas been registered.Fields inherited from class de.aristaflow.adept2.util.CleanupTask.AbstractCleanupTask
descriptor, logger -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRrcCleanup(String descriptor, RereadableContent rc) Creates a new clean-up for closing as post-mortem action of aRereadableContentor a created input stream. -
Method Summary
Methods inherited from class de.aristaflow.adept2.util.CleanupTask.AbstractCleanupTask
getDescriptor
-
Field Details
-
existingStreams
All objects for which streams (rather their clean-up tasks) have been created. Each clean-up task removes its object. As soon as this collection is empty, theRereadableContentis not used any more (or may not even exist any more) and the final cleanup may take place. -
stream
The (object of the) stream for which thisCleanupTaskhas been registered. This allows to track existing input streams. -
finalCleanup
The final clean-up to be executed after all streams and theRereadableContentitself have been closed/cleaned up.
-
-
Constructor Details
-
RrcCleanup
Creates a new clean-up for closing as post-mortem action of aRereadableContentor a created input stream. Also used for RereadableContent.close() explicit clean-up.- Parameters:
descriptor- A string meaningfully describing the cleanup.rc- TheRereadableContentproviding theexistingStreamsto prevent early clean-up as well as the final clean-up.
-
-
Method Details
-
cleanup
Description copied from interface:CleanupTaskPerforms the actual clean-up. This method is only called byCleanupand must NOT be called directly!- Parameters:
explicit- Whether the clean-up was triggered explicitly viaCleanup.clean(). Otherwise it was triggered implicitly as a post-mortem action by the object becoming phantom reachable.- Throws:
IOException
-