Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.equinox.weaving.aspectj/src/org/eclipse/equinox/weaving/aspectj/WeavingServicePlugin.java13
-rw-r--r--bundles/org.eclipse.equinox.weaving.aspectj/src/org/eclipse/equinox/weaving/aspectj/loadtime/OSGiWeavingContext.java37
2 files changed, 43 insertions, 7 deletions
diff --git a/bundles/org.eclipse.equinox.weaving.aspectj/src/org/eclipse/equinox/weaving/aspectj/WeavingServicePlugin.java b/bundles/org.eclipse.equinox.weaving.aspectj/src/org/eclipse/equinox/weaving/aspectj/WeavingServicePlugin.java
index 1ebd20ca1..56e35335e 100644
--- a/bundles/org.eclipse.equinox.weaving.aspectj/src/org/eclipse/equinox/weaving/aspectj/WeavingServicePlugin.java
+++ b/bundles/org.eclipse.equinox.weaving.aspectj/src/org/eclipse/equinox/weaving/aspectj/WeavingServicePlugin.java
@@ -33,6 +33,8 @@ public class WeavingServicePlugin implements BundleActivator {
//The shared instance.
private static WeavingServicePlugin plugin;
+ private BundleContext context;
+
/**
* The constructor.
*/
@@ -49,9 +51,19 @@ public class WeavingServicePlugin implements BundleActivator {
}
/**
+ * @return The bundle context of the weaving service bundle or null, of
+ * bundle is not started
+ */
+ public BundleContext getContext() {
+ return this.context;
+ }
+
+ /**
* This method is called upon plug-in activation
*/
public void start(final BundleContext context) throws Exception {
+ this.context = context;
+
loadOptions(context);
if (verbose)
System.err
@@ -69,6 +81,7 @@ public class WeavingServicePlugin implements BundleActivator {
* This method is called when the plug-in is stopped
*/
public void stop(final BundleContext context) throws Exception {
+ this.context = null;
plugin = null;
}
diff --git a/bundles/org.eclipse.equinox.weaving.aspectj/src/org/eclipse/equinox/weaving/aspectj/loadtime/OSGiWeavingContext.java b/bundles/org.eclipse.equinox.weaving.aspectj/src/org/eclipse/equinox/weaving/aspectj/loadtime/OSGiWeavingContext.java
index 5b1a3439e..dc3ed84c9 100644
--- a/bundles/org.eclipse.equinox.weaving.aspectj/src/org/eclipse/equinox/weaving/aspectj/loadtime/OSGiWeavingContext.java
+++ b/bundles/org.eclipse.equinox.weaving.aspectj/src/org/eclipse/equinox/weaving/aspectj/loadtime/OSGiWeavingContext.java
@@ -29,7 +29,12 @@ import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.BundleSpecification;
import org.eclipse.osgi.service.resolver.State;
import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+/**
+ * The weaving context for AspectJs load-time weaving API that deals with the
+ * OSGi specifics for load-time weaving
+ */
public class OSGiWeavingContext extends DefaultWeavingContext {
private final Bundle bundle;
@@ -64,25 +69,27 @@ public class OSGiWeavingContext extends DefaultWeavingContext {
// the bundle this context belongs to should be used
bundles.add(this.bundle);
- // add required bundles
- if (this.bundle.getBundleContext() != null) {
+ final BundleContext weavingBundleContext = WeavingServicePlugin
+ .getDefault() != null ? WeavingServicePlugin.getDefault()
+ .getContext() : null;
+ if (weavingBundleContext != null) {
+
+ // add required bundles
final BundleDescription[] resolvedRequires = this.bundleDescription
.getResolvedRequires();
for (int i = 0; i < resolvedRequires.length; i++) {
- final Bundle requiredBundle = this.bundle.getBundleContext()
+ final Bundle requiredBundle = weavingBundleContext
.getBundle(resolvedRequires[i].getBundleId());
if (requiredBundle != null) {
bundles.add(requiredBundle);
}
}
- }
- // add fragment bundles
- if (this.bundle.getBundleContext() != null) {
+ // add fragment bundles
final BundleDescription[] fragments = this.bundleDescription
.getFragments();
for (int i = 0; i < fragments.length; i++) {
- final Bundle fragmentBundle = this.bundle.getBundleContext()
+ final Bundle fragmentBundle = weavingBundleContext
.getBundle(fragments[i].getBundleId());
if (fragmentBundle != null) {
bundles.add(fragmentBundle);
@@ -103,10 +110,17 @@ public class OSGiWeavingContext extends DefaultWeavingContext {
.getVersion().toString();
}
+ /**
+ * @see org.aspectj.weaver.loadtime.DefaultWeavingContext#getClassLoaderName()
+ */
public String getClassLoaderName() {
return bundleDescription.getSymbolicName();
}
+ /**
+ * @see org.aspectj.weaver.loadtime.DefaultWeavingContext#getDefinitions(java.lang.ClassLoader,
+ * org.aspectj.weaver.tools.WeavingAdaptor)
+ */
public List getDefinitions(final ClassLoader loader,
final WeavingAdaptor adaptor) {
final List definitions = ((OSGiWeavingAdaptor) adaptor)
@@ -114,14 +128,23 @@ public class OSGiWeavingContext extends DefaultWeavingContext {
return definitions;
}
+ /**
+ * @see org.aspectj.weaver.loadtime.DefaultWeavingContext#getFile(java.net.URL)
+ */
public String getFile(final URL url) {
return getBundleIdFromURL(url) + url.getFile();
}
+ /**
+ * @see org.aspectj.weaver.loadtime.DefaultWeavingContext#getId()
+ */
public String getId() {
return bundleDescription.getSymbolicName();
}
+ /**
+ * @see org.aspectj.weaver.loadtime.DefaultWeavingContext#getResources(java.lang.String)
+ */
public Enumeration getResources(final String name) throws IOException {
Enumeration result = super.getResources(name);

Back to the top