Sha256: 054d73cf131d08801473a025a26ee969caa5195de8a8b0033ed5354b695f439c

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require 'pathname'

module Trinidad
  module Extensions
    class GenericDbpoolWebAppExtension < DbpoolWebAppExtension
      def driver_name
        if driver_path = @driver_path
          unless File.exist?(driver_path)
            driver_path = "#{driver_path}.jar" if driver_path[-4..-1] != '.jar'
          end
          driver_path = Pathname.new(driver_path).realpath.to_s
          if File.exist?(driver_path)
            url = java.net.URL.new "jar:file://#{driver_path}!/META-INF/services/java.sql.Driver"
            begin
              reader = java.io.InputStreamReader.new( url.openStream )
              return java.io.BufferedReader.new( reader ).readLine
            rescue java.io.FileNotFoundException
            end
          end
        end
        nil
      end

      def protocol
        'jdbc:'
      end
      
      protected
      def create_resource tomcat, app_context, options
        @driver_path = options.delete(:driverPath)
        require @driver_path if @driver_path
        super
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trinidad_generic_dbpool_extension-0.4.0 lib/trinidad_generic_dbpool_extension/generic_webapp_extension.rb