trinidad_dbpool 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +3 -0
- data/VERSION +1 -1
- data/lib/trinidad_dbpool/webapp_extension.rb +19 -12
- metadata +46 -68
- data/spec/spec_helper.rb +0 -10
- data/spec/trinidad_mysql_dbpool_extension_spec.rb +0 -48
data/README.rdoc
CHANGED
@@ -7,6 +7,8 @@ container.
|
|
7
7
|
|
8
8
|
* MySql (trinidad_mysql_dbpool_extension)
|
9
9
|
* PostgreSQL (trinidad_postgresql_dbpool_extension)
|
10
|
+
* Mssql (trinidad_mssql_dbpool_extension)
|
11
|
+
* Oracle (trinidad_oracle_dbpool_extension)
|
10
12
|
|
11
13
|
== Usage
|
12
14
|
|
@@ -37,6 +39,7 @@ http://commons.apache.org/dbcp/configuration.html
|
|
37
39
|
production:
|
38
40
|
adapter: jdbc
|
39
41
|
jndi: java:/comp/env/jdbc/TestDB
|
42
|
+
driver: com.mysql.jdbc.Driver # jdbc driver is mandatory
|
40
43
|
|
41
44
|
== Note on Patches/Pull Requests
|
42
45
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
@@ -2,22 +2,29 @@ module Trinidad
|
|
2
2
|
module Extensions
|
3
3
|
class DbpoolWebAppExtension < WebAppExtension
|
4
4
|
def configure(tomcat, app_context)
|
5
|
-
|
6
|
-
|
5
|
+
case @options
|
6
|
+
when Hash
|
7
|
+
[create_resource tomcat, app_context, @options]
|
8
|
+
when Array
|
9
|
+
@options.map { |opts| create_resource tomcat, app_context, opts }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def create_resource tomcat, app_context, opts
|
15
|
+
jndi = opts.delete(:jndi)
|
16
|
+
url = opts.delete(:url)
|
7
17
|
url = protocol + url unless %r{^#{protocol}} =~ url
|
8
|
-
|
18
|
+
opts[:url] = url
|
9
19
|
|
10
20
|
resource = Trinidad::Tomcat::ContextResource.new
|
11
|
-
resource.
|
12
|
-
resource.
|
13
|
-
resource.
|
14
|
-
resource.
|
15
|
-
|
16
|
-
@options.each do |key, value|
|
17
|
-
resource.setProperty(key.to_s, value.to_s)
|
18
|
-
end
|
21
|
+
resource.set_auth(opts.delete(:auth)) if opts.key?(:auth)
|
22
|
+
resource.set_name(jndi)
|
23
|
+
resource.set_type('javax.sql.DataSource')
|
24
|
+
resource.set_description(opts.delete(:description)) if opts.key?(:description)
|
19
25
|
|
20
|
-
resource.
|
26
|
+
opts.each { |key, value| resource.set_property(key.to_s, value.to_s) }
|
27
|
+
resource.set_property('driverClassName', driver_name)
|
21
28
|
|
22
29
|
app_context.naming_resources.add_resource(resource)
|
23
30
|
app_context.naming_resources = resource.naming_resources
|
metadata
CHANGED
@@ -1,53 +1,40 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trinidad_dbpool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 0
|
10
|
-
version: 0.2.0
|
4
|
+
prerelease:
|
5
|
+
version: 0.3.0
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
|
-
- David Calavera
|
8
|
+
- David Calavera
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date:
|
13
|
+
date: 2011-07-02 00:00:00 +02:00
|
19
14
|
default_executable:
|
20
15
|
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
hash: 13
|
44
|
-
segments:
|
45
|
-
- 1
|
46
|
-
- 2
|
47
|
-
- 9
|
48
|
-
version: 1.2.9
|
49
|
-
type: :development
|
50
|
-
version_requirements: *id002
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: trinidad_jars
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 1.2.9
|
36
|
+
type: :development
|
37
|
+
version_requirements: *id002
|
51
38
|
description: Addon to support database pools in Trinidad
|
52
39
|
email: calavera@apache.org
|
53
40
|
executables: []
|
@@ -55,51 +42,42 @@ executables: []
|
|
55
42
|
extensions: []
|
56
43
|
|
57
44
|
extra_rdoc_files:
|
58
|
-
- LICENSE
|
59
|
-
- README.rdoc
|
45
|
+
- LICENSE
|
46
|
+
- README.rdoc
|
60
47
|
files:
|
61
|
-
- LICENSE
|
62
|
-
- README.rdoc
|
63
|
-
- VERSION
|
64
|
-
- lib/trinidad_dbpool.rb
|
65
|
-
- lib/trinidad_dbpool/webapp_extension.rb
|
66
|
-
- trinidad-libs/tomcat-dbcp.jar
|
67
|
-
- spec/spec_helper.rb
|
68
|
-
- spec/trinidad_mysql_dbpool_extension_spec.rb
|
48
|
+
- LICENSE
|
49
|
+
- README.rdoc
|
50
|
+
- VERSION
|
51
|
+
- lib/trinidad_dbpool.rb
|
52
|
+
- lib/trinidad_dbpool/webapp_extension.rb
|
53
|
+
- trinidad-libs/tomcat-dbcp.jar
|
69
54
|
has_rdoc: true
|
70
55
|
homepage: http://github.com/calavera/trinidad-dbpool
|
71
56
|
licenses: []
|
72
57
|
|
73
58
|
post_install_message:
|
74
|
-
rdoc_options:
|
75
|
-
|
59
|
+
rdoc_options: []
|
60
|
+
|
76
61
|
require_paths:
|
77
|
-
- lib
|
62
|
+
- lib
|
78
63
|
required_ruby_version: !ruby/object:Gem::Requirement
|
79
64
|
none: false
|
80
65
|
requirements:
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
segments:
|
85
|
-
- 0
|
86
|
-
version: "0"
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
87
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
70
|
none: false
|
89
71
|
requirements:
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
segments:
|
94
|
-
- 0
|
95
|
-
version: "0"
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: "0"
|
96
75
|
requirements: []
|
97
76
|
|
98
77
|
rubyforge_project:
|
99
|
-
rubygems_version: 1.
|
78
|
+
rubygems_version: 1.5.1
|
100
79
|
signing_key:
|
101
80
|
specification_version: 3
|
102
81
|
summary: Addon to support database pools in Trinidad
|
103
|
-
test_files:
|
104
|
-
|
105
|
-
- spec/trinidad_mysql_dbpool_extension_spec.rb
|
82
|
+
test_files: []
|
83
|
+
|
data/spec/spec_helper.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'trinidad-libs'))
|
4
|
-
|
5
|
-
require 'trinidad_mysql_dbpool_extension'
|
6
|
-
require 'spec'
|
7
|
-
|
8
|
-
Spec::Runner.configure do |config|
|
9
|
-
config.mock_with :mocha
|
10
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe Trinidad::Extensions::MysqlDbpoolWebAppExtension do
|
4
|
-
before(:each) do
|
5
|
-
@options = {
|
6
|
-
:url => 'jdbc:mysql://localhost:3306/test',
|
7
|
-
:jndi => 'jdbc/TestDB',
|
8
|
-
:maxIdle => 300
|
9
|
-
}
|
10
|
-
@extension = Trinidad::Extensions::MysqlDbpoolWebAppExtension.new(@options)
|
11
|
-
@context = Trinidad::Tomcat::StandardContext.new
|
12
|
-
|
13
|
-
@tomcat = mock
|
14
|
-
resource_context = mock
|
15
|
-
naming = mock
|
16
|
-
|
17
|
-
naming.stubs(:addResource)
|
18
|
-
resource_context.stubs(:naming_resources).returns(naming)
|
19
|
-
resource_context.stubs(:naming_resources=)
|
20
|
-
@tomcat.stubs(:addContext).returns(resource_context)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "sets the mysql driver name as a resource property" do
|
24
|
-
resource = configure_extension
|
25
|
-
resource.getProperty('driverClassName').should == 'com.mysql.jdbc.Driver'
|
26
|
-
end
|
27
|
-
|
28
|
-
it "adds the resource to the tomcat standard context" do
|
29
|
-
configure_extension
|
30
|
-
@context.naming_resources.find_resource('jdbc/TestDB').should_not be_nil
|
31
|
-
end
|
32
|
-
|
33
|
-
it "adds properties to the resource" do
|
34
|
-
resource = configure_extension
|
35
|
-
resource.getProperty('maxIdle').should == '300'
|
36
|
-
end
|
37
|
-
|
38
|
-
it "adds the protocol if the url doesn't include it" do
|
39
|
-
@options[:url] = "localhost:3306/test_protocol"
|
40
|
-
extension = Trinidad::Extensions::MysqlDbpoolWebAppExtension.new(@options)
|
41
|
-
resource = extension.configure(@tomcat, @context)
|
42
|
-
resource.get_property('url').should == "jdbc:mysql://localhost:3306/test_protocol"
|
43
|
-
end
|
44
|
-
|
45
|
-
def configure_extension
|
46
|
-
@extension.configure(@tomcat, @context)
|
47
|
-
end
|
48
|
-
end
|