Class: TorqueBox::Messaging::XaConnectionFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/torquebox/messaging/xa_connection_factory.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(internal_connection_factory = nil) ⇒ XaConnectionFactory

Returns a new instance of XaConnectionFactory.



32
33
34
# File 'lib/torquebox/messaging/xa_connection_factory.rb', line 32

def initialize(internal_connection_factory = nil)
  @internal_connection_factory = internal_connection_factory
end

Instance Attribute Details

#internal_connection_factoryObject (readonly)

Returns the value of attribute internal_connection_factory.



25
26
27
# File 'lib/torquebox/messaging/xa_connection_factory.rb', line 25

def internal_connection_factory
  @internal_connection_factory
end

Class Method Details

.new(internal_connection_factory = nil) ⇒ Object



27
28
29
30
# File 'lib/torquebox/messaging/xa_connection_factory.rb', line 27

def self.new(internal_connection_factory = nil)
  return internal_connection_factory if internal_connection_factory.is_a?( XaConnectionFactory )
  super
end

Instance Method Details

#create_connectionObject



49
50
51
# File 'lib/torquebox/messaging/xa_connection_factory.rb', line 49

def create_connection()
  XaConnection.new( @internal_connection_factory.create_xa_connection )
end

#to_sObject



54
55
56
# File 'lib/torquebox/messaging/xa_connection_factory.rb', line 54

def to_s
  "[XaConnectionFactory: internal_connection_factory=#{internal_connection_factory}]"
end

#with_new_connection(options, &block) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/torquebox/messaging/xa_connection_factory.rb', line 36

def with_new_connection(options, &block)
  client_id = options[:client_id]
  connection = create_connection
  connection.client_id = client_id
  connection.start
  begin
    result = block.call( connection )
  ensure
    connection.close
  end
  return result
end