@Internal public class CloseableRegistry extends AbstractAutoCloseableRegistry<Closeable,Closeable,Object,IOException> implements Closeable
Closeable
, which are all closed if this
registry is closed.
Registering to an already closed registry will throw an exception and close the provided
Closeable
All methods in this class are thread-safe.
This class closes all registered Closeable
s in the reverse registration order.
closeableToRef
Constructor and Description |
---|
CloseableRegistry() |
Modifier and Type | Method and Description |
---|---|
void |
doClose(List<Closeable> toClose)
This implementation doesn't imply any exception during closing due to backward compatibility.
|
protected void |
doRegister(Closeable closeable,
Map<Closeable,Object> closeableMap)
Does the actual registration of the closeable with the registry map.
|
protected boolean |
doUnRegister(Closeable closeable,
Map<Closeable,Object> closeableMap)
Does the actual un-registration of the closeable from the registry map.
|
void |
unregisterAndCloseAll(Closeable... toUnregisterAndClose)
Unregisters all given
Closeable objects from this registry and closes all objects
that are were actually registered. |
close, getNumberOfRegisteredCloseables, getSynchronizationLock, isCloseableRegistered, isClosed, registerCloseable, removeCloseableInternal, unregisterCloseable
protected void doRegister(@Nonnull Closeable closeable, @Nonnull Map<Closeable,Object> closeableMap)
AbstractAutoCloseableRegistry
doRegister
in class AbstractAutoCloseableRegistry<Closeable,Closeable,Object,IOException>
protected boolean doUnRegister(@Nonnull Closeable closeable, @Nonnull Map<Closeable,Object> closeableMap)
AbstractAutoCloseableRegistry
doUnRegister
in class AbstractAutoCloseableRegistry<Closeable,Closeable,Object,IOException>
public void doClose(List<Closeable> toClose) throws IOException
doClose
in class AbstractAutoCloseableRegistry<Closeable,Closeable,Object,IOException>
IOException
public void unregisterAndCloseAll(Closeable... toUnregisterAndClose) throws IOException
Closeable
objects from this registry and closes all objects
that are were actually registered. Suppressed (and collects) all exceptions that happen
during closing and throws only when the all Closeable
objects have been processed.toUnregisterAndClose
- closables to unregister and close.IOException
- collects all exceptions encountered during closing of the given objects.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.