trinidad_bonecp 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,12 @@
1
+ require 'java'
2
+
3
+ require 'trinidad'
4
+ require 'trinidad/jars'
5
+
6
+ load File.expand_path('../../trinidad-libs/guava-14.0.1.jar', __FILE__)
7
+ load File.expand_path('../../trinidad-libs/log4j-1.2.17.jar', __FILE__)
8
+ load File.expand_path('../../trinidad-libs/slf4j-api-1.7.2.jar', __FILE__)
9
+ load File.expand_path('../../trinidad-libs/slf4j-log4j12-1.7.2.jar', __FILE__)
10
+ load File.expand_path('../../trinidad-libs/bonecp-0.7.1.RELEASE.jar', __FILE__)
11
+
12
+ require 'trinidad_bonecp/webapp_extension'
@@ -0,0 +1,61 @@
1
+ module Trinidad
2
+ module Extensions
3
+ class BonecpWebAppExtension < WebAppExtension
4
+
5
+ def configure(tomcat, app_context)
6
+ case @options
7
+ when Hash
8
+ [create_resource(tomcat, app_context, @options)]
9
+ when Array
10
+ @options.map { |opts| create_resource tomcat, app_context, opts }
11
+ end
12
+ end
13
+
14
+ protected
15
+
16
+ def create_resource(tomcat, app_context, options)
17
+ jndi, url = options.delete(:jndi), options.delete(:url)
18
+ url = protocol + url unless %r{^#{protocol}} =~ url
19
+ options[:jdbcUrl] = url
20
+
21
+ load_driver
22
+
23
+ driver_name = options.delete(:driver) || options.delete(:driverName) ||
24
+ self.driver_name
25
+
26
+ #<Resource type="javax.sql.DataSource"
27
+ # name="jdbc/jndiName"
28
+ # factory="com.jolbox.bonecp.BoneCPDataSource"
29
+ # driverClassName="org.gjt.mm.mysql.Driver"
30
+ # jdbcUrl="jdbc:mysql://localhost:3306/databaseName?characterEncoding=UTF-8"
31
+ # username="user"
32
+ # password="password"
33
+ # idleMaxAge="240"
34
+ # idleConnectionTestPeriod="60"
35
+ # partitionCount="3"
36
+ # acquireIncrement="3"
37
+ # maxConnectionsPerPartition="7"
38
+ # minConnectionsPerPartition="2"
39
+ # statementsCacheSize="50"
40
+ # releaseHelperThreads="5" />
41
+ resource = Trinidad::Tomcat::ContextResource.new
42
+ resource.set_auth(options.delete(:auth)) if options.has_key?(:auth)
43
+ resource.set_description(options.delete(:description)) if options.has_key?(:description)
44
+ resource.set_name(jndi)
45
+ resource.set_type('javax.sql.DataSource')
46
+
47
+ options.each { |key, value| resource.set_property(key.to_s, value.to_s) }
48
+ resource.set_property('driverClassName', driver_name)
49
+ resource.set_property('factory', 'com.jolbox.bonecp.BoneCPDataSource');
50
+
51
+ app_context.naming_resources.add_resource(resource)
52
+ app_context.naming_resources = resource.naming_resources
53
+
54
+ resource
55
+ end
56
+
57
+ def load_driver; end
58
+
59
+ end
60
+ end
61
+ end
Binary file
Binary file
Binary file
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trinidad_bonecp
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_jars
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - '>='
19
+ - !ruby/object:Gem::Version
20
+ version: 1.2.4
21
+ none: false
22
+ requirement: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.2.4
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 bonecp database pools in Trinidad
63
+ email: mrcsparker@gmail.com
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files:
67
+ - README.md
68
+ - LICENSE
69
+ files:
70
+ - lib/trinidad_bonecp.rb
71
+ - lib/trinidad_bonecp/webapp_extension.rb
72
+ - trinidad-libs/bonecp-0.7.1.RELEASE.jar
73
+ - trinidad-libs/guava-14.0.1.jar
74
+ - trinidad-libs/log4j-1.2.17.jar
75
+ - trinidad-libs/slf4j-api-1.7.2.jar
76
+ - trinidad-libs/slf4j-log4j12-1.7.2.jar
77
+ - Gemfile
78
+ - LICENSE
79
+ - README.md
80
+ homepage: http://github.com/mrcsparker/trinidad_bonecp_extension
81
+ licenses: []
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ none: false
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ none: false
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 1.8.24
101
+ signing_key:
102
+ specification_version: 3
103
+ summary: Addon to support bonecp database pools in Trinidad
104
+ test_files: []