Class NucleusConnectionImpl

  • All Implemented Interfaces:
    NucleusConnection

    public class NucleusConnectionImpl
    extends java.lang.Object
    implements NucleusConnection
    Representation of a datastore connection. Provides access to the native connection for the datastore.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean isAvailable
      whether this connection is available to the developer
      private java.lang.Object nativeConnection
      Native connection for this datastore.
      private java.lang.Runnable onClose
      run "onClose" on close call
    • Constructor Summary

      Constructors 
      Constructor Description
      NucleusConnectionImpl​(java.lang.Object conn, java.lang.Runnable onClose)
      Constructor for a datastore connection holder.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Method to close the connection.
      java.lang.Object getNativeConnection()
      Accessor for the native connection for this datastore.
      boolean isAvailable()
      Accessor for whether the connection is available.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • nativeConnection

        private final java.lang.Object nativeConnection
        Native connection for this datastore.
      • onClose

        private final java.lang.Runnable onClose
        run "onClose" on close call
      • isAvailable

        private boolean isAvailable
        whether this connection is available to the developer
    • Constructor Detail

      • NucleusConnectionImpl

        public NucleusConnectionImpl​(java.lang.Object conn,
                                     java.lang.Runnable onClose)
        Constructor for a datastore connection holder.
        Parameters:
        conn - The native connection
        onClose - What to perform on closure
    • Method Detail

      • close

        public void close()
        Method to close the connection. Performs whatever action was specified at creation.
        Specified by:
        close in interface NucleusConnection
        Throws:
        NucleusUserException - Thrown if the connection is no longer available.
      • isAvailable

        public boolean isAvailable()
        Description copied from interface: NucleusConnection
        Accessor for whether the connection is available.
        Specified by:
        isAvailable in interface NucleusConnection
        Returns:
        Whether it is available
      • getNativeConnection

        public java.lang.Object getNativeConnection()
        Accessor for the native connection for this datastore. For RDBMS this would be a java.sql.Connection, or for db4o an ObjectContainer etc.
        Specified by:
        getNativeConnection in interface NucleusConnection
        Returns:
        The native connection