Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Ross2013-05-07 12:01:09 +0000
committerJohn Ross2013-05-13 15:49:52 +0000
commit0865d5c4239dfb076dcab5cada3ea19ceaa6976b (patch)
treed8625c387d4e0822ab98d568999109446cf02005
parentdc2a943d9900f9f142f3027043cc230b2342a8e3 (diff)
downloadrt.equinox.framework-0865d5c4239dfb076dcab5cada3ea19ceaa6976b.tar.gz
rt.equinox.framework-0865d5c4239dfb076dcab5cada3ea19ceaa6976b.tar.xz
rt.equinox.framework-0865d5c4239dfb076dcab5cada3ea19ceaa6976b.zip
Bug 405919 - [unity] support for osgi.checkConfiguration option
Update EquinoxConifguration to support the osgi.checkConfiguration property. Update BundleInfo.Generation to support a lastModified attribute. The value is the last modified timestamp of either the bundle manifest (if a directory) or the bundle jar at installation time. Update Storage to load and store the last modified data. Whether or not a bundle needs discarding is also computed here.
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java18
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/BundleInfo.java19
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java29
3 files changed, 61 insertions, 5 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java
index e24b89d80..8ff7af2ee 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java
@@ -181,6 +181,9 @@ public class EquinoxConfiguration implements EnvironmentInfo {
public static final String PROPERTY_STRICT_BUNDLE_ENTRY_PATH = "osgi.strictBundleEntryPath";//$NON-NLS-1$
+ public static final String PROP_CHECK_CONFIGURATION = "osgi.checkConfiguration"; //$NON-NLS-1$
+ private final boolean inCheckConfigurationMode;
+
private final static Collection<String> populateInitConfig = Arrays.asList(PROP_OSGI_ARCH, PROP_OSGI_OS, PROP_OSGI_WS, PROP_OSGI_NL, FRAMEWORK_OS_NAME, FRAMEWORK_OS_VERSION, FRAMEWORK_PROCESSOR, FRAMEWORK_LANGUAGE);
EquinoxConfiguration(Map<String, ?> initialConfiguration, HookRegistry hookRegistry) {
@@ -273,6 +276,17 @@ public class EquinoxConfiguration implements EnvironmentInfo {
CLASS_CERTIFICATE = Boolean.valueOf(getConfiguration(PROP_CLASS_CERTIFICATE_SUPPORT, "true")).booleanValue(); //$NON-NLS-1$
PARALLEL_CAPABLE = CLASS_LOADER_TYPE_PARALLEL.equals(getConfiguration(PROP_CLASS_LOADER_TYPE));
+
+ inCheckConfigurationMode = computeCheckConfigurationMode();
+ }
+
+ private boolean computeCheckConfigurationMode() {
+ String osgiCheckConfiguration = configuration.getProperty(PROP_CHECK_CONFIGURATION);
+ // A specified osgi.dev property but unspecified osgi.checkConfiguration
+ // property implies osgi.checkConfiguration = true.
+ if (osgiCheckConfiguration == null && inDevelopmentMode)
+ return true;
+ return Boolean.valueOf(osgiCheckConfiguration);
}
public Map<String, Object> getInitialConfig() {
@@ -314,6 +328,10 @@ public class EquinoxConfiguration implements EnvironmentInfo {
return os == null || !os.startsWith("Mac OS") ? null : "dylib,jnilib"; //$NON-NLS-1$ //$NON-NLS-2$
}
+ public boolean inCheckConfigurationMode() {
+ return inCheckConfigurationMode;
+ }
+
public boolean inDevelopmentMode() {
return inDevelopmentMode;
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/BundleInfo.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/BundleInfo.java
index 2e9a27951..8f6e85a80 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/BundleInfo.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/BundleInfo.java
@@ -49,19 +49,21 @@ public final class BundleInfo {
private ProtectionDomain domain;
private NativeCodeFinder nativeCodeFinder;
private List<StorageHook<?, ?>> storageHooks;
+ private long lastModified;
Generation(long generationId) {
this.generationId = generationId;
this.cachedHeaders = new CachedManifest(this, Collections.<String, String> emptyMap());
}
- Generation(long generationId, File content, boolean isDirectory, boolean isReference, boolean hasPackageInfo, Map<String, String> cached) {
+ Generation(long generationId, File content, boolean isDirectory, boolean isReference, boolean hasPackageInfo, Map<String, String> cached, long lastModified) {
this.generationId = generationId;
this.content = content;
this.isDirectory = isDirectory;
this.isReference = isReference;
this.hasPackageInfo = hasPackageInfo;
this.cachedHeaders = new CachedManifest(this, cached);
+ this.lastModified = lastModified;
}
public BundleFile getBundleFile() {
@@ -150,6 +152,10 @@ public final class BundleInfo {
return this.generationId;
}
+ public long getLastModified() {
+ return lastModified;
+ }
+
public boolean isDirectory() {
synchronized (this.genMonitor) {
return this.isDirectory;
@@ -179,9 +185,16 @@ public final class BundleInfo {
this.content = content;
this.isDirectory = content == null ? false : Storage.secureAction.isDirectory(content);
this.isReference = isReference;
+ setLastModified(content);
}
}
+ private void setLastModified(File content) {
+ if (isDirectory)
+ content = new File(content, "META-INF/MANIFEST.MF"); //$NON-NLS-1$
+ lastModified = Storage.secureAction.lastModified(content);
+ }
+
void setStorageHooks(List<StorageHook<?, ?>> storageHooks, boolean install) {
synchronized (this.genMonitor) {
this.storageHooks = storageHooks;
@@ -338,9 +351,9 @@ public final class BundleInfo {
}
}
- Generation restoreGeneration(long generationId, File content, boolean isDirectory, boolean isReference, boolean hasPackageInfo, Map<String, String> cached) {
+ Generation restoreGeneration(long generationId, File content, boolean isDirectory, boolean isReference, boolean hasPackageInfo, Map<String, String> cached, long lastModified) {
synchronized (this.infoMonitor) {
- Generation restoredGeneration = new Generation(generationId, content, isDirectory, isReference, hasPackageInfo, cached);
+ Generation restoredGeneration = new Generation(generationId, content, isDirectory, isReference, hasPackageInfo, cached, lastModified);
return restoredGeneration;
}
}
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 7ea25440d..6f9c849b3 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 IBM Corporation and others.
+ * Copyright (c) 2012, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -134,6 +134,7 @@ public class Storage {
}
}
checkSystemBundle();
+ discardBundles();
installExtensions();
// TODO hack to make sure all bundles are in UNINSTALLED state before system bundle init is called
this.moduleContainer.setInitialModuleStates();
@@ -175,6 +176,28 @@ public class Storage {
return permData;
}
+ private void discardBundles() throws BundleException {
+ for (Module module : moduleContainer.getModules()) {
+ if (module.getId() == Constants.SYSTEM_BUNDLE_ID)
+ continue;
+ ModuleRevision revision = module.getCurrentRevision();
+ Generation generation = (Generation) revision.getRevisionInfo();
+ if (needsDiscarding(generation)) {
+ moduleContainer.uninstall(moduleContainer.getModule(generation.getBundleInfo().getBundleId()));
+ generation.delete();
+ }
+ }
+ }
+
+ private boolean needsDiscarding(Generation generation) {
+ if (!getConfiguration().inCheckConfigurationMode())
+ return false;
+ File content = generation.getContent();
+ if (generation.isDirectory())
+ content = new File(content, "META-INF/MANIFEST.MF"); //$NON-NLS-1$
+ return generation.getLastModified() != secureAction.lastModified(content);
+ }
+
private void checkSystemBundle() {
Module systemModule = moduleContainer.getModule(0);
Generation newGeneration = null;
@@ -977,6 +1000,7 @@ public class Storage {
out.writeUTF(Storage.getBundleFilePath(bundleInfo.getBundleId(), generation.getGenerationId()));
}
}
+ out.writeLong(generation.getLastModified());
Dictionary<String, String> headers = generation.getHeaders();
for (String headerKey : cachedHeaderKeys) {
@@ -1045,6 +1069,7 @@ public class Storage {
boolean isReference = in.readBoolean();
boolean hasPackageInfo = in.readBoolean();
String contentPath = in.readUTF();
+ long lastModified = in.readLong();
Map<String, String> cachedHeaders = new HashMap<String, String>(storedCachedHeaderKeys.size());
for (String headerKey : storedCachedHeaderKeys) {
@@ -1077,7 +1102,7 @@ public class Storage {
}
BundleInfo info = new BundleInfo(this, infoId, nextGenId);
- Generation generation = info.restoreGeneration(generationId, content, isDirectory, isReference, hasPackageInfo, cachedHeaders);
+ Generation generation = info.restoreGeneration(generationId, content, isDirectory, isReference, hasPackageInfo, cachedHeaders, lastModified);
result.put(infoId, generation);
generations.add(generation);
}

Back to the top