Skip to content

Commit 619e675

Browse files
committed
refactore the plain jdbc connection fatory as well + change naming convention(s)
- we're avoiding impl { ... } JRuby proxy method of implementing an interface
1 parent 65a3de0 commit 619e675

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

lib/arjdbc/jdbc/connection.rb

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,11 @@ def setup_jndi_factory
6767
Java::JavaxNaming::InitialContext.new.lookup(config[:jndi].to_s)
6868

6969
@jndi = true
70-
self.connection_factory = RubyJdbcConnectionFactory.new(data_source)
70+
self.connection_factory = JndiConnectionFactoryImpl.new(data_source)
7171
end
7272

73-
class RubyJdbcConnectionFactory
73+
# @private
74+
class JndiConnectionFactoryImpl
7475
include JdbcConnectionFactory
7576

7677
def initialize(data_source)
@@ -91,12 +92,26 @@ def setup_jdbc_factory
9192
url = jdbc_url
9293
username = config[:username]
9394
password = config[:password]
94-
jdbc_driver = ( config[:driver_instance] ||=
95+
driver = ( config[:driver_instance] ||=
9596
JdbcDriver.new(config[:driver].to_s, config[:properties]) )
9697

9798
@jndi = false
98-
self.connection_factory = JdbcConnectionFactory.impl do
99-
jdbc_driver.connection(url, username, password)
99+
self.connection_factory = JdbcConnectionFactoryImpl.new(url, username, password, driver)
100+
end
101+
102+
# @private
103+
class JdbcConnectionFactoryImpl
104+
include JdbcConnectionFactory
105+
106+
def initialize(url, username, password, driver)
107+
@url = url
108+
@username = username
109+
@password = password
110+
@driver = driver
111+
end
112+
113+
def new_connection
114+
@driver.connection(@url, @username, @password)
100115
end
101116
end
102117

0 commit comments

Comments
 (0)