Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Don't assume ActiveRecord implies ActiveRecord-JDBC (TORQUE-781)

  • Loading branch information...
commit 4b61e69034a7dac68af2f949916935645f0bd7f3 1 parent 1a7f110
Ben Browning bbrowning authored
Showing with 24 additions and 15 deletions.
  1. +24 −15 gems/transactions/lib/torquebox/active_record_adapters.rb
39 gems/transactions/lib/torquebox/active_record_adapters.rb
View
@@ -15,7 +15,12 @@
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-require 'arjdbc'
+begin
+ require 'arjdbc'
+ TORQUEBOX_XA_JDBC = true
+rescue LoadError
+ TORQUEBOX_XA_JDBC = false
+end
require 'set'
module TorqueBox
@@ -27,15 +32,17 @@ module ActiveRecordAdapters
module Connection
- def transaction(*)
- super
- rescue ActiveRecord::JDBCError => e
- unless self.is_a?(XAResource)
- puts "Creating an XAResource; exception=#{e}"
- self.extend(XAResource)
- retry
- else
- raise
+ if TORQUEBOX_XA_JDBC
+ def transaction(*)
+ super
+ rescue ActiveRecord::JDBCError => e
+ unless self.is_a?(XAResource)
+ puts "Creating an XAResource; exception=#{e}"
+ self.extend(XAResource)
+ retry
+ else
+ raise
+ end
end
end
@@ -114,14 +121,16 @@ def connections
end
end
-module ActiveRecord
- module ConnectionAdapters
- class JdbcAdapter
- include TorqueBox::Transactions::ActiveRecordAdapters::Connection
+if TORQUEBOX_XA_JDBC
+ module ActiveRecord
+ module ConnectionAdapters
+ class JdbcAdapter
+ include TorqueBox::Transactions::ActiveRecordAdapters::Connection
+ end
end
end
end
-
+
module TorqueBox
module Transactions
class Manager
Please sign in to comment.
Something went wrong with that request. Please try again.