Sha256: 23a210b7844e1bdf1fe50a15bf8f8d005c7b5e5aa22a7cd0bfe50909660de83c

Contents?: true

Size: 1.06 KB

Versions: 33

Compression:

Stored size: 1.06 KB

Contents

module ActiveRecord
  module ConnectionAdapters
    module JdbcConnectionPoolCallbacks
      def self.included(base)
        if base.respond_to?(:set_callback) # Rails 3 callbacks
          base.set_callback :checkin, :after, :on_checkin
          base.set_callback :checkout, :before, :on_checkout
        else
          base.checkin :on_checkin
          base.checkout :on_checkout
        end
      end

      def self.needed?
        ActiveRecord::Base.respond_to?(:connection_pool)
      end

      def on_checkin
        # default implementation does nothing
      end

      def on_checkout
        # default implementation does nothing
      end
    end

    module JndiConnectionPoolCallbacks
      def self.prepare(adapter, conn)
        if ActiveRecord::Base.respond_to?(:connection_pool) && conn.jndi_connection?
          adapter.extend self
          conn.disconnect! # disconnect initial connection in JdbcConnection#initialize
        end
      end

      def on_checkin
        disconnect!
      end

      def on_checkout
        reconnect!
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 8 rubygems

Version Path
activerecord-jdbc-adapter-1.2.9.1 lib/arjdbc/jdbc/callbacks.rb
cmoran92-activerecord-jdbc-adapter-1.2.1.2 lib/arjdbc/jdbc/callbacks.rb
activerecord-jdbc-adapter-1.3.0.beta1 lib/arjdbc/jdbc/callbacks.rb
activerecord-jdbc-adapter-1.2.9 lib/arjdbc/jdbc/callbacks.rb
activerecord-jdbc-adapter-1.2.8 lib/arjdbc/jdbc/callbacks.rb
activerecord-jdbc-adapter-1.2.5 lib/arjdbc/jdbc/callbacks.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.5 lib/arjdbc/jdbc/callbacks.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.4 lib/arjdbc/jdbc/callbacks.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.3 lib/arjdbc/jdbc/callbacks.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.2 lib/arjdbc/jdbc/callbacks.rb
activerecord-jdbc-adapter-1.2.2.1 lib/arjdbc/jdbc/callbacks.rb
activerecord-jdbc-adapter-onsite-1.2.2 lib/arjdbc/jdbc/callbacks.rb
cmoran92-activerecord-jdbc-adapter-1.2.1.1 lib/arjdbc/jdbc/callbacks.rb
intentmedia-activerecord-jdbc-adapter-1.1.1.1 lib/arjdbc/jdbc/callbacks.rb
activerecord-jdbc-adapter-1.2.2 lib/arjdbc/jdbc/callbacks.rb
cmoran92-activerecord-jdbc-adapter-1.2.1 lib/arjdbc/jdbc/callbacks.rb
activerecord-jdbc-adapter-1.2.1 lib/arjdbc/jdbc/callbacks.rb
c3-activerecord-jdbc-adapter-1.1.3.1 lib/arjdbc/jdbc/callbacks.rb
activerecord-jdbc-adapter-1.2.0 lib/arjdbc/jdbc/callbacks.rb
c3-activerecord-jdbc-adapter-1.1.3 lib/arjdbc/jdbc/callbacks.rb