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.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/buildr4osgi/osgi/registry.rb', line 74

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



65
66
67
68
# File 'lib/buildr4osgi/osgi/registry.rb', line 65

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

#release_toObject



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

def release_to
  unless @release_to
    prefs = Buildr.settings.build
    @release_to = prefs['osgi']['release_to'].strip unless prefs['osgi'].nil? || prefs['osgi']['release_to'].nil?
    @release_to ||= "#{ENV['HOME']}/.m2/osgi"
  end
  @release_to
end

#release_to=(release_to) ⇒ Object



57
58
59
# File 'lib/buildr4osgi/osgi/registry.rb', line 57

def release_to=(release_to)
  @release_to = release_to
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.



96
97
98
99
# File 'lib/buildr4osgi/osgi/registry.rb', line 96

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