osgi 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +176 -0
- data/NOTICE +6 -0
- data/README.rdoc +50 -0
- data/Rakefile +45 -0
- data/lib/osgi.rb +24 -0
- data/lib/osgi/bundle.rb +201 -0
- data/lib/osgi/bundle_package.rb +104 -0
- data/lib/osgi/container.rb +145 -0
- data/lib/osgi/execution_environment.rb +199 -0
- data/lib/osgi/registry.rb +137 -0
- data/lib/osgi/resolving_strategies.rb +107 -0
- data/lib/osgi/version.rb +131 -0
- data/osgi.gemspec +36 -0
- data/spec/osgi/bundle_package_spec.rb +44 -0
- data/spec/osgi/bundle_spec.rb +94 -0
- data/spec/osgi/container_spec.rb +89 -0
- data/spec/osgi/execution_environment_spec.rb +48 -0
- data/spec/osgi/registry_spec.rb +84 -0
- data/spec/osgi/resolving_strategies_spec.rb +116 -0
- data/spec/osgi/version_spec.rb +133 -0
- data/spec/spec_helpers.rb +131 -0
- metadata +94 -0
@@ -0,0 +1,104 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
module OSGi #:nodoc:
|
17
|
+
|
18
|
+
# A class to represent an OSGi bundle package.
|
19
|
+
# Created from the Import-Package or Provide-Package (Export-Package) header.
|
20
|
+
#
|
21
|
+
class BundlePackage
|
22
|
+
attr_accessor :name, :version, :bundles, :imports, :is_export, :original_version, :optional
|
23
|
+
|
24
|
+
def initialize(name, version, args = {}) #:nodoc:
|
25
|
+
@name= name
|
26
|
+
@is_export = args[:is_export]
|
27
|
+
@optional = args[:optional]
|
28
|
+
@original_version = version
|
29
|
+
if version
|
30
|
+
v = version.gsub(/\"/, '')
|
31
|
+
v = VersionRange.parse(v, true)
|
32
|
+
v ||= v
|
33
|
+
@version = v
|
34
|
+
end
|
35
|
+
@bundles = args[:bundles] || []
|
36
|
+
@imports = args[:imports] || []
|
37
|
+
end
|
38
|
+
|
39
|
+
#
|
40
|
+
# Resolves the matching artifacts associated with the project.
|
41
|
+
#
|
42
|
+
def resolve_matching_artifacts
|
43
|
+
# Collect the bundle projects
|
44
|
+
# and extend them with the BundleProjectMatcher module
|
45
|
+
b_projects = BundleProjects::bundle_projects.select {|p|
|
46
|
+
p.extend BundleProjectMatcher
|
47
|
+
p.matches(:exports_package => name, :version => version)
|
48
|
+
}
|
49
|
+
warn "*** SPLIT PACKAGE: #{self} is exported by more than one project: <#{b_projects.join(", ")}> ABORTING!" if b_projects.size > 1
|
50
|
+
return b_projects unless b_projects.empty?
|
51
|
+
|
52
|
+
resolved = OSGi.registry.resolved_containers.collect {|i| i.find(:exports_package => name, :version => version)}
|
53
|
+
resolved.flatten.compact.collect{|b| b.dup}
|
54
|
+
end
|
55
|
+
|
56
|
+
# Resolves the bundles that export this package.
|
57
|
+
#
|
58
|
+
def resolve(bundles = resolve_matching_artifacts)
|
59
|
+
bundles = case bundles.size
|
60
|
+
when 0 then []
|
61
|
+
when 1 then bundles
|
62
|
+
else
|
63
|
+
bundles = PackageResolvingStrategies.send(OSGi.options.package_resolving_strategy, name, bundles)
|
64
|
+
end
|
65
|
+
if bundles.empty?
|
66
|
+
|
67
|
+
return [] if OSGi.is_framework_package?(name) # Is the bundle part of the packages provided by default ?
|
68
|
+
|
69
|
+
|
70
|
+
trace "original version: #{original_version}"
|
71
|
+
if optional
|
72
|
+
info "No bundles found exporting the optional package #{name};version=#{version} (#{original_version})"
|
73
|
+
else
|
74
|
+
warn "No bundles found exporting the package #{name};version=#{version} (#{original_version})"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
bundles
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
def to_s #:nodoc:
|
82
|
+
"Package #{name}; version #{version}"
|
83
|
+
end
|
84
|
+
|
85
|
+
# Important for maps.
|
86
|
+
# We absolutely want to avoid having to resolve several times the same package
|
87
|
+
#
|
88
|
+
def hash
|
89
|
+
return to_s.hash
|
90
|
+
end
|
91
|
+
|
92
|
+
# We just test the name and version as we want to be able to see if an unresolved package and a resolved one represent the same
|
93
|
+
# bundle package.
|
94
|
+
def ==(other)
|
95
|
+
return false unless other.is_a? BundlePackage
|
96
|
+
eql = name == other.name
|
97
|
+
eql |= version.nil? ? other.version.nil? : version == other.version
|
98
|
+
eql
|
99
|
+
end
|
100
|
+
|
101
|
+
alias :eql? :==
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
require "manifest"
|
17
|
+
|
18
|
+
module OSGi #:nodoc:
|
19
|
+
|
20
|
+
# This class represents an OSGi container.
|
21
|
+
# It contains the bundles, fragments, and the location of the OSGi container.
|
22
|
+
# A typical OSGi container is an Eclipse instance.
|
23
|
+
#
|
24
|
+
class Container
|
25
|
+
|
26
|
+
# bundles: the bundles of the eclipse instance loaded on startup
|
27
|
+
# location: the location of the Eclipse instance
|
28
|
+
attr_reader :bundles, :fragments, :location
|
29
|
+
|
30
|
+
# Default constructor for a Container
|
31
|
+
#
|
32
|
+
# location: the location of the Eclipse instance
|
33
|
+
# plugin_locations, default value is ["dropins", "plugins"]
|
34
|
+
# create_bundle_info, default value is true
|
35
|
+
def initialize(location, plugin_locations = ["dropins", "plugins"])
|
36
|
+
@location = location
|
37
|
+
@bundles = []
|
38
|
+
@fragments = []
|
39
|
+
plugin_locations.each do |p_loc|
|
40
|
+
p_loc_complete = File.join(@location, p_loc)
|
41
|
+
warn "Folder #{p_loc_complete} not found!" if !File.exists? p_loc_complete
|
42
|
+
parse(p_loc_complete) if File.exists? p_loc_complete
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Parses the directory and grabs the plugins, adding the created bundle objects to @bundles.
|
47
|
+
def parse(dir)
|
48
|
+
Dir.open(dir) do |plugins|
|
49
|
+
plugins.entries.each do |plugin|
|
50
|
+
absolute_plugin_path = "#{plugins.path}#{File::SEPARATOR}#{plugin}"
|
51
|
+
if (/.*\.jar$/.match(plugin))
|
52
|
+
zipfile = Zip::ZipFile.open(absolute_plugin_path)
|
53
|
+
entry = zipfile.find_entry("META-INF/MANIFEST.MF")
|
54
|
+
if (entry != nil)
|
55
|
+
manifest = Manifest.read(zipfile.read("META-INF/MANIFEST.MF"))
|
56
|
+
bundle = Bundle.fromManifest(manifest, absolute_plugin_path)
|
57
|
+
if bundle.nil?
|
58
|
+
elsif bundle.fragment?
|
59
|
+
@fragments << bundle
|
60
|
+
else
|
61
|
+
@bundles << bundle
|
62
|
+
end
|
63
|
+
end
|
64
|
+
zipfile.close
|
65
|
+
else
|
66
|
+
# take care of the folder
|
67
|
+
if (File.directory?(absolute_plugin_path) && !(plugin == "." || plugin == ".."))
|
68
|
+
if (!File.exists? ["#{absolute_plugin_path}", "META-INF", "MANIFEST.MF"].join(File::SEPARATOR))
|
69
|
+
#recursive approach: we have a folder wih no MANIFEST.MF, we should look into it.
|
70
|
+
parse(absolute_plugin_path)
|
71
|
+
else
|
72
|
+
next if File.exists? "#{absolute_plugin_path}/feature.xml" # avoid parsing features.
|
73
|
+
begin
|
74
|
+
manifest = Manifest.read((file = File.open("#{absolute_plugin_path}/META-INF/MANIFEST.MF")).read)
|
75
|
+
rescue
|
76
|
+
file.close
|
77
|
+
end
|
78
|
+
bundle = Bundle.fromManifest(manifest, absolute_plugin_path)
|
79
|
+
if bundle.nil?
|
80
|
+
elsif bundle.fragment?
|
81
|
+
@fragments << bundle
|
82
|
+
else
|
83
|
+
@bundles << bundle
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
@bundles = @bundles.compact
|
91
|
+
@fragments = @fragments.compact
|
92
|
+
end
|
93
|
+
|
94
|
+
# Return the list of bundles and fragments that match the criteria passed as arguments
|
95
|
+
# Possible criterias:
|
96
|
+
# name: the name of the bundle
|
97
|
+
# version: the version of the bundle
|
98
|
+
# exports_package: a package exported by the bundle
|
99
|
+
def find(criteria = {})
|
100
|
+
selected = bundles + fragments
|
101
|
+
|
102
|
+
if (criteria[:name])
|
103
|
+
selected = selected.select {|b| b.name == criteria[:name]}
|
104
|
+
end
|
105
|
+
if (criteria[:exports_package])
|
106
|
+
selected = selected.select {|b|
|
107
|
+
!(b.exported_packages.select {|package|
|
108
|
+
package.name == criteria[:exports_package] &&
|
109
|
+
(criteria[:version].nil? || criteria[:version].in_range(package.version))
|
110
|
+
}.empty?)
|
111
|
+
}
|
112
|
+
else
|
113
|
+
if (criteria[:version])
|
114
|
+
if criteria[:version].is_a?(VersionRange)
|
115
|
+
selected = selected.select {|b| criteria[:version].in_range(b.version)}
|
116
|
+
else
|
117
|
+
selected = selected.select {|b| b.version == criteria[:version]}
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
selected
|
122
|
+
end
|
123
|
+
|
124
|
+
# Return the list of fragments that match the criteria passed as arguments
|
125
|
+
# Possible criterias:
|
126
|
+
# host: the name of the host bundle
|
127
|
+
# version: the version of the bundle
|
128
|
+
#
|
129
|
+
def find_fragments(criteria = {:host => "", :version => ""})
|
130
|
+
selected = fragments
|
131
|
+
if (criteria[:host])
|
132
|
+
selected = selected.select {|b| b.fragment.name == criteria[:host]}
|
133
|
+
end
|
134
|
+
if (criteria[:version])
|
135
|
+
selected = selected.select {|b| b.fragment.version == criteria[:version]}
|
136
|
+
end
|
137
|
+
selected
|
138
|
+
end
|
139
|
+
|
140
|
+
def ==(other)
|
141
|
+
false unless other.is_a? Container
|
142
|
+
return location == other.location
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
@@ -0,0 +1,199 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
module OSGi
|
17
|
+
|
18
|
+
# The notion of profile in OSGi refers to the execution environment: SDK, loaded libraries in LD_LIBRARY_PATH.
|
19
|
+
# A set of default execution environments is defined by the OSGi specifications.
|
20
|
+
class ExecutionEnvironment
|
21
|
+
|
22
|
+
attr_reader :name, :description, :packages
|
23
|
+
|
24
|
+
def initialize(name, description, packages)
|
25
|
+
@name = name
|
26
|
+
@description = description
|
27
|
+
@packages = packages.is_a?(Array) ? packages : [packages]
|
28
|
+
@packages.freeze
|
29
|
+
freeze
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
# No profile.
|
35
|
+
NONE = ExecutionEnvironment.new("None", "None", [])
|
36
|
+
|
37
|
+
# The standard CDC-1.0/Foundation-1.0 profile
|
38
|
+
CDC10FOUNDATION10 = ExecutionEnvironment.new("CDC-1.0/Foundation-1.0", "Equal to J2ME Foundation Profile", ["javax.microedition.io"])
|
39
|
+
|
40
|
+
# The standard CDC-1.0/Foundation-1.1 profile
|
41
|
+
CDC10FOUNDATION11 = ExecutionEnvironment.new("CDC-1.0/Foundation-1.1", "Equal to J2ME Foundation Profile", ["javax.microedition.io","javax.microedition.pki",
|
42
|
+
"javax.security.auth.x500"])
|
43
|
+
|
44
|
+
# The standard J2SE-1.2 profile
|
45
|
+
J2SE12 = ExecutionEnvironment.new("J2SE-1.2", "Java 2 Platform, Standard Edition 1.2", %w{javax.accessibility javax.swing javax.swing.border javax.swing.colorchooser javax.swing.event javax.swing.filechooser
|
46
|
+
javax.swing.plaf javax.swing.plaf.basic javax.swing.plaf.metal javax.swing.plaf.multi javax.swing.table javax.swing.text javax.swing.text.html
|
47
|
+
javax.swing.text.html.parser javax.swing.text.rtf javax.swing.tree javax.swing.undo org.omg.CORBA org.omg.CORBA.DynAnyPackage org.omg.CORBA.ORBPackage
|
48
|
+
org.omg.CORBA.portable org.omg.CORBA.TypeCodePackage org.omg.CosNaming org.omg.CosNaming.NamingContextPackage})
|
49
|
+
|
50
|
+
# The standard J2SE-1.3 profile
|
51
|
+
J2SE13 = ExecutionEnvironment.new("J2SE-1.3", "Java 2 Platform, Standard Edition 1.3", %w{javax.accessibility javax.naming javax.naming.directory javax.naming.event javax.naming.ldap
|
52
|
+
javax.naming.spi javax.rmi javax.rmi.CORBA javax.sound.midi javax.sound.midi.spi javax.sound.sampled javax.sound.sampled.spi javax.swing javax.swing.border
|
53
|
+
javax.swing.colorchooser javax.swing.event javax.swing.filechooser javax.swing.plaf javax.swing.plaf.basic javax.swing.plaf.metal javax.swing.plaf.multi
|
54
|
+
javax.swing.table javax.swing.text javax.swing.text.html javax.swing.text.html.parser javax.swing.text.rtf javax.swing.tree javax.swing.undo javax.transaction
|
55
|
+
org.omg.CORBA org.omg.CORBA_2_3 org.omg.CORBA_2_3.portable org.omg.CORBA.DynAnyPackage org.omg.CORBA.ORBPackage org.omg.CORBA.portable
|
56
|
+
org.omg.CORBA.TypeCodePackage org.omg.CosNaming org.omg.CosNaming.NamingContextPackage org.omg.SendingContext org.omg.stub.java.rmi})
|
57
|
+
|
58
|
+
# The standard J2SE-1.4 profile
|
59
|
+
J2SE14 = ExecutionEnvironment.new("J2SE-1.4", "Java 2 Platform, Standard Edition 1.4", %w{javax.accessibility javax.crypto javax.crypto.interfaces javax.crypto.spec javax.imageio
|
60
|
+
javax.imageio.event javax.imageio.metadata javax.imageio.plugins.jpeg javax.imageio.spi javax.imageio.stream javax.naming javax.naming.directory javax.naming.event
|
61
|
+
javax.naming.ldap javax.naming.spi javax.net javax.net.ssl javax.print javax.print.attribute javax.print.attribute.standard javax.print.event javax.rmi
|
62
|
+
javax.rmi.CORBA javax.security.auth javax.security.auth.callback javax.security.auth.kerberos javax.security.auth.login javax.security.auth.spi
|
63
|
+
javax.security.auth.x500 javax.security.cert javax.sound.midi javax.sound.midi.spi javax.sound.sampled javax.sound.sampled.spi javax.sql javax.swing
|
64
|
+
javax.swing.border javax.swing.colorchooser javax.swing.event javax.swing.filechooser javax.swing.plaf javax.swing.plaf.basic javax.swing.plaf.metal
|
65
|
+
javax.swing.plaf.multi javax.swing.table javax.swing.text javax.swing.text.html javax.swing.text.html.parser javax.swing.text.rtf javax.swing.tree
|
66
|
+
javax.swing.undo javax.transaction javax.transaction.xa javax.xml.parsers javax.xml.transform javax.xml.transform.dom javax.xml.transform.sax
|
67
|
+
javax.xml.transform.stream org.ietf.jgss org.omg.CORBA org.omg.CORBA_2_3 org.omg.CORBA_2_3.portable org.omg.CORBA.DynAnyPackage org.omg.CORBA.ORBPackage
|
68
|
+
org.omg.CORBA.portable org.omg.CORBA.TypeCodePackage org.omg.CosNaming org.omg.CosNaming.NamingContextExtPackage org.omg.CosNaming.NamingContextPackage
|
69
|
+
org.omg.Dynamic org.omg.DynamicAny org.omg.DynamicAny.DynAnyFactoryPackage org.omg.DynamicAny.DynAnyPackage org.omg.IOP org.omg.IOP.CodecFactoryPackage
|
70
|
+
org.omg.IOP.CodecPackage org.omg.Messaging org.omg.PortableInterceptor org.omg.PortableInterceptor.ORBInitInfoPackage org.omg.PortableServer
|
71
|
+
org.omg.PortableServer.CurrentPackage org.omg.PortableServer.POAManagerPackage org.omg.PortableServer.POAPackage org.omg.PortableServer.portable
|
72
|
+
org.omg.PortableServer.ServantLocatorPackage org.omg.SendingContext org.omg.stub.java.rmi org.w3c.dom org.w3c.dom.css org.w3c.dom.events
|
73
|
+
org.w3c.dom.html org.w3c.dom.stylesheets org.w3c.dom.views org.xml.sax org.xml.sax.ext org.xml.sax.helpers})
|
74
|
+
|
75
|
+
# The standard J2SE-1.5 profile
|
76
|
+
J2SE15 = ExecutionEnvironment.new("J2SE-1.5", "Java 2 Platform, Standard Edition 5.0", %w{javax.accessibility javax.activity javax.crypto javax.crypto.interfaces
|
77
|
+
javax.crypto.spec javax.imageio javax.imageio.event
|
78
|
+
javax.imageio.metadata javax.imageio.plugins.bmp javax.imageio.plugins.jpeg javax.imageio.spi javax.imageio.stream javax.management javax.management.loading
|
79
|
+
javax.management.modelmbean javax.management.monitor javax.management.openmbean javax.management.relation javax.management.remote javax.management.remote.rmi
|
80
|
+
javax.management.timer javax.naming javax.naming.directory javax.naming.event javax.naming.ldap javax.naming.spi javax.net javax.net.ssl javax.print
|
81
|
+
javax.print.attribute javax.print.attribute.standard javax.print.event javax.rmi javax.rmi.CORBA javax.rmi.ssl javax.security.auth javax.security.auth.callback
|
82
|
+
javax.security.auth.kerberos javax.security.auth.login javax.security.auth.spi javax.security.auth.x500 javax.security.cert javax.security.sasl javax.sound.midi
|
83
|
+
javax.sound.midi.spi javax.sound.sampled javax.sound.sampled.spi javax.sql javax.sql.rowset javax.sql.rowset.serial javax.sql.rowset.spi javax.swing
|
84
|
+
javax.swing.border javax.swing.colorchooser javax.swing.event javax.swing.filechooser javax.swing.plaf javax.swing.plaf.basic javax.swing.plaf.metal
|
85
|
+
javax.swing.plaf.multi javax.swing.plaf.synth javax.swing.table javax.swing.text javax.swing.text.html javax.swing.text.html.parser javax.swing.text.rtf
|
86
|
+
javax.swing.tree javax.swing.undo javax.transaction javax.transaction.xa javax.xml javax.xml.datatype javax.xml.namespace javax.xml.parsers javax.xml.transform
|
87
|
+
javax.xml.transform.dom javax.xml.transform.sax javax.xml.transform.stream javax.xml.validation javax.xml.xpath org.ietf.jgss org.omg.CORBA org.omg.CORBA_2_3
|
88
|
+
org.omg.CORBA_2_3.portable org.omg.CORBA.DynAnyPackage org.omg.CORBA.ORBPackage org.omg.CORBA.portable org.omg.CORBA.TypeCodePackage org.omg.CosNaming
|
89
|
+
org.omg.CosNaming.NamingContextExtPackage org.omg.CosNaming.NamingContextPackage org.omg.Dynamic org.omg.DynamicAny org.omg.DynamicAny.DynAnyFactoryPackage
|
90
|
+
org.omg.DynamicAny.DynAnyPackage org.omg.IOP org.omg.IOP.CodecFactoryPackage org.omg.IOP.CodecPackage org.omg.Messaging org.omg.PortableInterceptor
|
91
|
+
org.omg.PortableInterceptor.ORBInitInfoPackage org.omg.PortableServer org.omg.PortableServer.CurrentPackage org.omg.PortableServer.POAManagerPackage
|
92
|
+
org.omg.PortableServer.POAPackage org.omg.PortableServer.portable org.omg.PortableServer.ServantLocatorPackage org.omg.SendingContext org.omg.stub.java.rmi
|
93
|
+
org.w3c.dom org.w3c.dom.bootstrap org.w3c.dom.css org.w3c.dom.events org.w3c.dom.html org.w3c.dom.ls org.w3c.dom.ranges org.w3c.dom.stylesheets
|
94
|
+
org.w3c.dom.traversal org.w3c.dom.views org.xml.sax org.xml.sax.ext org.xml.sax.helpers})
|
95
|
+
|
96
|
+
# The standard JavaSE-1.6 profile
|
97
|
+
JAVASE16 = ExecutionEnvironment.new("JavaSE-1.6", "Java Platform, Standard Edition 6.0", %w{javax.accessibility javax.activation javax.activity
|
98
|
+
javax.annotation javax.annotation.processing javax.crypto javax.crypto.interfaces
|
99
|
+
javax.crypto.spec javax.imageio javax.imageio.event javax.imageio.metadata javax.imageio.plugins.bmp javax.imageio.plugins.jpeg javax.imageio.spi
|
100
|
+
javax.imageio.stream javax.jws javax.jws.soap javax.lang.model javax.lang.model.element javax.lang.model.type javax.lang.model.util javax.management
|
101
|
+
javax.management.loading javax.management.modelmbean javax.management.monitor javax.management.openmbean javax.management.relation javax.management.remote
|
102
|
+
javax.management.remote.rmi javax.management.timer javax.naming javax.naming.directory javax.naming.event javax.naming.ldap javax.naming.spi javax.net
|
103
|
+
javax.net.ssl javax.print javax.print.attribute javax.print.attribute.standard javax.print.event javax.rmi javax.rmi.CORBA javax.rmi.ssl javax.script
|
104
|
+
javax.security.auth javax.security.auth.callback javax.security.auth.kerberos javax.security.auth.login javax.security.auth.spi javax.security.auth.x500
|
105
|
+
javax.security.cert javax.security.sasl javax.sound.midi javax.sound.midi.spi javax.sound.sampled javax.sound.sampled.spi javax.sql javax.sql.rowset
|
106
|
+
javax.sql.rowset.serial javax.sql.rowset.spi javax.swing javax.swing.border javax.swing.colorchooser javax.swing.event javax.swing.filechooser
|
107
|
+
javax.swing.plaf javax.swing.plaf.basic javax.swing.plaf.metal javax.swing.plaf.multi javax.swing.plaf.synth javax.swing.table javax.swing.text
|
108
|
+
javax.swing.text.html javax.swing.text.html.parser javax.swing.text.rtf javax.swing.tree javax.swing.undo javax.tools javax.transaction
|
109
|
+
javax.transaction.xa javax.xml javax.xml.bind javax.xml.bind.annotation javax.xml.bind.annotation.adapters javax.xml.bind.attachment
|
110
|
+
javax.xml.bind.helpers javax.xml.bind.util javax.xml.crypto javax.xml.crypto.dom javax.xml.crypto.dsig javax.xml.crypto.dsig.dom
|
111
|
+
javax.xml.crypto.dsig.keyinfo javax.xml.crypto.dsig.spec javax.xml.datatype javax.xml.namespace javax.xml.parsers javax.xml.soap javax.xml.stream
|
112
|
+
javax.xml.stream.events javax.xml.stream.util javax.xml.transform javax.xml.transform.dom javax.xml.transform.sax javax.xml.transform.stax
|
113
|
+
javax.xml.transform.stream javax.xml.validation javax.xml.ws javax.xml.ws.handler javax.xml.ws.handler.soap javax.xml.ws.http javax.xml.ws.soap
|
114
|
+
javax.xml.ws.spi javax.xml.xpath org.ietf.jgss org.omg.CORBA org.omg.CORBA_2_3 org.omg.CORBA_2_3.portable org.omg.CORBA.DynAnyPackage
|
115
|
+
org.omg.CORBA.ORBPackage org.omg.CORBA.portable org.omg.CORBA.TypeCodePackage org.omg.CosNaming org.omg.CosNaming.NamingContextExtPackage
|
116
|
+
org.omg.CosNaming.NamingContextPackage org.omg.Dynamic org.omg.DynamicAny org.omg.DynamicAny.DynAnyFactoryPackage org.omg.DynamicAny.DynAnyPackage
|
117
|
+
org.omg.IOP org.omg.IOP.CodecFactoryPackage org.omg.IOP.CodecPackage org.omg.Messaging org.omg.PortableInterceptor
|
118
|
+
org.omg.PortableInterceptor.ORBInitInfoPackage org.omg.PortableServer org.omg.PortableServer.CurrentPackage org.omg.PortableServer.POAManagerPackage
|
119
|
+
org.omg.PortableServer.POAPackage org.omg.PortableServer.portable org.omg.PortableServer.ServantLocatorPackage org.omg.SendingContext
|
120
|
+
org.omg.stub.java.rmi org.w3c.dom org.w3c.dom.bootstrap org.w3c.dom.css org.w3c.dom.events org.w3c.dom.html org.w3c.dom.ls org.w3c.dom.ranges
|
121
|
+
org.w3c.dom.stylesheets org.w3c.dom.traversal org.w3c.dom.views org.xml.sax org.xml.sax.ext org.xml.sax.helpers})
|
122
|
+
|
123
|
+
JAVASE17 = ExecutionEnvironment.new("JavaSE-1.7", "Java SE 1.7.x (early access)", %w{javax.accessibility javax.activation javax.activity javax.annotation javax.annotation.processing
|
124
|
+
javax.crypto javax.crypto.interfaces javax.crypto.spec javax.imageio javax.imageio.event javax.imageio.metadata javax.imageio.plugins.bmp
|
125
|
+
javax.imageio.plugins.jpeg javax.imageio.spi javax.imageio.stream javax.jws javax.jws.soap javax.lang.model javax.lang.model.element javax.lang.model.type
|
126
|
+
javax.lang.model.util javax.management javax.management.loading javax.management.modelmbean javax.management.monitor javax.management.openmbean
|
127
|
+
javax.management.relation javax.management.remote javax.management.remote.rmi javax.management.timer javax.naming javax.naming.directory javax.naming.event
|
128
|
+
javax.naming.ldap javax.naming.spi javax.net javax.net.ssl javax.print javax.print.attribute javax.print.attribute.standard javax.print.event javax.rmi
|
129
|
+
javax.rmi.CORBA javax.rmi.ssl javax.script javax.security.auth javax.security.auth.callback javax.security.auth.kerberos javax.security.auth.login
|
130
|
+
javax.security.auth.spi javax.security.auth.x500 javax.security.cert javax.security.sasl javax.sound.midi javax.sound.midi.spi javax.sound.sampled
|
131
|
+
javax.sound.sampled.spi javax.sql javax.sql.rowset javax.sql.rowset.serial javax.sql.rowset.spi javax.swing javax.swing.border javax.swing.colorchooser
|
132
|
+
javax.swing.event javax.swing.filechooser javax.swing.plaf javax.swing.plaf.basic javax.swing.plaf.metal javax.swing.plaf.multi javax.swing.plaf.synth
|
133
|
+
javax.swing.table javax.swing.text javax.swing.text.html javax.swing.text.html.parser javax.swing.text.rtf javax.swing.tree javax.swing.undo javax.tools
|
134
|
+
javax.transaction javax.transaction.xa javax.xml javax.xml.bind javax.xml.bind.annotation javax.xml.bind.annotation.adapters javax.xml.bind.attachment
|
135
|
+
javax.xml.bind.helpers javax.xml.bind.util javax.xml.crypto javax.xml.crypto.dom javax.xml.crypto.dsig javax.xml.crypto.dsig.dom javax.xml.crypto.dsig.keyinfo
|
136
|
+
javax.xml.crypto.dsig.spec javax.xml.datatype javax.xml.namespace javax.xml.parsers javax.xml.soap javax.xml.stream javax.xml.stream.events javax.xml.stream.util
|
137
|
+
javax.xml.transform javax.xml.transform.dom javax.xml.transform.sax javax.xml.transform.stax javax.xml.transform.stream javax.xml.validation javax.xml.ws
|
138
|
+
javax.xml.ws.handler javax.xml.ws.handler.soap javax.xml.ws.http javax.xml.ws.soap javax.xml.ws.spi javax.xml.xpath org.ietf.jgss org.omg.CORBA org.omg.CORBA_2_3
|
139
|
+
org.omg.CORBA_2_3.portable org.omg.CORBA.DynAnyPackage org.omg.CORBA.ORBPackage org.omg.CORBA.portable org.omg.CORBA.TypeCodePackage org.omg.CosNaming
|
140
|
+
org.omg.CosNaming.NamingContextExtPackage org.omg.CosNaming.NamingContextPackage org.omg.Dynamic org.omg.DynamicAny org.omg.DynamicAny.DynAnyFactoryPackage
|
141
|
+
org.omg.DynamicAny.DynAnyPackage org.omg.IOP org.omg.IOP.CodecFactoryPackage org.omg.IOP.CodecPackage org.omg.Messaging org.omg.PortableInterceptor
|
142
|
+
org.omg.PortableInterceptor.ORBInitInfoPackage org.omg.PortableServer org.omg.PortableServer.CurrentPackage org.omg.PortableServer.POAManagerPackage
|
143
|
+
org.omg.PortableServer.POAPackage org.omg.PortableServer.portable org.omg.PortableServer.ServantLocatorPackage org.omg.SendingContext org.omg.stub.java.rmi
|
144
|
+
org.w3c.dom org.w3c.dom.bootstrap org.w3c.dom.css org.w3c.dom.events org.w3c.dom.html org.w3c.dom.ls org.w3c.dom.ranges org.w3c.dom.stylesheets
|
145
|
+
org.w3c.dom.traversal org.w3c.dom.views org.xml.sax org.xml.sax.ext org.xml.sax.helpers})
|
146
|
+
|
147
|
+
OSGIMINIMUM10 = ExecutionEnvironment.new("OSGi/Minimum-1.0", "OSGi EE that is a minimal set that allows the implementation of an OSGi Framework", [])
|
148
|
+
OSGIMINIMUM11 = ExecutionEnvironment.new("OSGi/Minimum-1.1", "OSGi EE that is a minimal set that allows the implementation of an OSGi Framework", [])
|
149
|
+
OSGIMINIMUM12 = ExecutionEnvironment.new("OSGi/Minimum-1.2", "OSGi EE that is a minimal set that allows the implementation of an OSGi Framework", [])
|
150
|
+
|
151
|
+
# The execution environment configuration class
|
152
|
+
# represents how to dispose of execution environments.
|
153
|
+
# The default execution environments are initialized in the constructor.
|
154
|
+
#
|
155
|
+
class ExecutionEnvironmentConfiguration
|
156
|
+
|
157
|
+
attr_accessor :extra_packages, :execution_environment
|
158
|
+
|
159
|
+
# Constructor
|
160
|
+
def initialize
|
161
|
+
@extra_packages = []
|
162
|
+
@available_ee = {}
|
163
|
+
|
164
|
+
register_execution_environment(NONE)
|
165
|
+
register_execution_environment(CDC10FOUNDATION10)
|
166
|
+
register_execution_environment(CDC10FOUNDATION11)
|
167
|
+
register_execution_environment(J2SE12)
|
168
|
+
register_execution_environment(J2SE13)
|
169
|
+
register_execution_environment(J2SE14)
|
170
|
+
register_execution_environment(J2SE15)
|
171
|
+
register_execution_environment(JAVASE16)
|
172
|
+
register_execution_environment(JAVASE17)
|
173
|
+
register_execution_environment(OSGIMINIMUM10)
|
174
|
+
register_execution_environment(OSGIMINIMUM11)
|
175
|
+
register_execution_environment(OSGIMINIMUM12)
|
176
|
+
|
177
|
+
@execution_environment = JAVASE16.name
|
178
|
+
end
|
179
|
+
|
180
|
+
#
|
181
|
+
# Returns the current execution environment.
|
182
|
+
# By default we return JavaSE-1.6
|
183
|
+
#
|
184
|
+
def current_execution_environment
|
185
|
+
@available_ee[@execution_environment]
|
186
|
+
end
|
187
|
+
|
188
|
+
# Registers an execution enviroment in the configuration.
|
189
|
+
# This method should be used to register additional execution environments using an extension.
|
190
|
+
#
|
191
|
+
def register_execution_environment(ee)
|
192
|
+
raise "Cannot register this execution environment" unless ee.is_a? ExecutionEnvironment
|
193
|
+
available_ee[ee.name] = ee
|
194
|
+
end
|
195
|
+
|
196
|
+
attr_accessor :available_ee
|
197
|
+
|
198
|
+
end
|
199
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
require 'singleton'
|
17
|
+
|
18
|
+
module OSGi
|
19
|
+
|
20
|
+
OSGI_GROUP_ID = "osgi"
|
21
|
+
|
22
|
+
class GroupMatcher
|
23
|
+
include Singleton
|
24
|
+
attr_accessor :group_matchers
|
25
|
+
|
26
|
+
def initialize
|
27
|
+
@group_matchers = []
|
28
|
+
# Default rule for Eclipse artifacts.
|
29
|
+
@group_matchers << Proc.new {|n| "org.eclipse" if n.match(/org\.eclipse\..*/) }
|
30
|
+
end
|
31
|
+
|
32
|
+
def group(bundle)
|
33
|
+
return group(bundle.id) if bundle.is_a?(Bundle)
|
34
|
+
group_matchers.reverse.each do |group|
|
35
|
+
result = group.call(bundle)
|
36
|
+
return result unless result.nil?
|
37
|
+
end
|
38
|
+
OSGI_GROUP_ID
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
#
|
43
|
+
# A class to hold the registered containers. It is possible to add containers until resolved_containers is called,
|
44
|
+
# after which it is not possible to modify the registry anymore.
|
45
|
+
#
|
46
|
+
class Registry
|
47
|
+
|
48
|
+
#
|
49
|
+
# Sets the containers of the registry
|
50
|
+
# Raises an exception if containers have been resolved already.
|
51
|
+
#
|
52
|
+
def containers=(containers)
|
53
|
+
raise "Cannot set containers, containers have been resolved already" if @resolved_containers
|
54
|
+
@containers = containers
|
55
|
+
end
|
56
|
+
|
57
|
+
#
|
58
|
+
# Returns the containers associated with this registry.
|
59
|
+
# The list of containers is modifiable if resolved_containers hasn't been called yet.
|
60
|
+
#
|
61
|
+
def containers
|
62
|
+
unless @containers
|
63
|
+
@containers = read_containers
|
64
|
+
if ENV['OSGI'] && !ENV['OSGi']
|
65
|
+
warn "The correct constant to define for the OSGi containers is named OSGi"
|
66
|
+
ENV['OSGi'] = ENV['OSGI']
|
67
|
+
end
|
68
|
+
if ENV['OSGi']
|
69
|
+
@containers |= ENV['OSGi'].split(';')
|
70
|
+
end
|
71
|
+
end
|
72
|
+
@resolved_containers.nil? ? @containers : @containers.dup.freeze
|
73
|
+
end
|
74
|
+
|
75
|
+
#
|
76
|
+
# Resolves the containers registered in this registry.
|
77
|
+
# This is a long running operation where all the containers are parsed.
|
78
|
+
#
|
79
|
+
# Containers are resolved only once.
|
80
|
+
#
|
81
|
+
def resolved_containers
|
82
|
+
@resolved_containers ||= containers.collect { |container| Container.new(container) }
|
83
|
+
@resolved_containers
|
84
|
+
end
|
85
|
+
|
86
|
+
protected
|
87
|
+
|
88
|
+
#
|
89
|
+
# Reads the containers from a configuration file.
|
90
|
+
# By default it returns an empty array.
|
91
|
+
#
|
92
|
+
def read_containers
|
93
|
+
[]
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# The options for the osgi.options method
|
98
|
+
# package_resolving_strategy:
|
99
|
+
# The package resolving strategy, it should be a symbol representing a module function in the OSGi::PackageResolvingStrategies module.
|
100
|
+
# bundle_resolving_strategy:
|
101
|
+
# The bundle resolving strategy, it should be a symbol representing a module function in the OSGi::BundleResolvingStrategies module.
|
102
|
+
# group_matchers:
|
103
|
+
# A set of Proc objects to match a bundle to a groupId for maven.
|
104
|
+
# The array is examined with the latest added Procs first.
|
105
|
+
# The first proc to return a non-nil answer is used, otherwise the OGSGI_GROUP_ID constant is used.
|
106
|
+
class Options < ::OSGi::ExecutionEnvironmentConfiguration
|
107
|
+
attr_accessor :package_resolving_strategy, :bundle_resolving_strategy
|
108
|
+
|
109
|
+
def initialize
|
110
|
+
super
|
111
|
+
@package_resolving_strategy = :all
|
112
|
+
@bundle_resolving_strategy = :latest
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
# Calls to this method return true if the package name passed as argument
|
117
|
+
# is either part of the packages of the framework given by the execution environment
|
118
|
+
# or part of the extra packages specified by the user.
|
119
|
+
#
|
120
|
+
def is_framework_package?(name)
|
121
|
+
options.current_execution_environment.packages.include?(name) || options.extra_packages.include?(name)
|
122
|
+
end
|
123
|
+
|
124
|
+
# Options for the framework resolution.
|
125
|
+
#
|
126
|
+
def options
|
127
|
+
@options ||= Options.new
|
128
|
+
end
|
129
|
+
|
130
|
+
#
|
131
|
+
# Returns the registry
|
132
|
+
#
|
133
|
+
def registry
|
134
|
+
@registry ||= ::OSGi::Registry.new
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|