Class: OSGi::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/osgi/registry.rb

Overview

A class to hold the registered containers. It is possible to add containers until resolved_containers is called, after which it is not possible to modify the registry anymore.

Instance Method Summary collapse

Instance Method Details

#containersObject

Returns the containers associated with this registry. The list of containers is modifiable if resolved_containers hasn’t been called yet.



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/osgi/registry.rb', line 61

def containers
  unless @containers
    @containers = read_containers
    if ENV['OSGI'] && !ENV['OSGi']
      warn "The correct constant to define for the OSGi containers is named OSGi"
      ENV['OSGi'] = ENV['OSGI']
    end
    if ENV['OSGi'] 
      @containers |= ENV['OSGi'].split(';')
    end
  end
  @resolved_containers.nil? ? @containers : @containers.dup.freeze
end

#containers=(containers) ⇒ Object

Sets the containers of the registry Raises an exception if containers have been resolved already.



52
53
54
55
# File 'lib/osgi/registry.rb', line 52

def containers=(containers)
  raise "Cannot set containers, containers have been resolved already" if @resolved_containers
  @containers = containers
end

#resolved_containersObject

Resolves the containers registered in this registry. This is a long running operation where all the containers are parsed.

Containers are resolved only once.



81
82
83
84
# File 'lib/osgi/registry.rb', line 81

def resolved_containers
  @resolved_containers ||= containers.collect { |container| Container.new(container) }
  @resolved_containers
end