Package org.marketcetera.util.file
Class CloseableRegistry
- java.lang.Object
-
- org.marketcetera.util.file.CloseableRegistry
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class CloseableRegistry extends Object implements Closeable
A registry ofCloseableinstances.- Since:
- 0.5.0
- Version:
- $Id: CloseableRegistry.java 16154 2012-07-14 16:34:05Z colin $
- Author:
- tlerios@marketcetera.com
-
-
Field Summary
Fields Modifier and Type Field Description private LinkedList<Closeable>mRegistry
-
Constructor Summary
Constructors Constructor Description CloseableRegistry()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes allCloseableinstances registered with the receiver.voidregister(Closeable closeable)Registers aCloseableinstance with the receiver.
-
-
-
Field Detail
-
mRegistry
private LinkedList<Closeable> mRegistry
-
-
Method Detail
-
register
public void register(Closeable closeable)
Registers aCloseableinstance with the receiver. An instance (dependent) that depends upon another instance (parent) must be registered after the parent.- Parameters:
closeable- The closeable.
-
close
public void close()
Closes allCloseableinstances registered with the receiver. All instances are always closed, even if an error occurs while closing an instance; such errors are merely logged, but do not prevent further closures. The order of closures is the reverse of the registration order.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
-