Class CloseableReference
java.lang.Object
java.lang.ref.Reference<T>
java.lang.ref.WeakReference<AuthorityCodes>
org.apache.sis.referencing.factory.sql.CloseableReference
- All Implemented Interfaces:
Disposable
Closes JDBC statements when
AuthorityCodes
is garbage collected.
Those weak references are stored in the EPSGDataAccess.authorityCodes
map as cached values.
Connection is not closed by this class because they will be closed when EPSGDataAccess
will
be closed.- Since:
- 0.7
- Version:
- 1.2
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final EPSGDataAccess
The EPSG factory, used for synchronization lock.private final Statement[]
The statements to close. -
Constructor Summary
ConstructorsConstructorDescriptionCloseableReference
(AuthorityCodes ref, EPSGDataAccess factory, Statement[] statements) Creates a new phantom reference which will close the given statements when the given referenced object will be garbage collected. -
Method Summary
Methods inherited from class java.lang.ref.Reference
clear, clone, enqueue, get, isEnqueued, reachabilityFence, refersTo
-
Field Details
-
factory
The EPSG factory, used for synchronization lock. -
statements
The statements to close. Statements will be closed in reverse order, with null elements ignored. A synchronization lock will be hold on the array.
-
-
Constructor Details
-
CloseableReference
CloseableReference(AuthorityCodes ref, EPSGDataAccess factory, Statement[] statements) Creates a new phantom reference which will close the given statements when the given referenced object will be garbage collected.
-
-
Method Details
-
close
Closes the statements. If an exception occurred, it will be thrown only after all statements have been closed. The connection is not closed in this method because it will be closed later by (indirectly)ConcurrentAuthorityFactory.close(List)
.- Throws:
SQLException
- if an error occurred while closing the statements.
-
dispose
public void dispose()Invoked indirectly by the garbage collector.- Specified by:
dispose
in interfaceDisposable
-