
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


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
    if @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
  end

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

end

Make the success of the test depend on the success of the injection, just for grins.
Make the success of the test depend on the success of the injection, just for grins.
