trinidad_generic_dbpool_extension 0.1.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,13 @@
1
+ == 0.4.0 (2012-05-31)
2
+
3
+ * revised trinidad_generic_dbpool_extension :
4
+ - driver configuration option aliased as driverName
5
+ - new driverPath option for specifying driver jar in configuration
6
+ - allow driverName to be auto resolved when driverPath specified
7
+ * trinidad_postgresql_dbpool_extension with driver updated to 9.1-902
8
+ * trinidad_mysql_dbpool_extension with mysql-connector-j 5.1.20
9
+ * code cleanup, get rid of jeweler, update tomcat-dbcp.jar for trinidad_dbpool
10
+
1
11
  == 0.3.0 (2011-07-01)
2
12
 
3
13
  * Oracle connection pool extension
@@ -1,45 +1,84 @@
1
1
  = trinidad-dbpool
2
2
 
3
- Trinidad extensions to support database connection pools configured into the Apache Tomcat
4
- container.
3
+ Trinidad extensions to support database connection pooling on top of the
4
+ underlying Apache Tomcat container.
5
5
 
6
- == Pools supported
6
+ Please note, that such pools are usually configured as "global" and thus
7
+ shareable by multiple applications deployed on to of Trinidad server.
7
8
 
8
- * MySql (trinidad_mysql_dbpool_extension)
9
+ == Available Pools
10
+
11
+ * MySQL (trinidad_mysql_dbpool_extension)
9
12
  * PostgreSQL (trinidad_postgresql_dbpool_extension)
10
- * Mssql (trinidad_mssql_dbpool_extension)
13
+ * MS-SQL (trinidad_mssql_dbpool_extension) using (unofficial) jTDS driver
11
14
  * Oracle (trinidad_oracle_dbpool_extension)
15
+ * Generic (trinidad_generic_dbpool_extension) in case your DB ain't supported
12
16
 
13
17
  == Usage
14
18
 
15
- * Install the extension gem, ie: jruby -S gem install trinidad_mysql_dbpool_extension
16
- * Configure the pool into the trinidad's configuration file, ie:
19
+ * Install the gem e.g. `jruby -S gem install trinidad_mysql_dbpool_extension`
20
+ * Configure the pool with Trinidad's configuration file e.g. :
17
21
 
18
- web_apps:
19
- default:
20
- extensions:
21
- mysql_dbpool: # EXTENSION NAME AS KEY
22
- jndi: 'jdbc/TestDB' # jndi name
23
- username: 'root' # database username
24
- password: 'root' # database password
25
- url: 'jdbc:mysql://localhost:3306/javatest' # database url
26
- maxActive: 100 # max nodes actives
27
- maxIdle: 30 # max nodes idles
28
- maxWait: 10000 # max nodes waiting
29
-
30
- _jndi_, _username_, _password_ and _url_ are mandatory, while other
31
- configuration options can be found here:
22
+ web_apps:
23
+ default:
24
+ extensions:
25
+ mysql_dbpool: # EXTENSION NAME AS KEY
26
+ jndi: 'jdbc/TestDB' # JNDI name
27
+ username: 'root' # database username
28
+ password: 'root' # database password
29
+ url: 'localhost:3306/javatest' # database URL (or full jdbc: URL)
30
+ maxActive: 100 # max nodes actives
31
+ maxIdle: 30 # max nodes idles
32
+ maxWait: 10000 # max nodes waiting
33
+
34
+ _jndi_, _username_, _password_ and _url_ are mandatory,
35
+ while other supported configuration options might be found here:
32
36
 
33
37
  http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html
34
38
 
35
39
  http://commons.apache.org/dbcp/configuration.html
36
40
 
37
- * Configure your rails application to use jndi into the config/database.yml
41
+ * Configure your rails application to use JNDI into the config/database.yml
42
+
43
+ production:
44
+ adapter: jdbc
45
+ jndi: java:/comp/env/jdbc/TestDB
46
+ driver: com.mysql.jdbc.Driver # JDBC driver is mandatory here
47
+
48
+ == Generic Pool
49
+
50
+ If there's no "official" pool for your database, or would like to use a
51
+ different version of a JDBC driver for a supported Trinidad pool, this allows
52
+ you to completely customize a pool.
53
+
54
+ NOTE: You will need a JDBC driver for your database, check the driver DB if
55
+ unsure about how to get one http://developers.sun.com/product/jdbc/drivers
56
+
57
+ Sample configuration for a DB2 database :
58
+
59
+ ---
60
+ extensions:
61
+ generic_dbpool: # EXTENSION NAME AS KEY
62
+ jndi: 'jdbc/MyDB' # JNDI name
63
+ url: 'jdbc:db2://127.0.0.1:50000/MYDB' # specify full jdbc: URL
64
+ username: 'mydb' # database username
65
+ password: 'pass' # database password
66
+ driverPath: '/opt/IBM/DB2/db2jcc4.jar' # leave out if it's on class-path
67
+ driverName: com.ibm.db2.jcc.DB2Driver # might resolve from driverPath
68
+
69
+ Beyond standard configuration options there's 2 specific options here :
70
+
71
+ * _driverPath_ should be a path to your JDBC driver archive, if you're using a
72
+ --libs jar folder with trinidad, might leave that out but make sure it's on
73
+ the class-path for each and every deployed application that requires it.
74
+
75
+ Also in case driverPath: is ommited you'll need to specify a driverName: !
38
76
 
39
- production:
40
- adapter: jdbc
41
- jndi: java:/comp/env/jdbc/TestDB
42
- driver: com.mysql.jdbc.Driver # jdbc driver is mandatory
77
+ * _driverName_ the class name implementing the JDBC driver interface, if you're
78
+ not sure check the .jar for a META-INF/services/java.sql.Driver file. If
79
+ present that file contains the class-name and you might leave driverName:
80
+ blank if you specified the jar path using driverPath: but you're going still
81
+ going to need the driver name in your database.yml
43
82
 
44
83
  == Note on Patches/Pull Requests
45
84
 
@@ -47,10 +86,8 @@ http://commons.apache.org/dbcp/configuration.html
47
86
  * Make your feature addition or bug fix.
48
87
  * Add tests for it. This is important so I don't break it in a
49
88
  future version unintentionally.
50
- * Commit, do not mess with rakefile, version, or history.
51
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
52
89
  * Send me a pull request. Bonus points for topic branches.
53
90
 
54
91
  == Copyright
55
92
 
56
- Copyright (c) 2010 David Calavera. See LICENSE for details.
93
+ Copyright (c) 2010-2012 David Calavera. See LICENSE for details.
data/Rakefile CHANGED
@@ -31,7 +31,14 @@ def release(gem, version = nil)
31
31
  sh "gem push #{gem_file}"
32
32
  end
33
33
 
34
- all_gems = %W{ dbpool mysql_dbpool_extension postgresql_dbpool_extension mssql_dbpool_extension oracle_dbpool_extension }
34
+ all_gems = %W{
35
+ dbpool
36
+ generic_dbpool_extension
37
+ mysql_dbpool_extension
38
+ postgresql_dbpool_extension
39
+ mssql_dbpool_extension
40
+ oracle_dbpool_extension
41
+ }
35
42
  all_gems.map! { |gem| "trinidad_#{gem}" }
36
43
  all_gems.each do |gem_name|
37
44
  namespace gem_name do
@@ -1,13 +1,36 @@
1
+ require 'pathname'
2
+
1
3
  module Trinidad
2
4
  module Extensions
3
5
  class GenericDbpoolWebAppExtension < DbpoolWebAppExtension
4
6
  def driver_name
7
+ if driver_path = @driver_path
8
+ unless File.exist?(driver_path)
9
+ driver_path = "#{driver_path}.jar" if driver_path[-4..-1] != '.jar'
10
+ end
11
+ driver_path = Pathname.new(driver_path).realpath.to_s
12
+ if File.exist?(driver_path)
13
+ url = java.net.URL.new "jar:file://#{driver_path}!/META-INF/services/java.sql.Driver"
14
+ begin
15
+ reader = java.io.InputStreamReader.new( url.openStream )
16
+ return java.io.BufferedReader.new( reader ).readLine
17
+ rescue java.io.FileNotFoundException
18
+ end
19
+ end
20
+ end
5
21
  nil
6
22
  end
7
23
 
8
24
  def protocol
9
25
  'jdbc:'
10
26
  end
27
+
28
+ protected
29
+ def create_resource tomcat, app_context, options
30
+ @driver_path = options.delete(:driverPath)
31
+ require @driver_path if @driver_path
32
+ super
33
+ end
11
34
  end
12
35
  end
13
36
  end
metadata CHANGED
@@ -2,15 +2,16 @@
2
2
  name: trinidad_generic_dbpool_extension
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.4.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Patrick Cheng
9
+ - Karol Bucek
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
13
 
13
- date: 2012-05-25 00:00:00 Z
14
+ date: 2012-05-31 00:00:00 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: trinidad_dbpool
@@ -20,7 +21,7 @@ dependencies:
20
21
  requirements:
21
22
  - - ">="
22
23
  - !ruby/object:Gem::Version
23
- version: 0.3.0
24
+ version: 0.4.0
24
25
  type: :runtime
25
26
  version_requirements: *id001
26
27
  - !ruby/object:Gem::Dependency
@@ -48,6 +49,7 @@ dependencies:
48
49
  description: Addon to support generic database pools in Trinidad
49
50
  email:
50
51
  - patrickyccheng@gmail.com
52
+ - self@kares.org
51
53
  executables: []
52
54
 
53
55
  extensions: []