
class SimpleService 
  include TorqueBox::Injectors

  def initialize
    @webserver = mc('jboss.web:service=WebServer')
  end

  def start() 
    @should_run = true
    spawn_thread()
  end

  def spawn_thread()
    @thread = Thread.new do
      while @should_run 
        loop_once
        sleep( 1 )
      end
    end
  end

  def loop_once
    $stderr.puts "Service executing loop!"
    basedir = ENV['BASEDIR' ]
    basedir.gsub!( %r(\\:), ':' )
    basedir.gsub!( %r(\\\\), '\\' )
    touchfile = File.join( basedir, 'target', 'touchfile.txt' )
    File.open( touchfile, 'w' ) do |f|
      f.puts( "Updated #{Time.now}" )
    end
  end

  def stop()
    @should_run = false
    @thread.join
  end

end


class SimpleService 
  include TorqueBox::Injectors

  def initialize
    @webserver = mc('jboss.web:service=WebServer')
  end

  def start() 
    @should_run = true
    spawn_thread()
  end

  def spawn_thread()
    @thread = Thread.new do
      while @should_run 
        loop_once
        sleep( 1 )
      end
    end
  end

  def loop_once
    $stderr.puts "Service executing loop with #{@webserver}!"
    basedir = ENV['BASEDIR' ]
    basedir.gsub!( %r(\\:), ':' )
    basedir.gsub!( %r(\\\\), '\\' )
    touchfile = File.join( basedir, 'target', 'touchfile.txt' )
    File.open( touchfile, 'w' ) do |f|
      f.puts( "Updated #{Time.now}" )
    end
  end

  def stop()
    @should_run = false
    @thread.join
  end

end

Print the injected webserver for manual verification of workingness.
Print the injected webserver for manual verification of workingness.
