Class: TorqueBox::ServiceRegistry

Inherits:
Object
  • Object
show all
Defined in:
core/lib/torquebox/service_registry.rb

Class Method Summary (collapse)

Class Method Details

+ (Object) [](name)



33
34
35
# File 'core/lib/torquebox/service_registry.rb', line 33

def self.[](name)
  self.lookup(name)
end

+ (Object) blocks



53
54
55
# File 'core/lib/torquebox/service_registry.rb', line 53

def self.blocks
  @blocks ||= Hash.new{|h, k| h[k] = []}
end

+ (Object) lookup(name, &block)



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'core/lib/torquebox/service_registry.rb', line 37

def self.lookup(name, &block)
  if registry.nil?
    self.blocks[name] << block
    nil
  else
    name = TorqueBox::ServiceRegistry.service_name_for( name ) if name.is_a? String
    entry = registry.getService( name )
    return nil unless entry
    if block_given?
      yield entry.getValue()
    else
      entry.getValue()
    end
  end
end

+ (Object) registry



61
62
63
# File 'core/lib/torquebox/service_registry.rb', line 61

def self.registry
  @service_registry
end

+ (Object) service_name_for(name)



57
58
59
# File 'core/lib/torquebox/service_registry.rb', line 57

def self.service_name_for( name )
  Java::org.jboss.msc.service.ServiceName.parse( name )
end

+ (Object) service_registry=(service_registry)



22
23
24
25
26
27
28
29
30
# File 'core/lib/torquebox/service_registry.rb', line 22

def self.service_registry=(service_registry)
  @service_registry = service_registry 
  blocks.keys.each do |name|
    blocks.delete(name).each do |block|
      lookup name, &block
    end
  end
  registry
end