<commit_before>
module TorqueBox
  module Messaging
    class ConnectionFactory

      attr_reader :internal_connection_factory

      def initialize(internal_connection_factory = null)
        @internal_connection_factory = internal_connection_factory
        @hornetq_direct = false
      end

      def with_new_connection(&block)
        connection = create_connection
        connection.start
        begin
          result = block.call( connection )
        ensure
          connection.close
        end
        return result
      end

      def create_connection()
        if !@internal_connection_factory
          # try to connect to HornetQ directly - this currently
          # assumes localhost, and the default AS7 HQ Netty port of 5445
          connect_opts = { org.hornetq.core.remoting.impl.netty.TransportConstants::PORT_PROP_NAME => 5445 }
          transport_config =
            org.hornetq.api.core.TransportConfiguration.new("org.hornetq.core.remoting.impl.netty.NettyConnectorFactory", 
                                                            connect_opts)
          @internal_connection_factory =
            org.hornetq.api.jms.HornetQJMSClient.createConnectionFactory( transport_config )
          @hornetq_direct = true
        end
        
        Connection.new( @internal_connection_factory.create_connection, @hornetq_direct )
      end

<commit_msg>Give HornetQ the integral love it wants.  Love you long time.<commit_after>require 'java'

module TorqueBox
  module Messaging
    class ConnectionFactory

      attr_reader :internal_connection_factory

      def initialize(internal_connection_factory = null)
        @internal_connection_factory = internal_connection_factory
        @hornetq_direct = false
      end

      def with_new_connection(&block)
        connection = create_connection
        connection.start
        begin
          result = block.call( connection )
        ensure
          connection.close
        end
        return result
      end

      def create_connection()
        if !@internal_connection_factory
          # try to connect to HornetQ directly - this currently
          # assumes localhost, and the default AS7 HQ Netty port of 5445
          connect_opts = { org.hornetq.core.remoting.impl.netty.TransportConstants::PORT_PROP_NAME => 5445.to_java( java.lang.Integer ) }
          transport_config =
            org.hornetq.api.core.TransportConfiguration.new("org.hornetq.core.remoting.impl.netty.NettyConnectorFactory", 
                                                            connect_opts)
          @internal_connection_factory =
            org.hornetq.api.jms.HornetQJMSClient.createConnectionFactory( transport_config )
          @hornetq_direct = true
        end
        
        Connection.new( @internal_connection_factory.create_connection, @hornetq_direct )
      end


{'fraction_non_alphanumeric': 0.05687369155617585, 'fraction_numerical': 0.00628053035589672, 'mean_word_length': 2.23954802259887, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1216220', 'n_tokens_mistral': 744, 'n_tokens_neox': 715, 'n_words': 154}