trinidad_generic_bonecp_extension 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +10 -0
- data/LICENSE +25 -0
- data/README.md +29 -0
- data/lib/trinidad_generic_bonecp_extension.rb +2 -0
- data/lib/trinidad_generic_bonecp_extension/generic_webapp_extension.rb +65 -0
- metadata +100 -0
data/Gemfile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec :name => 'trinidad_bonecp'
|
4
|
+
|
5
|
+
gemspec :name => 'trinidad_generic_bonecp_extension'
|
6
|
+
|
7
|
+
gem 'trinidad', :require => nil
|
8
|
+
|
9
|
+
gem 'rake', :groups => [:development, :test], :require => nil
|
10
|
+
gem 'jruby-openssl', :group => :development, :require => nil
|
data/LICENSE
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
Copyright (c) 2013 Chris Parker http://github.com/mrcsparker
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
== JDBC Driver
|
23
|
+
|
24
|
+
Included JDBC drivers are most likely distributed under different terms than
|
25
|
+
those above, please make sure you understand your driver's license terms.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Trinidad BoneCP Database Pool
|
2
|
+
|
3
|
+
Trinidad extensions that support the BoneCP (http://jolbox.com/) connection pool library.
|
4
|
+
|
5
|
+
The code is based on the Trinidad DBPool extension (https://github.com/trinidad/trinidad_dbpool_extension).
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
The configuration is modeled after the `trinidad_dbpool_extension`.
|
10
|
+
|
11
|
+
* Install the gem e.g. `jruby -S gem install trinidad_generic_bonecp_extension`
|
12
|
+
* Configure the pool with Trinidad's configuration file e.g. :
|
13
|
+
|
14
|
+
```yml
|
15
|
+
---
|
16
|
+
extensions:
|
17
|
+
generic_bonecp: # EXTENSION NAME AS KEY
|
18
|
+
jndi: 'jdbc/MyDB' # JNDI name
|
19
|
+
url: 'jdbc:db2://127.0.0.1:50000/MYDB' # specify full jdbc: URL
|
20
|
+
username: 'mydb' # database username
|
21
|
+
password: 'pass' # database password
|
22
|
+
driverPath: '/opt/IBM/DB2/db2jcc4.jar' # leave out if on class-path
|
23
|
+
driverName: com.ibm.db2.jcc.DB2Driver # resolved from driverPath jar
|
24
|
+
```
|
25
|
+
|
26
|
+
## Copyright
|
27
|
+
|
28
|
+
Copyright (c) 2013 [Chris Parker](https://github.com/mrcsparker).
|
29
|
+
See LICENSE (http://en.wikipedia.org/wiki/MIT_License) for details.
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Trinidad
|
2
|
+
module Extensions
|
3
|
+
class GenericBonecpWebAppExtension < BonecpWebAppExtension
|
4
|
+
|
5
|
+
PATH_SEPARATOR = java.io.File::pathSeparator
|
6
|
+
|
7
|
+
def driver_path(first = nil)
|
8
|
+
path = @driver_path || []
|
9
|
+
first ? path.first : path
|
10
|
+
end
|
11
|
+
|
12
|
+
def driver_path=(path)
|
13
|
+
path = ( path || '' ).split(PATH_SEPARATOR)
|
14
|
+
path.map! do |jar|
|
15
|
+
jars = Dir.glob(jar)
|
16
|
+
if jars.empty? # normalize .jar ext
|
17
|
+
jar = "#{jar}.jar" if jar[-4..-1] != '.jar'
|
18
|
+
jar
|
19
|
+
else
|
20
|
+
jars
|
21
|
+
end
|
22
|
+
end
|
23
|
+
path.flatten!
|
24
|
+
@driver_path = path
|
25
|
+
end
|
26
|
+
|
27
|
+
def driver_name
|
28
|
+
return @driver_name if defined? @driver_name
|
29
|
+
driver_path.find do |path|
|
30
|
+
path = java.io.File.new(path).absolute_path
|
31
|
+
if File.exist?(path)
|
32
|
+
url = java.net.URL.new "jar:file://#{path}!/META-INF/services/java.sql.Driver"
|
33
|
+
begin
|
34
|
+
reader = java.io.InputStreamReader.new( url.openStream )
|
35
|
+
return @driver_name = java.io.BufferedReader.new( reader ).readLine
|
36
|
+
rescue java.io.FileNotFoundException
|
37
|
+
false
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
@driver_name = nil
|
42
|
+
end
|
43
|
+
|
44
|
+
def protocol
|
45
|
+
'jdbc:'
|
46
|
+
end
|
47
|
+
|
48
|
+
protected
|
49
|
+
|
50
|
+
def create_resource(tomcat, app_context, options)
|
51
|
+
path = options.delete(:driverPath) || options.delete(:driver_path)
|
52
|
+
self.driver_path = path if path
|
53
|
+
if path && driver_path.empty?
|
54
|
+
warn "no driver matched with specified :driverPath = #{path.inspect}"
|
55
|
+
end
|
56
|
+
super
|
57
|
+
end
|
58
|
+
|
59
|
+
def load_driver
|
60
|
+
driver_path.each { |jar| load jar }
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: trinidad_generic_bonecp_extension
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Chris Parker
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-09-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: trinidad_bonecp
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.1.0
|
21
|
+
none: false
|
22
|
+
requirement: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.1.0
|
27
|
+
none: false
|
28
|
+
prerelease: false
|
29
|
+
type: :runtime
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
version_requirements: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '2.10'
|
37
|
+
none: false
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '2.10'
|
43
|
+
none: false
|
44
|
+
prerelease: false
|
45
|
+
type: :development
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: mocha
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0.10'
|
53
|
+
none: false
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0.10'
|
59
|
+
none: false
|
60
|
+
prerelease: false
|
61
|
+
type: :development
|
62
|
+
description: Addon to support generic bonecp database pools in Trinidad
|
63
|
+
email:
|
64
|
+
- mrcsparker@gmail.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files:
|
68
|
+
- README.md
|
69
|
+
- LICENSE
|
70
|
+
files:
|
71
|
+
- lib/trinidad_generic_bonecp_extension.rb
|
72
|
+
- lib/trinidad_generic_bonecp_extension/generic_webapp_extension.rb
|
73
|
+
- Gemfile
|
74
|
+
- LICENSE
|
75
|
+
- README.md
|
76
|
+
homepage: http://github.com/mrcsparker/trinidad_bonecp_extension
|
77
|
+
licenses: []
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
none: false
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
none: false
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 1.8.24
|
97
|
+
signing_key:
|
98
|
+
specification_version: 3
|
99
|
+
summary: Addon to support generic bonecp database pools in Trinidad
|
100
|
+
test_files: []
|