Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhseeberger2008-08-19 07:10:51 +0000
committerhseeberger2008-08-19 07:10:51 +0000
commit5d035a74474626f44a3aa7e49ef836da47e59553 (patch)
tree81caff6ced84fd7871ee3747229c9b8b440646cc
parent5e9bfb63cf9304bafbde035ccd0bc490dfb58c6f (diff)
downloadrt.equinox.bundles-5d035a74474626f44a3aa7e49ef836da47e59553.tar.gz
rt.equinox.bundles-5d035a74474626f44a3aa7e49ef836da47e59553.tar.xz
rt.equinox.bundles-5d035a74474626f44a3aa7e49ef836da47e59553.zip
Bug 226461 - [aspects] Improve handling of service dynamics
Changed AspectJAdaptorFactory according to Comment #7: All requests for bundle weaving services are stored. When the global weaving service starts or stops, all bundles for which a weaving service was requested are updated.
-rw-r--r--bundles/org.eclipse.equinox.weaving.hook/src/org/eclipse/equinox/weaving/adaptors/AspectJAdaptorFactory.java84
1 files changed, 61 insertions, 23 deletions
diff --git a/bundles/org.eclipse.equinox.weaving.hook/src/org/eclipse/equinox/weaving/adaptors/AspectJAdaptorFactory.java b/bundles/org.eclipse.equinox.weaving.hook/src/org/eclipse/equinox/weaving/adaptors/AspectJAdaptorFactory.java
index 3fba382b9..58f25d520 100644
--- a/bundles/org.eclipse.equinox.weaving.hook/src/org/eclipse/equinox/weaving/adaptors/AspectJAdaptorFactory.java
+++ b/bundles/org.eclipse.equinox.weaving.hook/src/org/eclipse/equinox/weaving/adaptors/AspectJAdaptorFactory.java
@@ -13,7 +13,12 @@
package org.eclipse.equinox.weaving.adaptors;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import org.eclipse.equinox.service.weaving.ICachingService;
import org.eclipse.equinox.service.weaving.IWeavingService;
@@ -34,6 +39,11 @@ import org.osgi.util.tracker.ServiceTracker;
public class AspectJAdaptorFactory {
+ private static final Collection IGNORE_WEAVING_SERVICE_BUNDLES = Arrays
+ .asList(new String[] { "org.eclipse.equinox.weaving.aspectj",
+ "org.eclipse.equinox.caching",
+ "org.eclipse.equinox.caching.j9" });
+
private BundleContext bundleContext;
private ServiceTracker cachingServiceTracker;
@@ -44,6 +54,12 @@ public class AspectJAdaptorFactory {
private ServiceListener weavingServiceListener;
+ /**
+ * Bundle -> Local weaving service
+ */
+ private final Map weavingServices = Collections
+ .synchronizedMap(new HashMap());
+
private ServiceTracker weavingServiceTracker;
public AspectJAdaptorFactory() {
@@ -97,17 +113,36 @@ public class AspectJAdaptorFactory {
weavingServiceListener = new ServiceListener() {
public void serviceChanged(final ServiceEvent event) {
- if (event.getType() != ServiceEvent.MODIFIED) {
- final Iterator supplementedBundlesIterator = supplementerRegistry
- .getSupplementedBundles().iterator();
- while (supplementedBundlesIterator.hasNext()) {
- final Bundle supplementedBundle = (Bundle) supplementedBundlesIterator
- .next();
- supplementerRegistry
- .updateInstalledBundle(supplementedBundle);
- if (Debug.DEBUG_WEAVE)
- Debug.println("> Updated supplemented bundle "
- + supplementedBundle.getSymbolicName());
+ if (event.getType() == ServiceEvent.REGISTERED) {
+ final Iterator bundles = weavingServices.keySet()
+ .iterator();
+ synchronized (weavingServices) {
+ while (bundles.hasNext()) {
+ final Bundle bundle = (Bundle) bundles.next();
+ if (weavingServices.get(bundle) == null) {
+ supplementerRegistry
+ .updateInstalledBundle(bundle);
+ if (Debug.DEBUG_WEAVE)
+ Debug.println("> Updated bundle "
+ + bundle.getSymbolicName());
+ }
+ }
+ }
+ }
+ if (event.getType() == ServiceEvent.UNREGISTERING) {
+ final Iterator bundles = weavingServices.keySet()
+ .iterator();
+ synchronized (weavingServices) {
+ while (bundles.hasNext()) {
+ final Bundle bundle = (Bundle) bundles.next();
+ if (weavingServices.get(bundle) != null) {
+ supplementerRegistry
+ .updateInstalledBundle(bundle);
+ if (Debug.DEBUG_WEAVE)
+ Debug.println("> Updated bundle "
+ + bundle.getSymbolicName());
+ }
+ }
}
}
}
@@ -159,19 +194,22 @@ public class AspectJAdaptorFactory {
.println("> AspectJAdaptorFactory.getWeavingService() baseClassLoader="
+ loader);
+ final BaseData baseData = loader.getClasspathManager().getBaseData();
+ final State state = baseData.getAdaptor().getState();
+ final Bundle bundle = baseData.getBundle();
+ final BundleDescription bundleDescription = state.getBundle(bundle
+ .getBundleId());
+
IWeavingService weavingService = null;
- final IWeavingService singletonWeavingService = (IWeavingService) weavingServiceTracker
- .getService();
- if (singletonWeavingService != null) {
- final BaseData baseData = loader.getClasspathManager()
- .getBaseData();
- final State state = baseData.getAdaptor().getState();
- final Bundle bundle = baseData.getBundle();
- final BundleDescription bundleDescription = state.getBundle(bundle
- .getBundleId());
- weavingService = singletonWeavingService.getInstance(
- (ClassLoader) loader, bundle, state, bundleDescription,
- supplementerRegistry);
+ if (!IGNORE_WEAVING_SERVICE_BUNDLES.contains(bundle.getSymbolicName())) {
+ final IWeavingService singletonWeavingService = (IWeavingService) weavingServiceTracker
+ .getService();
+ if (singletonWeavingService != null) {
+ weavingService = singletonWeavingService.getInstance(
+ (ClassLoader) loader, bundle, state, bundleDescription,
+ supplementerRegistry);
+ }
+ weavingServices.put(bundle, weavingService);
}
if (Debug.DEBUG_WEAVE)
Debug

Back to the top