Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Lippert2008-07-27 19:41:48 +0000
committerMartin Lippert2008-07-27 19:41:48 +0000
commit024bf49af50e919f5e62c0cc5045659e5f87df2d (patch)
tree87977e37502601e67825e0f4c2d785358bb5b4d0 /bundles/org.eclipse.equinox.weaving.caching
parent7b700d79ccad032f3c1a55178ea5b34b32ab8b03 (diff)
downloadrt.equinox.bundles-024bf49af50e919f5e62c0cc5045659e5f87df2d.tar.gz
rt.equinox.bundles-024bf49af50e919f5e62c0cc5045659e5f87df2d.tar.xz
rt.equinox.bundles-024bf49af50e919f5e62c0cc5045659e5f87df2d.zip
Bug 216398 - [aspects] add handling of bundle and aspect versions to standard caching service, caching service API slightly changed to allow caching service to indicate that a class is remembered to be unchanged
Diffstat (limited to 'bundles/org.eclipse.equinox.weaving.caching')
-rw-r--r--bundles/org.eclipse.equinox.weaving.caching/src/org/eclipse/equinox/weaving/internal/caching/BaseCachingService.java9
-rw-r--r--bundles/org.eclipse.equinox.weaving.caching/src/org/eclipse/equinox/weaving/internal/caching/BundleCachingService.java8
-rw-r--r--bundles/org.eclipse.equinox.weaving.caching/src/org/eclipse/equinox/weaving/internal/caching/SingletonCachingService.java21
-rw-r--r--bundles/org.eclipse.equinox.weaving.caching/src/org/eclipse/equinox/weaving/internal/caching/UnchangedCachingService.java50
4 files changed, 76 insertions, 12 deletions
diff --git a/bundles/org.eclipse.equinox.weaving.caching/src/org/eclipse/equinox/weaving/internal/caching/BaseCachingService.java b/bundles/org.eclipse.equinox.weaving.caching/src/org/eclipse/equinox/weaving/internal/caching/BaseCachingService.java
index 11ebdae62..8a56f2ffa 100644
--- a/bundles/org.eclipse.equinox.weaving.caching/src/org/eclipse/equinox/weaving/internal/caching/BaseCachingService.java
+++ b/bundles/org.eclipse.equinox.weaving.caching/src/org/eclipse/equinox/weaving/internal/caching/BaseCachingService.java
@@ -13,6 +13,7 @@ package org.eclipse.equinox.weaving.internal.caching;
import java.net.URL;
+import org.eclipse.equinox.service.weaving.CacheEntry;
import org.eclipse.equinox.service.weaving.ICachingService;
import org.osgi.framework.Bundle;
@@ -28,7 +29,7 @@ public abstract class BaseCachingService implements ICachingService {
* @see org.eclipse.equinox.service.weaving.ICachingService#findStoredClass(java.lang.String,
* java.net.URL, java.lang.String)
*/
- public byte[] findStoredClass(final String namespace,
+ public CacheEntry findStoredClass(final String namespace,
final URL sourceFileURL, final String name) {
throw new UnsupportedOperationException("Illegal call semantics!");
}
@@ -43,6 +44,12 @@ public abstract class BaseCachingService implements ICachingService {
}
/**
+ * Lifecycle method Stops the caching service
+ */
+ public void stop() {
+ }
+
+ /**
* @see org.eclipse.equinox.service.weaving.ICachingService#storeClass(java.lang.String,
* java.net.URL, java.lang.Class, byte[])
*/
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 1d7439607..a75cb210f 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
@@ -24,6 +24,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import org.eclipse.equinox.service.weaving.CacheEntry;
import org.eclipse.equinox.service.weaving.ICachingService;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -103,7 +104,7 @@ public class BundleCachingService extends BaseCachingService {
* java.net.URL, java.lang.String)
*/
@Override
- public byte[] findStoredClass(final String namespace,
+ public CacheEntry findStoredClass(final String namespace,
final URL sourceFileURL, final String name) {
if (name == null) {
@@ -112,11 +113,14 @@ public class BundleCachingService extends BaseCachingService {
}
byte[] storedClass = null;
+ boolean isCached = false;
+
if (cachePartition != null) {
final File cacheDirectory = getCacheDirectory(sourceFileURL);
final File cachedBytecodeFile = new File(cacheDirectory, name);
if (cachedBytecodeFile.exists()) {
storedClass = read(name, cachedBytecodeFile);
+ isCached = true;
}
}
@@ -125,7 +129,7 @@ public class BundleCachingService extends BaseCachingService {
.getSymbolicName(), ((storedClass != null) ? "Found" //$NON-NLS-1$
: "Found NOT"), name)); //$NON-NLS-1$
}
- return storedClass;
+ return new CacheEntry(isCached, storedClass);
}
/**
diff --git a/bundles/org.eclipse.equinox.weaving.caching/src/org/eclipse/equinox/weaving/internal/caching/SingletonCachingService.java b/bundles/org.eclipse.equinox.weaving.caching/src/org/eclipse/equinox/weaving/internal/caching/SingletonCachingService.java
index d5dd00554..c48473767 100644
--- a/bundles/org.eclipse.equinox.weaving.caching/src/org/eclipse/equinox/weaving/internal/caching/SingletonCachingService.java
+++ b/bundles/org.eclipse.equinox.weaving.caching/src/org/eclipse/equinox/weaving/internal/caching/SingletonCachingService.java
@@ -30,7 +30,7 @@ import org.osgi.framework.SynchronousBundleListener;
*/
public class SingletonCachingService extends BaseCachingService {
- private final Map<String, BundleCachingService> bundleCachingServices = new HashMap<String, BundleCachingService>();
+ private final Map<String, BaseCachingService> bundleCachingServices = new HashMap<String, BaseCachingService>();
private final BundleContext bundleContext;
@@ -83,7 +83,7 @@ public class SingletonCachingService extends BaseCachingService {
*/
@Override
public synchronized ICachingService getInstance(
- final ClassLoader classLoader, final Bundle bundle, String key) {
+ final ClassLoader classLoader, final Bundle bundle, final String key) {
if (bundle == null) {
throw new IllegalArgumentException(
@@ -92,15 +92,17 @@ public class SingletonCachingService extends BaseCachingService {
final String cacheId = getCacheId(bundle);
- BundleCachingService bundleCachingService = bundleCachingServices
+ BaseCachingService bundleCachingService = bundleCachingServices
.get(cacheId);
- key = key == null || key.length() == 0 ? "defaultCache" : key;
-
if (bundleCachingService == null) {
- bundleCachingService = new BundleCachingService(bundleContext,
- bundle, key);
+ if (key != null && key.length() > 0) {
+ bundleCachingService = new BundleCachingService(bundleContext,
+ bundle, key);
+ } else {
+ bundleCachingService = new UnchangedCachingService();
+ }
bundleCachingServices.put(cacheId, bundleCachingService);
if (Log.isDebugEnabled()) {
@@ -115,8 +117,9 @@ public class SingletonCachingService extends BaseCachingService {
/**
* Stops all individual bundle services.
*/
+ @Override
public synchronized void stop() {
- for (final BundleCachingService bundleCachingService : bundleCachingServices
+ for (final BaseCachingService bundleCachingService : bundleCachingServices
.values()) {
bundleCachingService.stop();
}
@@ -128,7 +131,7 @@ public class SingletonCachingService extends BaseCachingService {
*/
protected void stopBundleCachingService(final BundleEvent event) {
final String cacheId = getCacheId(event.getBundle());
- final BundleCachingService bundleCachingService = bundleCachingServices
+ final BaseCachingService bundleCachingService = bundleCachingServices
.get(cacheId);
if (bundleCachingService != null) {
bundleCachingService.stop();
diff --git a/bundles/org.eclipse.equinox.weaving.caching/src/org/eclipse/equinox/weaving/internal/caching/UnchangedCachingService.java b/bundles/org.eclipse.equinox.weaving.caching/src/org/eclipse/equinox/weaving/internal/caching/UnchangedCachingService.java
new file mode 100644
index 000000000..ac29802d7
--- /dev/null
+++ b/bundles/org.eclipse.equinox.weaving.caching/src/org/eclipse/equinox/weaving/internal/caching/UnchangedCachingService.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Martin Lippert 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
+ * http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Martin Lippert - initial implementation
+ *******************************************************************************/
+
+package org.eclipse.equinox.weaving.internal.caching;
+
+import java.net.URL;
+
+import org.eclipse.equinox.service.weaving.CacheEntry;
+
+/**
+ * This implementation of the caching service is responsible for those bundles
+ * that are not affected by the weaving. This is the case if no aspects are
+ * being found for this bundle.
+ *
+ * This caching service indicates for the runtime system that classes of the
+ * bundle this caching service belongs to dont need to be passed to the weaving
+ * service. Instead the original code from the bundle can be used.
+ *
+ * @author Martin Lippert
+ */
+public class UnchangedCachingService extends BaseCachingService {
+
+ /**
+ * @see org.eclipse.equinox.weaving.internal.caching.BaseCachingService#findStoredClass(java.lang.String,
+ * java.net.URL, java.lang.String)
+ */
+ @Override
+ public CacheEntry findStoredClass(final String namespace,
+ final URL sourceFileURL, final String name) {
+ return new CacheEntry(true, null);
+ }
+
+ /**
+ * @see org.eclipse.equinox.weaving.internal.caching.BaseCachingService#storeClass(java.lang.String,
+ * java.net.URL, java.lang.Class, byte[])
+ */
+ @Override
+ public boolean storeClass(final String namespace, final URL sourceFileURL,
+ final Class clazz, final byte[] classbytes) {
+ return false;
+ }
+}

Back to the top