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

final class CloseableReference extends WeakReference<AuthorityCodes> implements 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 Details

    • factory

      private final EPSGDataAccess factory
      The EPSG factory, used for synchronization lock.
    • statements

      private final Statement[] 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

      final void close() throws SQLException
      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 interface Disposable