Module: ActiveRecord::ConnectionAdapters::Jdbc::JndiConnectionPoolCallbacks

Defined in:
lib/arjdbc/jdbc/callbacks.rb

Overview

JNDI specific connection pool callbacks that make sure the JNDI connection is disconnected on check-in and looked up (re-connected) on-checkout.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepare(adapter, connection) ⇒ Object



32
33
34
35
36
37
# File 'lib/arjdbc/jdbc/callbacks.rb', line 32

def self.prepare(adapter, connection)
  if adapter.is_a?(ConnectionPoolCallbacks) && connection.jndi?
    adapter.extend self # extend JndiConnectionPoolCallbacks
    connection.disconnect! # if connection.open? - close initial (JNDI) connection
  end
end

Instance Method Details

#on_checkinObject



39
40
41
# File 'lib/arjdbc/jdbc/callbacks.rb', line 39

def on_checkin
  disconnect!
end

#on_checkoutObject



43
44
45
# File 'lib/arjdbc/jdbc/callbacks.rb', line 43

def on_checkout
  reconnect!
end