Class Named
In: queuemgr/queuemgr.rb
Parent: Object

class Named does the work.

Methods
exit    listall    new    register    unregister    value   
Public Class methods
new()
# File queuemgr/queuemgr.rb, line 96
  def initialize()
    @log = Logging::init(APPNAME)
    @log.info { "Initializing ..." }
    @protocols = Hash.new
    extend(MonitorMixin)
    Thread.start {
      Thread.pass
      while sleep(TIMEOUT)
	tnow = Time.now.to_i
	synchronize {
	  @protocols.each {
	    |proto|
	    proto.delete_if {
	    |k,v|
	    tnow - v.last > TIMEOUT
	    @log.info { "GC: removed '#{k} ...'" }
	    }
	  }
	}
	Thread.pass
      end
    }
  end
Public Instance methods
value(uri)
# File queuemgr/queuemgr.rb, line 120
  def value(uri)
    synchronize {
      pair = uri.split("://")
      proto = pair.first
      path = pair.last
      result = @protocols.key?(proto) ? [path] + @protocols[proto][path] : []
    }
  end
register(uri, val)
# File queuemgr/queuemgr.rb, line 129
  def register(uri, val)
    synchronize {
      pair = uri.split("://")
      proto = pair.first
      path = pair.last
      val = val.split("|")
      @protocols[proto] = Hash.new if !@protocols.key?(proto)
      @log.info { "Register '#{uri}'." } if @protocols[proto][path].nil?
      @protocols[proto][path] = val + [ Time.now.to_i ]
    }
  end
unregister(uri)
# File queuemgr/queuemgr.rb, line 141
  def unregister(uri)
    synchronize {
      pair = uri.split("://")
      proto = pair.first
      path = pair.last
      if @protocols.key?(proto) 
	if !@protocols[proto][path].nil?
	  @protocols[proto].delete(path)
	  @log.info { "Unregister '#{uri}'." } 
	end
      end
    }
  end
listall(proto)
# File queuemgr/queuemgr.rb, line 155
  def listall(proto)
    synchronize {
      list = []
      if @protocols.key?(proto)
	@protocols[proto].each_pair {
	  |key, val|
	  list << ([key] + val)
	}
      end
      list
    }
  end
exit()
# File queuemgr/queuemgr.rb, line 168
  def exit()
    @log.info { "Exiting by request" }
    Process.kill("HUP",$$)
  end