Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Lippert2008-07-27 19:56:22 +0000
committerMartin Lippert2008-07-27 19:56:22 +0000
commit8a641640940a127d9779188f6cbc432de18fb28f (patch)
tree6489876fa4c282f548d97a15d64ecf9c094948d8 /bundles
parent024bf49af50e919f5e62c0cc5045659e5f87df2d (diff)
downloadrt.equinox.bundles-8a641640940a127d9779188f6cbc432de18fb28f.tar.gz
rt.equinox.bundles-8a641640940a127d9779188f6cbc432de18fb28f.tar.xz
rt.equinox.bundles-8a641640940a127d9779188f6cbc432de18fb28f.zip
Bug 216398 - [aspects] add handling of bundle and aspect versions to standard caching service, bundle version from header added to cache directory name in addition to sourceFileURL
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.equinox.weaving.caching/src/org/eclipse/equinox/weaving/internal/caching/BundleCachingService.java24
1 files changed, 19 insertions, 5 deletions
diff --git a/bundles/org.eclipse.equinox.weaving.caching/src/org/eclipse/equinox/weaving/internal/caching/BundleCachingService.java b/bundles/org.eclipse.equinox.weaving.caching/src/org/eclipse/equinox/weaving/internal/caching/BundleCachingService.java
index a75cb210f..ea80dba66 100644
--- a/bundles/org.eclipse.equinox.weaving.caching/src/org/eclipse/equinox/weaving/internal/caching/BundleCachingService.java
+++ b/bundles/org.eclipse.equinox.weaving.caching/src/org/eclipse/equinox/weaving/internal/caching/BundleCachingService.java
@@ -28,6 +28,7 @@ import org.eclipse.equinox.service.weaving.CacheEntry;
import org.eclipse.equinox.service.weaving.ICachingService;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
/**
* <p>
@@ -54,10 +55,12 @@ public class BundleCachingService extends BaseCachingService {
private final BundleContext bundleContext;
+ private String bundleVersion;
+
private final Map<String, byte[]> cachedClasses = new HashMap<String, byte[]>(
MAX_CACHED_CLASSES + 10);
- private final Map<URL, File> cacheDirectories = new HashMap<URL, File>();
+ private final Map<String, File> cacheDirectories = new HashMap<String, File>();
private final Map<String, URL> cachedSourceFileURLs = new HashMap<String, URL>(
MAX_CACHED_CLASSES + 10);
@@ -96,6 +99,14 @@ public class BundleCachingService extends BaseCachingService {
this.bundle = bundle;
this.cacheKey = hashNamespace(key);
+ final Object version = bundle.getHeaders()
+ .get(Constants.BUNDLE_VERSION);
+ if (version != null) {
+ this.bundleVersion = (String) version;
+ } else {
+ this.bundleVersion = "0.0.0"; //$NON-NLS-1$
+ }
+
initCache();
}
@@ -135,6 +146,7 @@ public class BundleCachingService extends BaseCachingService {
/**
* Writes the remaining cache to disk.
*/
+ @Override
public void stop() {
if (cachePartition != null) {
for (final String name : cachedClasses.keySet()) {
@@ -182,17 +194,19 @@ public class BundleCachingService extends BaseCachingService {
}
private File getCacheDirectory(final URL sourceFileUrl) {
- File cacheDir = this.cacheDirectories.get(sourceFileUrl);
+ final String directoryName = sourceFileUrl.toString()
+ + this.bundleVersion;
+
+ File cacheDir = this.cacheDirectories.get(directoryName);
if (cacheDir == null) {
- final String cacheDirFromUrl = hashNamespace(sourceFileUrl
- .toString());
+ final String cacheDirFromUrl = hashNamespace(directoryName);
cacheDir = new File(cachePartition, cacheDirFromUrl);
if (!cacheDir.exists()) {
cacheDir.mkdirs();
}
- this.cacheDirectories.put(sourceFileUrl, cacheDir);
+ this.cacheDirectories.put(directoryName, cacheDir);
}
return cacheDir;

Back to the top