Class: OSGi::Registry

Inherits:
Object show all
Defined in:
lib/buildr4osgi/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.



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/buildr4osgi/osgi/registry.rb', line 59

def containers
  unless @containers
    @containers = [Buildr.settings.user, Buildr.settings.build].inject([]) { |repos, hash|
      repos | Array(hash['osgi'] && hash['osgi']['containers'])
    }
    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.



50
51
52
53
# File 'lib/buildr4osgi/osgi/registry.rb', line 50

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.



77
78
79
80
# File 'lib/buildr4osgi/osgi/registry.rb', line 77

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