Class: TorqueBox::Messaging::Commands::MessageBroker

Inherits:
Container::FoundationCommand
  • Object
show all
Defined in:
lib/torquebox/messaging/commands/message_broker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMessageBroker

Returns a new instance of MessageBroker.



33
34
35
36
37
38
39
40
# File 'lib/torquebox/messaging/commands/message_broker.rb', line 33

def initialize()
  super
  @deploy_files = []
  @deployments = []
  @naming_service = nil
  @standalone = false
  @bind_address = nil
end

Instance Attribute Details

#deploy_filesObject

Returns the value of attribute deploy_files.



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

def deploy_files
  @deploy_files
end

Instance Method Details

#after_start(container) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/torquebox/messaging/commands/message_broker.rb', line 53

def after_start(container)
  require 'torquebox-vfs'
  @deploy_files.each do |file|
    deployment = container.deploy( file )
    unit = container.deployment_unit( deployment.name )
    virtual_file = org.jboss.vfs::VFS.child( File.join( Dir.pwd, file ) )
    unit.addAttachment( 'queues.yml.altDD', virtual_file )
    container.process_deployments(true)
    puts "deployed #{file}"
    @deployments << deployment
  end
end

#before_stop(container) ⇒ Object



66
67
68
69
70
# File 'lib/torquebox/messaging/commands/message_broker.rb', line 66

def before_stop(container)
  @deployments.reverse.each do |deployment|
    container.undeploy( deployment.name )
  end
end

#configure(container) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/torquebox/messaging/commands/message_broker.rb', line 42

def configure(container)
  if ( @standalone )
    container.enable( TorqueBox::Naming::NamingService )
  else
    TorqueBox::Naming.configure do |config|
      config.host = @naming_service
    end
  end
  container.enable( TorqueBox::Messaging::MessageBroker )
end

#parser_options(opts) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/torquebox/messaging/commands/message_broker.rb', line 72

def parser_options(opts)
  opts.on( '-d', '--deploy FILE', 'Deploy a destination descriptor' ) do |file|
    @deploy_files << file
  end
  opts.on( '-n', '--naming HOST', 'External naming service connection' ) do |naming_service|
    @naming_service = naming_service
  end
  opts.on( '-s', '--standalone', 'Run standalone (include naming)' ) do |host|
    @standalone = true
  end
  opts.on( '-b', '--bind', 'Bind address' ) do |bind_address|
    @bind_address = bind_address
  end
  super( opts )
end