Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnjum Fatima2020-02-11 19:24:31 +0000
committerAnjum Fatima2020-02-11 20:38:25 +0000
commit2cf35ecfe61ac1df4e9f1003cf862c023ce24366 (patch)
tree7b4bac149dddf0bd409baab26d2a1053253b1146
parent4f46832028bc86417a8d71c8f053f71542c153f5 (diff)
downloadrt.equinox.framework-2cf35ecfe61ac1df4e9f1003cf862c023ce24366.tar.gz
rt.equinox.framework-2cf35ecfe61ac1df4e9f1003cf862c023ce24366.tar.xz
rt.equinox.framework-2cf35ecfe61ac1df4e9f1003cf862c023ce24366.zip
Bug 559840 - [OSGi R8] Bundle install or update with stream must
override calls to ModuleConnector Change-Id: I224f899acb57946b6a24c46dd591571555de4c18 Signed-off-by: Anjum Fatima <anjum.eclipse@gmail.com>
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/AbstractBundleTests.java17
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ConnectTests.java102
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/DiscardBundleTests.java19
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/connect/ConnectHookConfigurator.java18
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java11
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java10
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainer.java22
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java93
8 files changed, 174 insertions, 118 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/AbstractBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/AbstractBundleTests.java
index 74ad42fc7..ee2f835eb 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/AbstractBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/AbstractBundleTests.java
@@ -278,4 +278,21 @@ public class AbstractBundleTests extends CoreTest {
}
}
+ protected static boolean delete(File file) {
+ if (file.exists()) {
+ if (file.isDirectory()) {
+ String list[] = file.list();
+ if (list != null) {
+ int len = list.length;
+ for (int i = 0; i < len; i++) {
+ delete(new File(file, list[i]));
+ }
+ }
+ }
+
+ return file.delete();
+ }
+ return (true);
+ }
+
} \ No newline at end of file
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 40067d2d9..2e40f4715 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
@@ -78,6 +78,10 @@ public class ConnectTests extends AbstractBundleTests {
return new TestSuite(ConnectTests.class);
}
+ void cleanStorage() {
+ delete(getContext().getDataFile(getName()));
+ }
+
void doTestConnect(ModuleConnector moduleConnector, Map<String, String> fwkConfig, Consumer<Framework> test) {
doTestConnect(moduleConnector, fwkConfig, test, false);
}
@@ -317,9 +321,9 @@ public class ConnectTests extends AbstractBundleTests {
static final TestConnectModule BUNDLE_EXCEPTION = new TestConnectModule(null);
public void testConnectFactoryNoModules() {
- TestCountingModuleConnector connectFactory = new TestCountingModuleConnector();
+ TestCountingModuleConnector connector = new TestCountingModuleConnector();
- doTestConnect(connectFactory, new HashMap<>(), (f) -> {
+ doTestConnect(connector, new HashMap<>(), (f) -> {
try {
f.start();
f.stop();
@@ -331,7 +335,7 @@ public class ConnectTests extends AbstractBundleTests {
sneakyThrow(t);
}
});
- doTestConnect(connectFactory, new HashMap<>(), (f) -> {
+ doTestConnect(connector, new HashMap<>(), (f) -> {
try {
f.start();
f.stop();
@@ -340,8 +344,8 @@ public class ConnectTests extends AbstractBundleTests {
}
});
- assertEquals("Wrong number of init called.", 2, connectFactory.getInitializeCnt());
- assertEquals("Wrong number of create activator called.", 3, connectFactory.getCreateBundleActivatorCnt());
+ assertEquals("Wrong number of init called.", 2, connector.getInitializeCnt());
+ assertEquals("Wrong number of create activator called.", 3, connector.getCreateBundleActivatorCnt());
}
public void testConnectActivator() {
@@ -427,13 +431,13 @@ public class ConnectTests extends AbstractBundleTests {
}
void doTestConnectContentSimple(boolean withManifest) throws IOException {
- TestCountingModuleConnector connectFactory = new TestCountingModuleConnector();
+ TestCountingModuleConnector connector = new TestCountingModuleConnector();
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));
+ connector.setModule(l, withManifest ? createSimpleManifestModule(l) : createSimpleHeadersModule(l));
}
- doTestConnect(connectFactory, new HashMap<>(), (f) -> {
+ doTestConnect(connector, new HashMap<>(), (f) -> {
try {
f.init();
for (String l : locations) {
@@ -447,7 +451,7 @@ public class ConnectTests extends AbstractBundleTests {
}
});
- doTestConnect(connectFactory, new HashMap<>(), (f) -> {
+ doTestConnect(connector, new HashMap<>(), (f) -> {
try {
f.init();
Bundle[] bundles = f.getBundleContext().getBundles();
@@ -464,9 +468,9 @@ public class ConnectTests extends AbstractBundleTests {
}
});
- connectFactory.setModule("b.2", null);
- connectFactory.setModule("b.3", BUNDLE_EXCEPTION);
- doTestConnect(connectFactory, new HashMap<>(), (f) -> {
+ connector.setModule("b.2", null);
+ connector.setModule("b.3", BUNDLE_EXCEPTION);
+ doTestConnect(connector, new HashMap<>(), (f) -> {
try {
f.init();
Bundle[] bundles = f.getBundleContext().getBundles();
@@ -515,13 +519,13 @@ public class ConnectTests extends AbstractBundleTests {
}
void doTestConnectContentActivators(boolean provideLoader) {
- TestCountingModuleConnector connectFactory = new TestCountingModuleConnector();
+ TestCountingModuleConnector connector = new TestCountingModuleConnector();
final List<Integer> ids = Arrays.asList(1, 2, 3);
for (Integer id : ids) {
- connectFactory.setModule(id.toString(), createAdvancedModule(id, provideLoader));
+ connector.setModule(id.toString(), createAdvancedModule(id, provideLoader));
}
- doTestConnect(connectFactory, new HashMap<>(), (f) -> {
+ doTestConnect(connector, new HashMap<>(), (f) -> {
try {
f.start();
for (Integer id : ids) {
@@ -553,16 +557,16 @@ public class ConnectTests extends AbstractBundleTests {
}
void doTestConnectContentEntries(boolean provideLoader) {
- TestCountingModuleConnector connectFactory = new TestCountingModuleConnector();
+ TestCountingModuleConnector connector = new TestCountingModuleConnector();
final List<Integer> ids = Arrays.asList(1, 2, 3);
final Map<Integer, TestConnectModule> modules = new HashMap<>();
for (Integer id : ids) {
TestConnectModule m = createAdvancedModule(id, provideLoader);
modules.put(id, m);
- connectFactory.setModule(id.toString(), m);
+ connector.setModule(id.toString(), m);
}
- doTestConnect(connectFactory, new HashMap<>(), (f) -> {
+ doTestConnect(connector, new HashMap<>(), (f) -> {
try {
f.start();
for (Integer id : ids) {
@@ -631,11 +635,11 @@ public class ConnectTests extends AbstractBundleTests {
public void testOpenCloseUpdateConnectContent() {
final String NAME1 = "testUpdate.1";
final String NAME2 = "testUpdate.2";
- TestCountingModuleConnector connectFactory = new TestCountingModuleConnector();
+ TestCountingModuleConnector connector = new TestCountingModuleConnector();
TestConnectModule m = createSimpleHeadersModule(NAME1);
- connectFactory.setModule(NAME1, m);
+ connector.setModule(NAME1, m);
- doTestConnect(connectFactory, new HashMap<>(), (f) -> {
+ doTestConnect(connector, new HashMap<>(), (f) -> {
try {
f.start();
Bundle b = f.getBundleContext().installBundle(NAME1);
@@ -681,10 +685,10 @@ public class ConnectTests extends AbstractBundleTests {
void doTestConnectBundleHeaders(boolean withSignedHook, boolean withManifest) throws IOException {
final String NAME1 = "bundle1";
final String NAME2 = "bundle2";
- TestCountingModuleConnector connectFactory = new TestCountingModuleConnector();
+ TestCountingModuleConnector connector = new TestCountingModuleConnector();
TestConnectModule m = withManifest ? createSimpleManifestModule(NAME1) : createSimpleHeadersModule(NAME1);
- connectFactory.setModule(NAME1, m);
- doTestConnect(connectFactory, new HashMap<>(), (f) -> {
+ connector.setModule(NAME1, m);
+ doTestConnect(connector, new HashMap<>(), (f) -> {
try {
f.start();
Bundle b = f.getBundleContext().installBundle(NAME1);
@@ -718,10 +722,10 @@ public class ConnectTests extends AbstractBundleTests {
final AtomicReference<Dictionary<String, String>> headers1 = new AtomicReference<>();
final AtomicReference<Dictionary<String, String>> headers2 = new AtomicReference<>();
- TestCountingModuleConnector connectFactory = new TestCountingModuleConnector();
+ TestCountingModuleConnector connector = new TestCountingModuleConnector();
TestConnectModule m = createSimpleHeadersModule(NAME);
- connectFactory.setModule(NAME, m);
- doTestConnect(connectFactory, new HashMap<>(), (f) -> {
+ connector.setModule(NAME, m);
+ doTestConnect(connector, new HashMap<>(), (f) -> {
try {
f.start();
Bundle b = f.getBundleContext().installBundle(NAME);
@@ -734,7 +738,7 @@ public class ConnectTests extends AbstractBundleTests {
}
});
- doTestConnect(connectFactory, new HashMap<>(), (f) -> {
+ doTestConnect(connector, new HashMap<>(), (f) -> {
try {
f.start();
Bundle b = f.getBundleContext().getBundle(NAME);
@@ -759,6 +763,48 @@ public class ConnectTests extends AbstractBundleTests {
}
}
+ public void testInstallUpdateWithInputStream() throws Exception {
+ dotestInstallUpdate(false, false);
+ dotestInstallUpdate(false, true);
+ dotestInstallUpdate(true, false);
+ dotestInstallUpdate(true, true);
+ }
+
+ void dotestInstallUpdate(boolean installWithInputStream, boolean updateWithInputStream) throws Exception {
+ final InputStream in1 = installWithInputStream ? new URL(installer.getBundleLocation("test")).openStream() : null;
+ final InputStream in2 = updateWithInputStream ? new URL(installer.getBundleLocation("test2")).openStream() : null;
+ final String NAME1 = installWithInputStream ? "test1" : "bundle1";
+ final String NAME2 = updateWithInputStream ? "test2" : "bundle2";
+
+ TestCountingModuleConnector connector = new TestCountingModuleConnector();
+
+ TestConnectModule m = createSimpleHeadersModule(NAME1);
+ connector.setModule(NAME1, m);
+
+ doTestConnect(connector, new HashMap<>(), (f) -> {
+ try {
+ f.start();
+ Bundle test = f.getBundleContext().installBundle(NAME1, in1);
+ assertEquals("Wrong name.", NAME1, test.getSymbolicName());
+ if (installWithInputStream) {
+ assertNotNull("Resource not found", test.getResource("stuff/data/resource1"));
+ }
+ m.setContent(createSimpleHeadersContent(NAME2));
+ test.update(in2);
+ assertEquals("Wrong name.", NAME2, test.getSymbolicName());
+ if (updateWithInputStream) {
+ assertNotNull("Resource not found", test.getResource("stuff/data/resource2"));
+ }
+ f.stop();
+ f.waitForStop(5000);
+ } catch (Throwable t) {
+ sneakyThrow(t);
+ } finally {
+ cleanStorage();
+ }
+ });
+ }
+
private void checkHeaders(Map<String, String> expected, Dictionary<String, String> actual) {
assertEquals("Headers size not equals", expected.size(), actual.size());
for (Entry<String, String> entry : expected.entrySet()) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/DiscardBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/DiscardBundleTests.java
index 0908f9227..72da3f428 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/DiscardBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/DiscardBundleTests.java
@@ -119,7 +119,7 @@ public class DiscardBundleTests extends AbstractBundleTests {
// will sometimes result in failure presumably due to a locked
// file.
stop(equinox);
- rm(bundleFile);
+ delete(bundleFile);
equinox = restart(equinox, configuration);
assertDiscarded(location, equinox);
} finally {
@@ -222,21 +222,4 @@ public class DiscardBundleTests extends AbstractBundleTests {
file = new File(file, BUNDLE_MANIFEST);
assertTrue("Could not set last modified: " + file, file.setLastModified(file.lastModified() + 1000));
}
-
- public static boolean rm(File file) {
- if (file.exists()) {
- if (file.isDirectory()) {
- String list[] = file.list();
- if (list != null) {
- int len = list.length;
- for (int i = 0; i < len; i++) {
- rm(new File(file, list[i]));
- }
- }
- }
-
- return file.delete();
- }
- return (true);
- }
} \ No newline at end of file
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 7a9bf3cb5..ee1ffba02 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
@@ -53,20 +53,12 @@ public class ConnectHookConfigurator implements HookConfigurator {
@Override
public void addHooks(final HookRegistry hookRegistry) {
final ConnectModules connectModules = hookRegistry.getContainer().getConnectModules();
- ModuleConnector moduleConnector = connectModules.getConnectFramework();
+ ModuleConnector moduleConnector = connectModules.getModuleConnector();
hookRegistry.addStorageHookFactory(new StorageHookFactory<Object, Object, StorageHook<Object, Object>>() {
@Override
protected StorageHook<Object, Object> createStorageHook(Generation generation) {
- ConnectModule tmp = null;
- try {
- tmp = connectModules.getConnectModule(generation.getBundleInfo().getLocation());
- } catch (IllegalStateException e) {
- if (!(e.getCause() instanceof BundleException)) {
- throw e;
- }
- }
- final ConnectModule m = tmp;
+ final ConnectModule m = connectModules.getConnectModule(generation.getBundleInfo().getLocation());
return new StorageHook<Object, Object>(generation, this.getClass()) {
boolean hasModule = false;
@@ -119,11 +111,15 @@ public class ConnectHookConfigurator implements HookConfigurator {
@Override
public URLConnection handleContentConnection(Module module, String location, InputStream in) {
+ if (in != null) {
+ // Do not call ModuleConnector method connect when input stream is non null.
+ return null;
+ }
if (location == null) {
location = module.getLocation();
}
try {
- ConnectModule m = connectModules.getConnectModule(location);
+ ConnectModule m = connectModules.connect(location);
if (m != null) {
return ConnectInputStream.URL_CONNECTION_INSTANCE;
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java
index 5d900bf78..3164a0e29 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java
@@ -15,10 +15,8 @@
package org.eclipse.osgi.internal.framework;
import java.io.File;
-import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
-import java.net.URLConnection;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
@@ -182,14 +180,9 @@ public class BundleContextImpl implements BundleContext, EventDispatcher<Object,
@Override
public Bundle installBundle(String location, InputStream in) throws BundleException {
checkValid();
- try {
- URLConnection content = container.getStorage().getContentConnection(null, location, in);
- Generation generation = container.getStorage().install(bundle.getModule(), location, content);
- return generation.getRevision().getBundle();
- } catch (IOException e) {
- throw new BundleException("Error reading bundle content.", e); //$NON-NLS-1$
- }
+ Generation generation = container.getStorage().install(bundle.getModule(), location, in);
+ return generation.getRevision().getBundle();
}
/**
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 7470d3168..9d2721feb 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
@@ -480,13 +480,9 @@ public class EquinoxBundle implements Bundle, BundleReference {
@Override
public void update(InputStream input) throws BundleException {
- try {
- Storage storage = equinoxContainer.getStorage();
- storage.update(module, storage.getContentConnection(module, null, input));
- signerInfos = null;
- } catch (IOException e) {
- throw new BundleException("Error reading bundle content.", e); //$NON-NLS-1$
- }
+ Storage storage = equinoxContainer.getStorage();
+ storage.update(module, input);
+ signerInfos = null;
}
@Override
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 a9ec59dd8..9ddad8a80 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
@@ -49,7 +49,6 @@ import org.osgi.framework.Bundle;
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.ConnectModule;
import org.osgi.framework.connect.ModuleConnector;
import org.osgi.service.packageadmin.PackageAdmin;
@@ -60,12 +59,6 @@ import org.osgi.util.tracker.ServiceTracker;
public class EquinoxContainer implements ThreadFactory, Runnable {
public static final String NAME = "org.eclipse.osgi"; //$NON-NLS-1$
static final SecureAction secureAction = AccessController.doPrivileged(SecureAction.createSecureAction());
- static final ConnectModule NULL_MODULE = new ConnectModule() {
- @Override
- public ConnectContent getContent() throws IOException {
- throw new IOException();
- }
- };
private final ConnectModules connectModules;
private final EquinoxConfiguration equinoxConfig;
@@ -374,24 +367,27 @@ public class EquinoxContainer implements ThreadFactory, Runnable {
this.moduleConnector = moduleConnector;
}
- @SuppressWarnings("unused")
- public ConnectModule getConnectModule(String location) {
+ public ConnectModule connect(String location) {
if (moduleConnector == null) {
return null;
}
- ConnectModule result = connectModules.computeIfAbsent(location, (l) -> {
+ ConnectModule result = connectModules.compute(location, (k, v) -> {
try {
- return moduleConnector.connect(location).orElse(NULL_MODULE);
+ return moduleConnector.connect(location).orElse(null);
} catch (BundleException e) {
throw new IllegalStateException(e);
}
});
- return result == NULL_MODULE ? null : result;
+ return result;
}
- public ModuleConnector getConnectFramework() {
+ public ModuleConnector getModuleConnector() {
return moduleConnector;
}
+
+ public ConnectModule getConnectModule(String location) {
+ return connectModules.get(location);
+ }
}
@SuppressWarnings("unchecked")
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java
index de070fce2..98399d730 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java
@@ -571,41 +571,47 @@ public class Storage {
return osgiLocation.isReadOnly();
}
- public URLConnection getContentConnection(Module module, String bundleLocation, final InputStream in) throws IOException {
- List<StorageHookFactory<?, ?, ?>> storageHooks = getConfiguration().getHookRegistry().getStorageHookFactories();
- for (StorageHookFactory<?, ?, ?> storageHook : storageHooks) {
- URLConnection hookContent = storageHook.handleContentConnection(module, bundleLocation, in);
- if (hookContent != null) {
- return hookContent;
+ public URLConnection getContentConnection(Module module, String bundleLocation, final InputStream in)
+ throws BundleException {
+ try {
+ List<StorageHookFactory<?, ?, ?>> storageHooks = getConfiguration().getHookRegistry()
+ .getStorageHookFactories();
+ for (StorageHookFactory<?, ?, ?> storageHook : storageHooks) {
+ URLConnection hookContent = storageHook.handleContentConnection(module, bundleLocation, in);
+ if (hookContent != null) {
+ return hookContent;
+ }
}
- }
- if (in != null) {
- return new URLConnection(null) {
- /**
- * @throws IOException
- */
- @Override
- public void connect() throws IOException {
- connected = true;
- }
+ if (in != null) {
+ return new URLConnection(null) {
+ /**
+ * @throws IOException
+ */
+ @Override
+ public void connect() throws IOException {
+ connected = true;
+ }
- /**
- * @throws IOException
- */
- @Override
- public InputStream getInputStream() throws IOException {
- return (in);
+ /**
+ * @throws IOException
+ */
+ @Override
+ public InputStream getInputStream() throws IOException {
+ return (in);
+ }
+ };
+ }
+ if (module == null) {
+ if (bundleLocation == null) {
+ throw new IllegalArgumentException("Module and location cannot be null"); //$NON-NLS-1$
}
- };
- }
- if (module == null) {
- if (bundleLocation == null) {
- throw new IllegalArgumentException("Module and location cannot be null"); //$NON-NLS-1$
+ return getContentConnection(bundleLocation);
}
- return getContentConnection(bundleLocation);
+ return getContentConnection(getUpdateLocation(module));
+ } catch (IOException e) {
+ throw new BundleException("Error reading bundle content.", e); //$NON-NLS-1$
}
- return getContentConnection(getUpdateLocation(module));
}
private String getUpdateLocation(final Module module) {
@@ -657,7 +663,8 @@ public class Storage {
return new URL(spec);
}
- public Generation install(Module origin, String bundleLocation, URLConnection content) throws BundleException {
+ public Generation install(Module origin, String bundleLocation, InputStream toInstall) throws BundleException {
+ URLConnection content = getContentConnection(null, bundleLocation, toInstall);
if (osgiLocation.isReadOnly()) {
throw new BundleException("The framework storage area is read only.", BundleException.INVALID_OPERATION); //$NON-NLS-1$
}
@@ -908,6 +915,7 @@ public class Storage {
Generation currentGen = (Generation) current.getRevisionInfo();
File content = currentGen.getContent();
if (content == null) {
+ // TODO Handle connect bundle
return;
}
String spec = (currentGen.getContentType() == Type.REFERENCE ? "reference:" : "") + content.toURI().toString(); //$NON-NLS-1$ //$NON-NLS-2$
@@ -920,7 +928,12 @@ public class Storage {
update(module, contentConn);
}
- public Generation update(Module module, URLConnection content) throws BundleException {
+ public Generation update(Module module, InputStream updateIn) throws BundleException {
+ return update(module, getContentConnection(module, null, updateIn));
+ }
+
+ private Generation update(Module module, URLConnection content) throws BundleException {
+
if (osgiLocation.isReadOnly()) {
throw new BundleException("The framework storage area is read only.", BundleException.INVALID_OPERATION); //$NON-NLS-1$
}
@@ -1163,8 +1176,11 @@ public class Storage {
public BundleFile createBundleFile(File content, Generation generation, boolean isDirectory, boolean isBase) {
BundleFile result = null;
+ ConnectModule connectModule = null;
+ if (generation.getContentType() == Type.CONNECT) {
+ connectModule = equinoxContainer.getConnectModules().getConnectModule(generation.getBundleInfo().getLocation());
+ }
try {
- ConnectModule connectModule = equinoxContainer.getConnectModules().getConnectModule(generation.getBundleInfo().getLocation());
if (connectModule != null && isBase) {
result = new ConnectBundleFile(connectModule, content, generation, mruList, getConfiguration().getDebug());
} else if (isDirectory) {
@@ -1543,10 +1559,23 @@ public class Storage {
generations.add(generation);
}
+ connectPersistentBundles(generations);
loadStorageHookData(generations, in);
return result;
}
+ private void connectPersistentBundles(List<Generation> generations) {
+ generations.forEach(g -> {
+ try {
+ equinoxContainer.getConnectModules().connect(g.getBundleInfo().getLocation());
+ } catch (IllegalStateException e) {
+ if (!(e.getCause() instanceof BundleException)) {
+ throw e;
+ }
+ }
+ });
+ }
+
private void loadStorageHookData(List<Generation> generations, DataInputStream in) throws IOException {
List<StorageHookFactory<?, ?, ?>> factories = new ArrayList<>(getConfiguration().getHookRegistry().getStorageHookFactories());
Map<Generation, List<StorageHook<?, ?>>> hookMap = new HashMap<>();

Back to the top