Class: TorqueBox::Messaging::Commands::MessageProcessorHost

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMessageProcessorHost

Returns a new instance of MessageProcessorHost.



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

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

Instance Attribute Details

#deploy_filesObject

Returns the value of attribute deploy_files.



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

def deploy_files
  @deploy_files
end

Instance Method Details

#after_start(container) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/torquebox/messaging/commands/message_processor_host.rb', line 47

def after_start(container)
  @deploy_files.each do |file|
    deployment = container.deploy( file )
    unit = container.deployment_unit( deployment.name )
    builder = TorqueBox::Messaging::MetaData::Builder.new() 
    builder.evaluate_file( file )
    builder.processors.each do |processor|
      org.torquebox.mc::AttachmentUtils.multipleAttach( unit, processor, processor.name )
    end
    app_meta = org.torquebox.base.::RubyApplicationMetaData.new
    app_meta.setApplicationName( "none" )
    app_meta.setEnvironmentName( ENV['TORQUEBOX_ENV'] || 'development' )
    app_meta.setRoot( org.jboss.vfs::VFS.getChild( Dir.pwd ) )
    unit.addAttachment( org.torquebox.base.::RubyApplicationMetaData.java_class, app_meta )
    container.process_deployments(true)
    puts "deployed #{file}"
    @deployments << deployment
  end
end

#before_stop(container) ⇒ Object



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

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

#configure(container) ⇒ Object



40
41
42
43
44
45
# File 'lib/torquebox/messaging/commands/message_processor_host.rb', line 40

def configure(container)
  TorqueBox::Naming.configure do |config|
    config.host = @naming_service 
  end
  container.enable( TorqueBox::Messaging::MessageProcessorHost )
end

#parser_options(opts) ⇒ Object



73
74
75
76
77
78
79
80
81
# File 'lib/torquebox/messaging/commands/message_processor_host.rb', line 73

def parser_options(opts)
  opts.on( '-d', '--deploy FILE', 'Deploy a message-processor configuration' ) do |file|
    @deploy_files << file
  end
  opts.on( '-n', '--naming HOST', 'External naming service connection' ) do |naming_service|
    @naming_service = naming_service
  end
  super( opts )
end