Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2019-12-12 13:55:26 +0000
committerThomas Watson2019-12-12 16:39:52 +0000
commit28e1dde96160e1bbbb60babe50b9be9e78887648 (patch)
tree2ea58d58d05ec81731af2e025b30cbe6486e3a16
parentad073ed3f1a50bc54e570ed82e2549a18d8b59df (diff)
downloadrt.equinox.framework-28e1dde96160e1bbbb60babe50b9be9e78887648.tar.gz
rt.equinox.framework-28e1dde96160e1bbbb60babe50b9be9e78887648.tar.xz
rt.equinox.framework-28e1dde96160e1bbbb60babe50b9be9e78887648.zip
Bug 552573 - Update OSGi Connect API
- Rename ConnectFactory to ConnectFramework - Move newFramework with ConnectFramework from FrameworkFactory to ConnectFrameworkFactory in the connect package Change-Id: I71044befd16542bc84d2fc4c9b7ffdeb8a32eba5 Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/storage.hooks.a/org/eclipse/osgi/tests/hooks/framework/storage/a/TestHelper.java5
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ConnectTests.java40
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/filter/FilterTests.java5
-rw-r--r--bundles/org.eclipse.osgi/.settings/.api_filters50
-rw-r--r--bundles/org.eclipse.osgi/META-INF/MANIFEST.MF5
-rw-r--r--bundles/org.eclipse.osgi/META-INF/services/org.osgi.framework.connect.ConnectFrameworkFactory1
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/connect/ConnectHookConfigurator.java8
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/DTOBuilder.java55
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java2
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainer.java28
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceReferenceImpl.java27
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/launch/Equinox.java6
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/launch/EquinoxFactory.java9
-rw-r--r--bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/FrameworkUtil.java61
-rw-r--r--bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/ServiceReference.java27
-rw-r--r--bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/connect/ConnectContent.java6
-rw-r--r--bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/connect/ConnectFramework.java (renamed from bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/connect/ConnectFactory.java)40
-rw-r--r--bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/connect/ConnectFrameworkFactory.java80
-rw-r--r--bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/connect/FrameworkUtilHelper.java16
-rw-r--r--bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/dto/ServiceReferenceDTO.java5
-rw-r--r--bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/launch/FrameworkFactory.java30
-rw-r--r--bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/launch/package-info.java2
22 files changed, 350 insertions, 158 deletions
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/storage.hooks.a/org/eclipse/osgi/tests/hooks/framework/storage/a/TestHelper.java b/bundles/org.eclipse.osgi.tests/bundles_src/storage.hooks.a/org/eclipse/osgi/tests/hooks/framework/storage/a/TestHelper.java
index cffc2118b..639865e59 100644
--- a/bundles/org.eclipse.osgi.tests/bundles_src/storage.hooks.a/org/eclipse/osgi/tests/hooks/framework/storage/a/TestHelper.java
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/storage.hooks.a/org/eclipse/osgi/tests/hooks/framework/storage/a/TestHelper.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.osgi.tests.hooks.framework.storage.a;
+import java.util.Optional;
import org.osgi.framework.Bundle;
import org.osgi.framework.connect.FrameworkUtilHelper;
@@ -20,8 +21,8 @@ public class TestHelper implements FrameworkUtilHelper {
volatile static Bundle testBundle;
@Override
- public Bundle getBundle(Class<?> classFromBundle) {
- return testBundle;
+ public Optional<Bundle> getBundle(Class<?> classFromBundle) {
+ return Optional.ofNullable(testBundle);
}
public static void setBundle(Bundle testBundle) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ConnectTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ConnectTests.java
index fa977dd02..147b6067c 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ConnectTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ConnectTests.java
@@ -56,10 +56,10 @@ import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.connect.ConnectContent;
import org.osgi.framework.connect.ConnectContent.ConnectEntry;
-import org.osgi.framework.connect.ConnectFactory;
+import org.osgi.framework.connect.ConnectFramework;
+import org.osgi.framework.connect.ConnectFrameworkFactory;
import org.osgi.framework.connect.ConnectModule;
import org.osgi.framework.launch.Framework;
-import org.osgi.framework.launch.FrameworkFactory;
import org.osgi.framework.wiring.BundleWiring;
import org.osgi.framework.wiring.FrameworkWiring;
@@ -69,11 +69,11 @@ public class ConnectTests extends AbstractBundleTests {
return new TestSuite(ConnectTests.class);
}
- void doTestConnect(ConnectFactory connectFactory, Map<String, String> fwkConfig, Consumer<Framework> test) {
+ void doTestConnect(ConnectFramework connectFactory, Map<String, String> fwkConfig, Consumer<Framework> test) {
File config = OSGiTestsActivator.getContext().getDataFile(getName());
config.mkdirs();
fwkConfig.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath());
- FrameworkFactory fwkFactory = new EquinoxFactory();
+ ConnectFrameworkFactory fwkFactory = new EquinoxFactory();
Framework framework = fwkFactory.newFramework(fwkConfig, connectFactory);
boolean passed = false;
try {
@@ -91,15 +91,16 @@ public class ConnectTests extends AbstractBundleTests {
}
}
- public static class TestCountingConnectFactory implements ConnectFactory {
+ public static class TestCountingConnectFramework implements ConnectFramework {
private final AtomicInteger initializeCalled = new AtomicInteger();
private final Queue<String> getModuleCalled = new ConcurrentLinkedQueue<>();
private final AtomicInteger createBundleActivatorCalled = new AtomicInteger();
private final Map<String, ConnectModule> modules = new ConcurrentHashMap<String, ConnectModule>();
@Override
- public void initialize(File storage, Map<String, String> config) {
+ public ConnectFramework initialize(File storage, Map<String, String> config) {
initializeCalled.getAndIncrement();
+ return this;
}
@Override
@@ -194,18 +195,20 @@ public class ConnectTests extends AbstractBundleTests {
@SuppressWarnings("unused")
@Override
- public void open() throws IOException {
+ public ConnectContent open() throws IOException {
if (!isOpen.compareAndSet(false, true)) {
throw new IllegalStateException("Already Opened.");
}
+ return this;
}
@SuppressWarnings("unused")
@Override
- public void close() throws IOException {
+ public ConnectContent close() throws IOException {
if (!isOpen.compareAndSet(true, false)) {
throw new IllegalStateException("Already Closed.");
}
+ return this;
}
void addEntry(String path, ConnectEntry entry) {
@@ -301,7 +304,7 @@ public class ConnectTests extends AbstractBundleTests {
static final TestConnectModule ILLEGAL_STATE_EXCEPTION = new TestConnectModule(null);
public void testConnectFactoryNoModules() {
- TestCountingConnectFactory connectFactory = new TestCountingConnectFactory();
+ TestCountingConnectFramework connectFactory = new TestCountingConnectFramework();
doTestConnect(connectFactory, new HashMap<>(), (f) -> {
try {
@@ -331,7 +334,7 @@ public class ConnectTests extends AbstractBundleTests {
public void testConnectActivator() {
final AtomicInteger bundleActvatorStartCalled = new AtomicInteger();
final AtomicInteger bundleActvatorStopCalled = new AtomicInteger();
- ConnectFactory activatorFactory = new TestCountingConnectFactory() {
+ ConnectFramework activatorConnectFramework = new TestCountingConnectFramework() {
@Override
public Optional<BundleActivator> createBundleActivator() {
super.createBundleActivator();
@@ -350,7 +353,7 @@ public class ConnectTests extends AbstractBundleTests {
}
};
- doTestConnect(activatorFactory, new HashMap<>(), (f) -> {
+ doTestConnect(activatorConnectFramework, new HashMap<>(), (f) -> {
try {
f.start();
f.stop();
@@ -370,12 +373,13 @@ public class ConnectTests extends AbstractBundleTests {
final AtomicReference<File> initFile = new AtomicReference<>();
final AtomicReference<File> storeFile = new AtomicReference<>();
final AtomicReference<Map<String, String>> initConfig = new AtomicReference<>();
- ConnectFactory activatorFactory = new TestCountingConnectFactory() {
+ ConnectFramework activatorConnectFramework = new TestCountingConnectFramework() {
@Override
- public void initialize(File storage, Map<String, String> config) {
+ public ConnectFramework initialize(File storage, Map<String, String> config) {
super.initialize(storage, config);
initFile.set(storage);
initConfig.set(config);
+ return this;
}
};
@@ -383,7 +387,7 @@ public class ConnectTests extends AbstractBundleTests {
config.put("k1", "v1");
config.put("k2", "v2");
- doTestConnect(activatorFactory, config, (f) -> {
+ doTestConnect(activatorConnectFramework, config, (f) -> {
try {
f.init();
BundleContext bc = f.getBundleContext();
@@ -411,7 +415,7 @@ public class ConnectTests extends AbstractBundleTests {
}
void doTestConnectContentSimple(boolean withManifest) throws IOException {
- TestCountingConnectFactory connectFactory = new TestCountingConnectFactory();
+ TestCountingConnectFramework connectFactory = new TestCountingConnectFramework();
final List<String> locations = Arrays.asList("b.1", "b.2", "b.3", "b.4");
for (String l : locations) {
connectFactory.setModule(l, withManifest ? createSimpleManifestModule(l) : createSimpleHeadersModule(l));
@@ -475,7 +479,7 @@ public class ConnectTests extends AbstractBundleTests {
}
void doTestConnectContentActivators(boolean provideLoader) {
- TestCountingConnectFactory connectFactory = new TestCountingConnectFactory();
+ TestCountingConnectFramework connectFactory = new TestCountingConnectFramework();
final List<Integer> ids = Arrays.asList(1, 2, 3);
for (Integer id : ids) {
connectFactory.setModule(id.toString(), createAdvancedModule(id, provideLoader));
@@ -513,7 +517,7 @@ public class ConnectTests extends AbstractBundleTests {
}
void doTestConnectContentEntries(boolean provideLoader) {
- TestCountingConnectFactory connectFactory = new TestCountingConnectFactory();
+ TestCountingConnectFramework connectFactory = new TestCountingConnectFramework();
final List<Integer> ids = Arrays.asList(1, 2, 3);
final Map<Integer, TestConnectModule> modules = new HashMap<>();
for (Integer id : ids) {
@@ -591,7 +595,7 @@ public class ConnectTests extends AbstractBundleTests {
public void testOpenCloseUpdateConnectContent() {
final String NAME1 = "testUpdate.1";
final String NAME2 = "testUpdate.2";
- TestCountingConnectFactory connectFactory = new TestCountingConnectFactory();
+ TestCountingConnectFramework connectFactory = new TestCountingConnectFramework();
TestConnectModule m = createSimpleHeadersModule(NAME1);
connectFactory.setModule(NAME1, m);
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/filter/FilterTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/filter/FilterTests.java
index 366d5bb18..4bdbeb0f7 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/filter/FilterTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/filter/FilterTests.java
@@ -477,5 +477,10 @@ public abstract class FilterTests extends TestCase {
}
return new CaseInsensitiveDictionaryMap(dictionary);
}
+
+ @Override
+ public Object adapt(Class type) {
+ return null;
+ }
}
}
diff --git a/bundles/org.eclipse.osgi/.settings/.api_filters b/bundles/org.eclipse.osgi/.settings/.api_filters
index eae320647..fa3ef9a19 100644
--- a/bundles/org.eclipse.osgi/.settings/.api_filters
+++ b/bundles/org.eclipse.osgi/.settings/.api_filters
@@ -1,12 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.osgi" version="2">
- <resource path="container/src/org/eclipse/osgi/launch/EquinoxFactory.java" type="org.eclipse.osgi.launch.EquinoxFactory">
- <filter comment="Not for OSGi API" id="1143996420">
- <message_arguments>
- <message_argument value="newFramework(Map&lt;String,String&gt;, ConnectFactory)"/>
- </message_arguments>
- </filter>
- </resource>
<resource path="osgi/src/org/osgi/framework/FrameworkUtil.java" type="org.osgi.framework.FrameworkUtil">
<filter comment="Not for OSGi API" id="1141899266">
<message_arguments>
@@ -22,6 +15,35 @@
<message_argument value="asMap(Dictionary&lt;? extends K,? extends V&gt;)"/>
</message_arguments>
</filter>
+ <filter comment="Not for OSGi API" id="1141899266">
+ <message_arguments>
+ <message_argument value="1.10"/>
+ <message_argument value="3.16"/>
+ <message_argument value="getBundle(ClassLoader)"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="osgi/src/org/osgi/framework/ServiceReference.java" type="org.osgi.framework.ServiceReference">
+ <filter comment="Not for OSGi API" id="403804204">
+ <message_arguments>
+ <message_argument value="org.osgi.framework.ServiceReference"/>
+ <message_argument value="adapt(Class&lt;A&gt;)"/>
+ </message_arguments>
+ </filter>
+ <filter id="403984517">
+ <message_arguments>
+ <message_argument value="org.osgi.framework.ServiceReference"/>
+ <message_argument value="org.osgi.framework.BundleReference"/>
+ <message_argument value="getBundle()"/>
+ </message_arguments>
+ </filter>
+ <filter comment="Not for OSGi API" id="1209008130">
+ <message_arguments>
+ <message_argument value="1.10"/>
+ <message_argument value="3.16"/>
+ <message_argument value="adapt(Class&lt;A&gt;)"/>
+ </message_arguments>
+ </filter>
</resource>
<resource path="osgi/src/org/osgi/framework/connect/ConnectContent.java" type="org.osgi.framework.connect.ConnectContent">
<filter comment="Not for OSGi API" id="1110441988">
@@ -37,6 +59,20 @@
</message_arguments>
</filter>
</resource>
+ <resource path="osgi/src/org/osgi/framework/connect/ConnectFramework.java" type="org.osgi.framework.connect.ConnectFramework">
+ <filter comment="Not for OSGi API" id="1110441988">
+ <message_arguments>
+ <message_argument value="org.osgi.framework.connect.ConnectFramework"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="osgi/src/org/osgi/framework/connect/ConnectFrameworkFactory.java" type="org.osgi.framework.connect.ConnectFrameworkFactory">
+ <filter comment="Not for OSGi API" id="1110441988">
+ <message_arguments>
+ <message_argument value="org.osgi.framework.connect.ConnectFrameworkFactory"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="osgi/src/org/osgi/framework/connect/ConnectModule.java" type="org.osgi.framework.connect.ConnectModule">
<filter comment="Not for OSGi API" id="1110441988">
<message_arguments>
diff --git a/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF
index f784484e0..97cdc8860 100644
--- a/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF
@@ -6,6 +6,7 @@ Export-Package: org.eclipse.core.runtime.adaptor;x-friends:="org.eclipse.core.ru
org.eclipse.osgi.container;version="1.5";
uses:="org.eclipse.osgi.report.resolution,
org.osgi.framework.wiring,
+ org.eclipse.osgi.framework.eventmgr,
org.osgi.framework.startlevel,
org.osgi.framework,
org.osgi.framework.hooks.resolver,
@@ -53,13 +54,13 @@ Export-Package: org.eclipse.core.runtime.adaptor;x-friends:="org.eclipse.core.ru
org.eclipse.osgi.util;version="1.1",
org.osgi.dto;version="1.1",
org.osgi.framework;version="1.10",
- org.osgi.framework.connect;version="1.0",
+ org.osgi.framework.connect;version="1.0";uses:="org.osgi.framework.launch",
org.osgi.framework.dto;version="1.8";uses:="org.osgi.dto",
org.osgi.framework.hooks.bundle;version="1.1";uses:="org.osgi.framework",
org.osgi.framework.hooks.resolver;version="1.0";uses:="org.osgi.framework.wiring",
org.osgi.framework.hooks.service;version="1.1";uses:="org.osgi.framework",
org.osgi.framework.hooks.weaving;version="1.1";uses:="org.osgi.framework.wiring",
- org.osgi.framework.launch;version="1.3";uses:="org.osgi.framework,org.osgi.framework.connect",
+ org.osgi.framework.launch;version="1.2";uses:="org.osgi.framework",
org.osgi.framework.namespace;version="1.1";uses:="org.osgi.resource",
org.osgi.framework.startlevel;version="1.0";uses:="org.osgi.framework",
org.osgi.framework.startlevel.dto;version="1.0";uses:="org.osgi.dto",
diff --git a/bundles/org.eclipse.osgi/META-INF/services/org.osgi.framework.connect.ConnectFrameworkFactory b/bundles/org.eclipse.osgi/META-INF/services/org.osgi.framework.connect.ConnectFrameworkFactory
new file mode 100644
index 000000000..6cd04c1be
--- /dev/null
+++ b/bundles/org.eclipse.osgi/META-INF/services/org.osgi.framework.connect.ConnectFrameworkFactory
@@ -0,0 +1 @@
+org.eclipse.osgi.launch.EquinoxFactory
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/connect/ConnectHookConfigurator.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/connect/ConnectHookConfigurator.java
index 98948f58c..2f4aa4fa1 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/connect/ConnectHookConfigurator.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/connect/ConnectHookConfigurator.java
@@ -41,7 +41,7 @@ import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.connect.ConnectContent;
-import org.osgi.framework.connect.ConnectFactory;
+import org.osgi.framework.connect.ConnectFramework;
import org.osgi.framework.connect.ConnectModule;
public class ConnectHookConfigurator implements HookConfigurator {
@@ -49,7 +49,7 @@ public class ConnectHookConfigurator implements HookConfigurator {
@Override
public void addHooks(final HookRegistry hookRegistry) {
final ConnectModules connectModules = hookRegistry.getContainer().getConnectModules();
- ConnectFactory connectFactory = connectModules.getConnectFactory();
+ ConnectFramework connectFramework = connectModules.getConnectFramework();
hookRegistry.addStorageHookFactory(new StorageHookFactory<Object, Object, StorageHook<Object, Object>>() {
@Override
@@ -112,7 +112,7 @@ public class ConnectHookConfigurator implements HookConfigurator {
}
});
- if (connectFactory == null) {
+ if (connectFramework == null) {
return;
}
@@ -143,7 +143,7 @@ public class ConnectHookConfigurator implements HookConfigurator {
@Override
public BundleActivator createActivator() {
final List<BundleActivator> activators = new ArrayList<>();
- connectFactory.createBundleActivator().ifPresent((a) -> activators.add(a));
+ connectFramework.createBundleActivator().ifPresent((a) -> activators.add(a));
return new BundleActivator() {
@Override
public void start(BundleContext context) throws Exception {
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/DTOBuilder.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/DTOBuilder.java
index a54e9bad6..6bec70344 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/DTOBuilder.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/DTOBuilder.java
@@ -15,17 +15,44 @@
package org.eclipse.osgi.internal.framework;
import java.lang.reflect.Array;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.IdentityHashMap;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Set;
import org.osgi.dto.DTO;
-import org.osgi.framework.*;
-import org.osgi.framework.dto.*;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
+import org.osgi.framework.dto.BundleDTO;
+import org.osgi.framework.dto.FrameworkDTO;
+import org.osgi.framework.dto.ServiceReferenceDTO;
import org.osgi.framework.startlevel.BundleStartLevel;
import org.osgi.framework.startlevel.FrameworkStartLevel;
import org.osgi.framework.startlevel.dto.BundleStartLevelDTO;
import org.osgi.framework.startlevel.dto.FrameworkStartLevelDTO;
-import org.osgi.framework.wiring.*;
-import org.osgi.framework.wiring.dto.*;
-import org.osgi.resource.dto.*;
+import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleRequirement;
+import org.osgi.framework.wiring.BundleRevision;
+import org.osgi.framework.wiring.BundleRevisions;
+import org.osgi.framework.wiring.BundleWire;
+import org.osgi.framework.wiring.BundleWiring;
+import org.osgi.framework.wiring.dto.BundleRevisionDTO;
+import org.osgi.framework.wiring.dto.BundleWireDTO;
+import org.osgi.framework.wiring.dto.BundleWiringDTO;
+import org.osgi.framework.wiring.dto.FrameworkWiringDTO;
+import org.osgi.resource.dto.CapabilityDTO;
+import org.osgi.resource.dto.CapabilityRefDTO;
+import org.osgi.resource.dto.RequirementDTO;
+import org.osgi.resource.dto.RequirementRefDTO;
+import org.osgi.resource.dto.WireDTO;
public class DTOBuilder {
private final Map<BundleRevision, BundleRevisionDTO> resources;
@@ -318,7 +345,7 @@ public class DTOBuilder {
size = references == null ? 0 : references.length;
List<ServiceReferenceDTO> refDTOs = newList(size);
for (int i = 0; i < size; i++) {
- ServiceReferenceDTO serviceRefDTO = getServiceReferenceDTO(references[i]);
+ ServiceReferenceDTO serviceRefDTO = newServiceReferenceDTO(references[i]);
if (serviceRefDTO != null) {
refDTOs.add(serviceRefDTO);
}
@@ -335,17 +362,12 @@ public class DTOBuilder {
return (Map<String, Object>) m;
}
- private static ServiceReferenceDTO getServiceReferenceDTO(ServiceReference<?> ref) {
+ public static ServiceReferenceDTO newServiceReferenceDTO(ServiceReference<?> ref) {
if (ref == null) {
return null;
}
- Bundle b = ref.getBundle();
- if (b == null) {
- // service has been unregistered
- return null;
- }
+
ServiceReferenceDTO dto = new ServiceReferenceDTO();
- dto.bundle = b.getBundleId();
String[] keys = ref.getPropertyKeys();
Map<String, Object> properties = newMap(keys.length);
for (String k : keys) {
@@ -353,6 +375,9 @@ public class DTOBuilder {
if (Constants.SERVICE_ID.equals(k)) {
dto.id = ((Long) v).longValue();
}
+ if (Constants.SERVICE_BUNDLEID.equals(k)) {
+ dto.bundle = ((Long) v).longValue();
+ }
properties.put(k, mapValue(v));
}
dto.properties = properties;
@@ -383,7 +408,7 @@ public class DTOBuilder {
final int length = references.length;
List<ServiceReferenceDTO> refDTOs = new ArrayList<>(length);
for (int i = 0; i < length; i++) {
- ServiceReferenceDTO dto = getServiceReferenceDTO(references[i]);
+ ServiceReferenceDTO dto = newServiceReferenceDTO(references[i]);
if (dto != null) {
refDTOs.add(dto);
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java
index aefaac69d..7470d3168 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java
@@ -971,7 +971,7 @@ public class EquinoxBundle implements Bundle, BundleReference {
}
/**
- * Check for permission to get a service.
+ * Check for permission to adapt.
*/
private <A> void checkAdaptPermission(Class<A> adapterType) {
SecurityManager sm = System.getSecurityManager();
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainer.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainer.java
index 5a846be1d..33a620458 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainer.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainer.java
@@ -50,7 +50,7 @@ import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
import org.osgi.framework.connect.ConnectContent;
-import org.osgi.framework.connect.ConnectFactory;
+import org.osgi.framework.connect.ConnectFramework;
import org.osgi.framework.connect.ConnectModule;
import org.osgi.service.packageadmin.PackageAdmin;
import org.osgi.service.startlevel.StartLevel;
@@ -90,7 +90,7 @@ public class EquinoxContainer implements ThreadFactory, Runnable {
private ScheduledExecutorService executor;
private StorageSaver storageSaver;
- public EquinoxContainer(Map<String, ?> configuration, ConnectFactory connectFactory) {
+ public EquinoxContainer(Map<String, ?> configuration, ConnectFramework connectFramework) {
ClassLoader platformClassLoader = null;
try {
Method getPlatformClassLoader = ClassLoader.class.getMethod("getPlatformClassLoader"); //$NON-NLS-1$
@@ -104,9 +104,9 @@ public class EquinoxContainer implements ThreadFactory, Runnable {
this.equinoxConfig = new EquinoxConfiguration(configuration, new HookRegistry(this));
this.logServices = new EquinoxLogServices(this.equinoxConfig);
this.equinoxConfig.logMessages(this.logServices);
- this.connectModules = new ConnectModules(connectFactory);
+ this.connectModules = new ConnectModules(connectFramework);
- initConnectFactory(connectFactory, this.equinoxConfig);
+ initConnectFramework(connectFramework, this.equinoxConfig);
this.equinoxConfig.getHookRegistry().initialize();
try {
@@ -152,15 +152,15 @@ public class EquinoxContainer implements ThreadFactory, Runnable {
isProcessClassRecursionSupportedByAll = supportRecursion;
}
- private static void initConnectFactory(ConnectFactory connectFactory, EquinoxConfiguration equinoxConfig) {
- if (connectFactory == null) {
+ private static void initConnectFramework(ConnectFramework connectFramework, EquinoxConfiguration equinoxConfig) {
+ if (connectFramework == null) {
return;
}
URL configUrl = equinoxConfig.getEquinoxLocations().getConfigurationLocation().getURL();
final File fwkStore = new File(configUrl.getPath());
@SuppressWarnings({"rawtypes", "unchecked"})
Map<String, String> config = (Map) equinoxConfig.getInitialConfig();
- connectFactory.initialize(fwkStore, Collections.unmodifiableMap(config));
+ connectFramework.initialize(fwkStore, Collections.unmodifiableMap(config));
}
public Storage getStorage() {
@@ -367,20 +367,20 @@ public class EquinoxContainer implements ThreadFactory, Runnable {
}
public static class ConnectModules {
- final ConnectFactory connectFactory;
+ final ConnectFramework connectFramework;
private final ConcurrentMap<String, ConnectModule> connectModules = new ConcurrentHashMap<>();
- public ConnectModules(ConnectFactory connectFactory) {
- this.connectFactory = connectFactory;
+ public ConnectModules(ConnectFramework connectFramework) {
+ this.connectFramework = connectFramework;
}
public ConnectModule getConnectModule(String location) {
- if (connectFactory == null) {
+ if (connectFramework == null) {
return null;
}
ConnectModule result = connectModules.computeIfAbsent(location, (l) -> {
try {
- return connectFactory.getModule(location).orElse(NULL_MODULE);
+ return connectFramework.getModule(location).orElse(NULL_MODULE);
} catch (IllegalStateException e) {
return NULL_MODULE;
}
@@ -388,8 +388,8 @@ public class EquinoxContainer implements ThreadFactory, Runnable {
return result == NULL_MODULE ? null : result;
}
- public ConnectFactory getConnectFactory() {
- return connectFactory;
+ public ConnectFramework getConnectFramework() {
+ return connectFramework;
}
}
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceReferenceImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceReferenceImpl.java
index a1887a767..aca9b9ad5 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceReferenceImpl.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceReferenceImpl.java
@@ -15,7 +15,14 @@
package org.eclipse.osgi.internal.serviceregistry;
import java.util.Dictionary;
-import org.osgi.framework.*;
+import org.eclipse.osgi.internal.framework.DTOBuilder;
+import org.osgi.framework.AdaptPermission;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.dto.ServiceReferenceDTO;
/**
* A reference to a service.
@@ -318,4 +325,22 @@ public class ServiceReferenceImpl<S> implements ServiceReference<S> {
public Dictionary<String, Object> getProperties() {
return registration.getPropertiesCopy();
}
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <A> A adapt(Class<A> type) {
+ checkAdaptPermission(type);
+ if (ServiceReferenceDTO.class.equals(type)) {
+ return (A) DTOBuilder.newServiceReferenceDTO(this);
+ }
+ return null;
+ }
+
+ private <A> void checkAdaptPermission(Class<A> adapterType) {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null) {
+ return;
+ }
+ sm.checkPermission(new AdaptPermission(adapterType.getName(), registration.getRegisteringBundle(), AdaptPermission.ADAPT));
+ }
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/launch/Equinox.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/launch/Equinox.java
index f960f8707..d380836dc 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/launch/Equinox.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/launch/Equinox.java
@@ -30,7 +30,7 @@ import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.FrameworkListener;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.Version;
-import org.osgi.framework.connect.ConnectFactory;
+import org.osgi.framework.connect.ConnectFramework;
import org.osgi.framework.launch.Framework;
/**
@@ -49,8 +49,8 @@ public class Equinox implements Framework {
/**
* @since 3.16
*/
- public Equinox(Map<String, ?> configuration, ConnectFactory connectFactory) {
- EquinoxContainer container = new EquinoxContainer(configuration, connectFactory);
+ public Equinox(Map<String, ?> configuration, ConnectFramework connectFramework) {
+ EquinoxContainer container = new EquinoxContainer(configuration, connectFramework);
systemBundle = (Framework) container.getStorage().getModuleContainer().getModule(0).getBundle();
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/launch/EquinoxFactory.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/launch/EquinoxFactory.java
index c997d5246..43000efe8 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/launch/EquinoxFactory.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/launch/EquinoxFactory.java
@@ -14,7 +14,8 @@
package org.eclipse.osgi.launch;
import java.util.Map;
-import org.osgi.framework.connect.ConnectFactory;
+import org.osgi.framework.connect.ConnectFramework;
+import org.osgi.framework.connect.ConnectFrameworkFactory;
import org.osgi.framework.launch.Framework;
import org.osgi.framework.launch.FrameworkFactory;
@@ -22,7 +23,7 @@ import org.osgi.framework.launch.FrameworkFactory;
* The framework factory implementation for the Equinox framework.
* @since 3.5
*/
-public class EquinoxFactory implements FrameworkFactory {
+public class EquinoxFactory implements FrameworkFactory, ConnectFrameworkFactory {
@Override
public Framework newFramework(Map<String, String> configuration) {
@@ -30,7 +31,7 @@ public class EquinoxFactory implements FrameworkFactory {
}
@Override
- public Framework newFramework(Map<String, String> configuration, ConnectFactory connectFactory) {
- return new Equinox(configuration, connectFactory);
+ public Framework newFramework(Map<String, String> configuration, ConnectFramework connectFramework) {
+ return new Equinox(configuration, connectFramework);
}
}
diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/FrameworkUtil.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/FrameworkUtil.java
index 8bd7c5b44..0c31d9f7b 100644
--- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/FrameworkUtil.java
+++ b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/FrameworkUtil.java
@@ -37,6 +37,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
+import java.util.Optional;
import java.util.ServiceLoader;
import java.util.Set;
@@ -203,33 +204,45 @@ public class FrameworkUtil {
}
/**
- * Return a {@code Bundle} for the specified bundle class. The returned
- * {@code Bundle} is the bundle associated with the bundle class loader
- * which defined the specified class.
+ * Return a {@code Bundle} for the specified bundle class loader.
*
- * @param classFromBundle A class defined by a bundle class loader.
+ * @param bundleClassLoader A bundle class loader.
+ * @return An Optional containing {@code Bundle} for the specified bundle
+ * class loader or an empty Optional if the specified class loader
+ * is not associated with a specific bundle.
+ * @since 1.10
+ */
+ public static Optional<Bundle> getBundle(ClassLoader bundleClassLoader) {
+ requireNonNull(bundleClassLoader);
+ return Optional
+ .ofNullable((bundleClassLoader instanceof BundleReference)
+ ? ((BundleReference) bundleClassLoader).getBundle()
+ : null);
+ }
+
+ /**
+ * Return a {@code Bundle} for the specified bundle class.
+ *
+ * @param classFromBundle A class defined by a bundle.
* @return A {@code Bundle} for the specified bundle class or {@code null}
- * if the specified class was not defined by a bundle class loader.
+ * if the specified class was not defined by a bundle.
* @since 1.5
*/
- public static Bundle getBundle(final Class<?> classFromBundle) {
+ public static Bundle getBundle(Class< ? > classFromBundle) {
// We use doPriv since the caller may not have permission
// to call getClassLoader.
- ClassLoader cl = AccessController
- .doPrivileged( (PrivilegedAction<ClassLoader>)
- () -> classFromBundle.getClassLoader());
-
- if (cl instanceof BundleReference) {
- return ((BundleReference) cl).getBundle();
- }
-
- for (FrameworkUtilHelper helper : helpers) {
- Bundle b = helper.getBundle(classFromBundle);
- if (b != null) {
- return b;
- }
- }
- return null;
+ Optional<ClassLoader> cl = Optional
+ .ofNullable(AccessController.doPrivileged(
+ (PrivilegedAction<ClassLoader>) () -> classFromBundle
+ .getClassLoader()));
+
+ return cl.flatMap(FrameworkUtil::getBundle)
+ .orElseGet(() -> helpers.stream()
+ .map(helper -> helper.getBundle(classFromBundle))
+ .filter(Optional::isPresent)
+ .map(Optional::get)
+ .findFirst()
+ .orElse(null));
}
private final static List<FrameworkUtilHelper> helpers;
@@ -240,9 +253,9 @@ public class FrameworkUtil {
.doPrivileged(
(PrivilegedAction<ServiceLoader<FrameworkUtilHelper>>) () -> ServiceLoader
.load(FrameworkUtilHelper.class,
- FrameworkUtilHelper.class.getClassLoader()));
-
- helperLoader.forEach((h) -> l.add(h));
+ FrameworkUtilHelper.class
+ .getClassLoader()));
+ helperLoader.forEach(l::add);
} catch (Throwable error) {
// try hard not to fail static <clinit>
try {
diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/ServiceReference.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/ServiceReference.java
index 1454244c3..4d412aa61 100644
--- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/ServiceReference.java
+++ b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/ServiceReference.java
@@ -53,7 +53,8 @@ import org.osgi.annotation.versioning.ProviderType;
* @author $Id$
*/
@ProviderType
-public interface ServiceReference<S> extends Comparable<Object> {
+public interface ServiceReference<S>
+ extends Comparable<Object>, BundleReference {
/**
* Returns the property value to which the specified property key is mapped
* in the properties {@code Dictionary} object of the service referenced by
@@ -109,6 +110,7 @@ public interface ServiceReference<S> extends Comparable<Object> {
* already been unregistered.
* @see BundleContext#registerService(String[],Object,Dictionary)
*/
+ @Override
public Bundle getBundle();
/**
@@ -212,4 +214,27 @@ public interface ServiceReference<S> extends Comparable<Object> {
* @since 1.9
*/
public Dictionary<String,Object> getProperties();
+
+ /**
+ * Adapt this {@code ServiceReference} object to the specified type.
+ * <p>
+ * Adapting this {@code ServiceReference} object to the specified type may
+ * require certain checks, including security checks, to succeed. If a check
+ * does not succeed, then this {@code ServiceReference} object cannot be
+ * adapted and {@code null} is returned.
+ *
+ * @param <A> The type to which this {@code ServiceReference} object is to
+ * be adapted.
+ * @param type Class object for the type to which this
+ * {@code ServiceReference} object is to be adapted.
+ * @return The object, of the specified type, to which this
+ * {@code ServiceReference} object has been adapted or {@code null}
+ * if this {@code ServiceReference} object cannot be adapted to the
+ * specified type.
+ * @throws SecurityException If the caller does not have the appropriate
+ * {@code AdaptPermission[type,this,ADAPT]}, and the Java
+ * Runtime Environment supports permissions.
+ * @since 1.10
+ */
+ <A> A adapt(Class<A> type);
}
diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/connect/ConnectContent.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/connect/ConnectContent.java
index 1d3691dbb..a109b609c 100644
--- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/connect/ConnectContent.java
+++ b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/connect/ConnectContent.java
@@ -95,16 +95,18 @@ public interface ConnectContent {
* connect content. The framework may lazily open the content until the
* first request is made to access the bundle revision content.
*
+ * @return a reference to this object
* @throws IOException if an error occurred opening the content
*/
- void open() throws IOException;
+ ConnectContent open() throws IOException;
/**
* Closes this connect content.
*
+ * @return a reference to this object
* @throws IOException if an error occurred closing the connect content
*/
- void close() throws IOException;
+ ConnectContent close() throws IOException;
/**
* Represents the entry of a connect module
diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/connect/ConnectFactory.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/connect/ConnectFramework.java
index 31e1a83a2..a1f4f0adc 100644
--- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/connect/ConnectFactory.java
+++ b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/connect/ConnectFramework.java
@@ -22,29 +22,28 @@ import java.util.Optional;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.Constants;
import org.osgi.framework.launch.Framework;
-import org.osgi.framework.launch.FrameworkFactory;
/**
- * A connect factory creates instances of {@link ConnectModule} that are used by
- * a {@link Framework} instance to provide content and classes for a bundle
- * installed in the Framework. A connect factory is provided when
- * {@link FrameworkFactory#newFramework(java.util.Map) creating} a framework
- * instance. Because a connect factory instance can participate in the
- * initialization of the framework and the lifecycle of a framework instance the
- * connect factory instance should only be used with a single framework
- * instance.
+ * A connect framework provides access to instances of {@link ConnectModule}
+ * that are used by a {@link Framework} instance to provide content and classes
+ * for a bundle installed in the Framework. A connect framework is provided when
+ * {@link ConnectFrameworkFactory#newFramework(java.util.Map, ConnectFramework)
+ * creating} a framework instance. Because a connect framework instance can
+ * participate in the initialization of the framework and the life cycle of a
+ * framework instance the connect framework instance should only be used with a
+ * single framework instance.
*
* @ThreadSafe
* @author $Id$
*/
-public interface ConnectFactory {
+public interface ConnectFramework {
/**
- * Initializes the connect factory with the
+ * Initializes the connect framework with the
* {@link Constants#FRAMEWORK_STORAGE framework persistent storage} file and
* framework properties configured for a {@link Framework} instance. This
* method is called once by a {@link Framework} instance and is called
- * before any other methods on this factory are called.
+ * before any other methods on this connect framework are called.
*
* @param configuration The framework properties to used configure the new
* framework instance. An unmodifiable map of framework
@@ -53,8 +52,9 @@ public interface ConnectFactory {
* @param storage the persistent storage area used by the {@link Framework}
* or {@code null} if the if the platform does not have file
* system support.
+ * @return a reference to this object
*/
- void initialize(File storage, Map<String,String> configuration);
+ ConnectFramework initialize(File storage, Map<String,String> configuration);
/**
* Returns the connect module for the specified bundle location. If an
@@ -71,19 +71,19 @@ public interface ConnectFactory {
Optional<ConnectModule> getModule(String location);
/**
- * Creates a new activator for this factory. A new activator is created by
- * the framework each time the framework is {@link Framework#init()
- * initialized}. An activator allows the factory to participate in the
- * framework lifecyle. When the framework is {@link Framework#init()
- * initialized} the activator
+ * Creates a new activator for this connect framework. A new activator is
+ * created by the framework each time the framework is
+ * {@link Framework#init() initialized}. An activator allows the connect
+ * framework to participate in the framework life cyle. When the framework
+ * is {@link Framework#init() initialized} the activator
* {@link BundleActivator#start(org.osgi.framework.BundleContext) start}
* method is called. When the framework is {@link Framework#stop() stopped}
* the activator
* {@link BundleActivator#stop(org.osgi.framework.BundleContext) stop}
* method is called
*
- * @return a new activator for this factory or {@link Optional#empty()
- * empty} if no activator is available for the factory
+ * @return a new activator for this connect framework or
+ * {@link Optional#empty() empty} if no activator is available
*/
Optional<BundleActivator> createBundleActivator();
} \ No newline at end of file
diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/connect/ConnectFrameworkFactory.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/connect/ConnectFrameworkFactory.java
new file mode 100644
index 000000000..cb596326b
--- /dev/null
+++ b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/connect/ConnectFrameworkFactory.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) OSGi Alliance (2019). All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.osgi.framework.connect;
+
+import java.util.Map;
+
+import org.osgi.annotation.versioning.ProviderType;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.launch.Framework;
+
+/**
+ * A factory for creating {@link Framework} instances.
+ * <p>
+ * If a framework supports {@link ConnectFramework} then the implementation jar
+ * must contain the following resource:
+ *
+ * <pre>
+ * /META-INF/services/org.osgi.framework.connect.ConnectFrameworkFactory
+ * </pre>
+ *
+ * This UTF-8 encoded resource must contain the name of the framework
+ * implementation's ConnectFrameworkFactory implementation class. Space and tab
+ * characters, including blank lines, in the resource must be ignored. The
+ * number sign ({@code '#'} &#92;u0023) and all characters following it on each
+ * line are a comment and must be ignored.
+ * <p>
+ * Launchers can find the name of the ConnectFrameworkFactory implementation
+ * class in the resource and then load and construct a ConnectFrameworkFactory
+ * object for the framework implementation. The ConnectFrameworkFactory
+ * implementation class must have a public, no-argument constructor. Java&#8482;
+ * SE 6 introduced the {@code ServiceLoader} class which can create a
+ * ConnectFrameworkFactory instance from the resource.
+ *
+ * @ThreadSafe
+ * @author $Id$
+ */
+@ProviderType
+public interface ConnectFrameworkFactory {
+ /**
+ * Create a new {@link Framework} instance using the specified
+ * {@link ConnectFramework connect framework}.
+ *
+ * @param configuration The framework properties to configure the new
+ * framework instance. If framework properties are not provided
+ * by the configuration argument, the created framework instance
+ * must use some reasonable default configuration appropriate for
+ * the current VM. For example, the system packages for the
+ * current execution environment should be properly exported. The
+ * specified configuration argument may be {@code null}. The
+ * created framework instance must copy any information needed
+ * from the specified configuration argument since the
+ * configuration argument can be changed after the framework
+ * instance has been created.
+ * @param connectFramework The connect framework that the new framework
+ * instance will use. The specified connect framework argument
+ * may be {@code null}.
+ * @return A new, configured {@link Framework} instance. The framework
+ * instance must be in the {@link Bundle#INSTALLED} state.
+ * @throws SecurityException If the caller does not have
+ * {@code AllPermission}, and the Java Runtime Environment
+ * supports permissions.
+ * @see ConnectFramework
+ * @since 1.3
+ */
+ Framework newFramework(Map<String,String> configuration,
+ ConnectFramework connectFramework);
+}
diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/connect/FrameworkUtilHelper.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/connect/FrameworkUtilHelper.java
index 8c8da1842..3b1164ea6 100644
--- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/connect/FrameworkUtilHelper.java
+++ b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/connect/FrameworkUtilHelper.java
@@ -16,6 +16,8 @@
package org.osgi.framework.connect;
+import java.util.Optional;
+
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
@@ -27,15 +29,15 @@ public interface FrameworkUtilHelper {
/**
* Return a {@code Bundle} associated with the specified class.
* <p>
- * This helper method is called by
- * {@link FrameworkUtil#getBundle(Class)} if the standard implementation
- * of {@code FrameworkUtil} cannot find the bundle.
+ * This helper method is called by {@link FrameworkUtil#getBundle(Class)} if
+ * the standard implementation of {@code FrameworkUtil} cannot find the
+ * bundle.
*
* @param classFromBundle A class associated with a bundle
- * @return A {@code Bundle} for the specified class or {@code null} if
- * the specified class is not from a bundle.
+ * @return An Optional containing a {@code Bundle} for the specified class
+ * or an empty Optional if the specified class is not from a bundle.
*/
- default Bundle getBundle(Class< ? > classFromBundle) {
- return null;
+ default Optional<Bundle> getBundle(Class< ? > classFromBundle) {
+ return Optional.empty();
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/dto/ServiceReferenceDTO.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/dto/ServiceReferenceDTO.java
index 87265ded2..40c0eda3a 100644
--- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/dto/ServiceReferenceDTO.java
+++ b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/dto/ServiceReferenceDTO.java
@@ -17,16 +17,17 @@
package org.osgi.framework.dto;
import java.util.Map;
+
import org.osgi.dto.DTO;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
/**
* Data Transfer Object for a ServiceReference.
- *
* <p>
* {@code ServiceReferenceDTO}s for all registered services can be obtained from
- * a {@link FrameworkDTO}. A started Bundle can be adapted to provide a
+ * a {@link FrameworkDTO}. A {@link ServiceReference} can be adapted to a
+ * {@code ServiceReferenceDTO}. A started Bundle can be adapted to provide a
* {@code ServiceReferenceDTO[]} of the services registered by the Bundle. A
* {@code ServiceReferenceDTO} obtained from a framework must convert service
* property values which are not valid value types for DTOs to type
diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/launch/FrameworkFactory.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/launch/FrameworkFactory.java
index eb28dcaad..5f20eb739 100644
--- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/launch/FrameworkFactory.java
+++ b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/launch/FrameworkFactory.java
@@ -20,7 +20,6 @@ import java.util.Map;
import org.osgi.annotation.versioning.ProviderType;
import org.osgi.framework.Bundle;
-import org.osgi.framework.connect.ConnectFactory;
/**
* A factory for creating {@link Framework} instances.
@@ -72,33 +71,4 @@ public interface FrameworkFactory {
* permissions.
*/
Framework newFramework(Map<String, String> configuration);
-
- /**
- * Create a new {@link Framework} instance using the specified
- * {@link ConnectFactory connect factory}.
- *
- * @param configuration The framework properties to configure the new
- * framework instance. If framework properties are not provided
- * by the configuration argument, the created framework instance
- * must use some reasonable default configuration appropriate for
- * the current VM. For example, the system packages for the
- * current execution environment should be properly exported. The
- * specified configuration argument may be {@code null}. The
- * created framework instance must copy any information needed
- * from the specified configuration argument since the
- * configuration argument can be changed after the framework
- * instance has been created.
- * @param connectFactory The connect factory that the new framework instance
- * will use. The specified connect factory argument may be
- * {@code null}.
- * @return A new, configured {@link Framework} instance. The framework
- * instance must be in the {@link Bundle#INSTALLED} state.
- * @throws SecurityException If the caller does not have
- * {@code AllPermission}, and the Java Runtime Environment
- * supports permissions.
- * @see ConnectFactory
- * @since 1.3
- */
- Framework newFramework(Map<String,String> configuration,
- ConnectFactory connectFactory);
}
diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/launch/package-info.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/launch/package-info.java
index b4e9d8e0e..db5e926ca 100644
--- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/launch/package-info.java
+++ b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/launch/package-info.java
@@ -29,7 +29,7 @@
* @author $Id$
*/
-@Version("1.3")
+@Version("1.2")
package org.osgi.framework.launch;
import org.osgi.annotation.versioning.Version;

Back to the top