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



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

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



41
42
43
# File 'lib/arjdbc/jdbc/callbacks.rb', line 41

def on_checkin
  disconnect!
end

#on_checkoutObject



45
46
47
# File 'lib/arjdbc/jdbc/callbacks.rb', line 45

def on_checkout
  reconnect!
end