Class: TorqueBox::Container::FoundationCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/torquebox/container/foundation_command.rb

Instance Method Summary collapse

Constructor Details

#initializeFoundationCommand

Returns a new instance of FoundationCommand.



23
24
25
26
# File 'lib/torquebox/container/foundation_command.rb', line 23

def initialize()
  @options_parser = OptionParser.new
  parser_options( @options_parser )
end

Instance Method Details

#after_start(container) ⇒ Object



70
71
# File 'lib/torquebox/container/foundation_command.rb', line 70

def after_start(container)
end

#before_stop(container) ⇒ Object



73
74
# File 'lib/torquebox/container/foundation_command.rb', line 73

def before_stop(container)
end

#configure(container) ⇒ Object



66
67
68
# File 'lib/torquebox/container/foundation_command.rb', line 66

def configure(container)
  # no op
end

#parse!(args) ⇒ Object



76
77
78
# File 'lib/torquebox/container/foundation_command.rb', line 76

def parse!(args)
  @options_parser.parse!(args)
end

#parser_options(opts) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/torquebox/container/foundation_command.rb', line 28

def parser_options(opts)
  opts.on( '-L', '--logging CONFIG_XML', 'Specify a logging configuration' ) do |logging_config_xml|
    @logging_config_xml = logging_config_xml
  end
  opts.on_tail( '-h', '--help', 'Show this message' ) do
    puts opts
    exit
  end
end

#runObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/torquebox/container/foundation_command.rb', line 39

def run()

  full_path = File.expand_path( File.join( File.dirname( __FILE__ ), 'log4j.xml' ) )

  if ( @logging_config_xml )
    full_path = File.expand_path( @logging_config_xml ) 
  end

  org.apache.log4j.xml::DOMConfigurator.configure( full_path )

  container = TorqueBox::Container::Foundation.new
  configure( container )
  container.start
  after_start( container )

  interrupted = false
  trap( "INT" ) do
    before_stop( container )
    container.stop
    interrupted = true
  end

  while ( ! interrupted )
    sleep( 2 )
  end
end