Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Lippert2008-10-01 20:57:26 +0000
committerMartin Lippert2008-10-01 20:57:26 +0000
commitcea0ac37f492e48b7d049c8a906bee556afa4c73 (patch)
tree31274529735d244151757dee63693391670737e7
parent330b8eb6bcdaeaef03978dc107d9e3e1d1acc3c3 (diff)
downloadrt.equinox.bundles-cea0ac37f492e48b7d049c8a906bee556afa4c73.tar.gz
rt.equinox.bundles-cea0ac37f492e48b7d049c8a906bee556afa4c73.tar.xz
rt.equinox.bundles-cea0ac37f492e48b7d049c8a906bee556afa4c73.zip
Bug 243685 - [aspects] avoid weaver initialization until really needed
-rw-r--r--bundles/org.eclipse.equinox.weaving.aspectj/src/org/eclipse/equinox/weaving/aspectj/WeavingService.java16
-rw-r--r--bundles/org.eclipse.equinox.weaving.aspectj/src/org/eclipse/equinox/weaving/aspectj/loadtime/OSGiWeavingAdaptor.java100
-rw-r--r--bundles/org.eclipse.equinox.weaving.aspectj/src/org/eclipse/equinox/weaving/aspectj/loadtime/OSGiWeavingContext.java2
3 files changed, 69 insertions, 49 deletions
diff --git a/bundles/org.eclipse.equinox.weaving.aspectj/src/org/eclipse/equinox/weaving/aspectj/WeavingService.java b/bundles/org.eclipse.equinox.weaving.aspectj/src/org/eclipse/equinox/weaving/aspectj/WeavingService.java
index 1c5369571..283a2bd33 100644
--- a/bundles/org.eclipse.equinox.weaving.aspectj/src/org/eclipse/equinox/weaving/aspectj/WeavingService.java
+++ b/bundles/org.eclipse.equinox.weaving.aspectj/src/org/eclipse/equinox/weaving/aspectj/WeavingService.java
@@ -75,7 +75,7 @@ public class WeavingService implements IWeavingService {
System.out.println("> WeavingService.getKey() bundle="
+ bundle.getSymbolicName());
String key;
- ensureAdaptorInit();
+ ensureAdaptorCreated();
key = adaptor1.getNamespace();
if (WeavingServicePlugin.DEBUG)
System.out.println("< WeavingService.getKey() key='" + key + "'");
@@ -105,11 +105,17 @@ public class WeavingService implements IWeavingService {
/**
* Initialise Aj
*/
- private void ensureAdaptorInit() {
- if (adaptor1 == null) {
- adaptor1 = new OSGiWeavingAdaptor(loader, weavingContext);
- adaptor1.initialize();
+ private void ensureAdaptorCreated() {
+ synchronized (this) {
+ if (adaptor1 == null) {
+ adaptor1 = new OSGiWeavingAdaptor(loader, weavingContext);
+ }
}
}
+ private void ensureAdaptorInit() {
+ ensureAdaptorCreated();
+ adaptor1.initialize();
+ }
+
}
diff --git a/bundles/org.eclipse.equinox.weaving.aspectj/src/org/eclipse/equinox/weaving/aspectj/loadtime/OSGiWeavingAdaptor.java b/bundles/org.eclipse.equinox.weaving.aspectj/src/org/eclipse/equinox/weaving/aspectj/loadtime/OSGiWeavingAdaptor.java
index 2b8c64bd1..978bf54e1 100644
--- a/bundles/org.eclipse.equinox.weaving.aspectj/src/org/eclipse/equinox/weaving/aspectj/loadtime/OSGiWeavingAdaptor.java
+++ b/bundles/org.eclipse.equinox.weaving.aspectj/src/org/eclipse/equinox/weaving/aspectj/loadtime/OSGiWeavingAdaptor.java
@@ -40,6 +40,8 @@ public class OSGiWeavingAdaptor extends ClassLoaderWeavingAdaptor {
private static final String DEFAULT_AOP_CONTEXT_LOCATION = "META-INF/aop.xml";
+ private final List aspectDefinitions;
+
private final ClassLoader classLoader;
private boolean initialized;
@@ -56,19 +58,29 @@ public class OSGiWeavingAdaptor extends ClassLoaderWeavingAdaptor {
this.classLoader = loader;
this.weavingContext = context;
this.namespaceAddon = new StringBuffer();
+ this.aspectDefinitions = parseDefinitionsForBundle();
+ }
+
+ /**
+ * returns the found aspect definitions
+ */
+ public List getAspectDefinitions() {
+ return this.aspectDefinitions;
}
/**
* @see org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor#getNamespace()
*/
public String getNamespace() {
- final String namespace = super.getNamespace();
- if (namespace != null && namespace.length() > 0
- && namespaceAddon.length() > 0) {
- return namespace + " - " + namespaceAddon.toString(); //$NON-NLS-1$
- } else {
- return namespace;
- }
+ // final String namespace = super.getNamespace();
+ return namespaceAddon.toString();
+
+ // if (namespace != null && namespace.length() > 0
+ // && namespaceAddon.length() > 0) {
+ // return namespace + " - " + namespaceAddon.toString();
+ // } else {
+ // return namespace;
+ // }
}
public void initialize() {
@@ -78,45 +90,21 @@ public class OSGiWeavingAdaptor extends ClassLoaderWeavingAdaptor {
super.initialize(classLoader, weavingContext);
initialized = true;
initializing = false;
- }
- }
- if (WeavingServicePlugin.verbose) {
- if (isEnabled())
- System.err
- .println("[org.aspectj.osgi.service.weaving] info weaving bundle '"
- + weavingContext.getClassLoaderName() + "'");
- else
- System.err
- .println("[org.aspectj.osgi.service.weaving] info not weaving bundle '"
- + weavingContext.getClassLoaderName() + "'");
- }
- }
-
- /**
- * Load and cache the aop.xml/properties according to the classloader
- * visibility rules
- *
- * @param weaver
- * @param loader
- */
- public List parseDefinitionsForBundle() {
- final List definitions = new ArrayList();
- final Set seenBefore = new HashSet();
-
- try {
- parseDefinitionsFromVisibility(definitions, seenBefore);
- parseDefinitionsFromRequiredBundles(definitions, seenBefore);
- if (definitions.isEmpty()) {
- info("no configuration found. Disabling weaver for bundler "
- + weavingContext.getClassLoaderName());
+ if (WeavingServicePlugin.verbose) {
+ if (isEnabled())
+ System.err
+ .println("[org.aspectj.osgi.service.weaving] info weaving bundle '"
+ + weavingContext.getClassLoaderName()
+ + "'");
+ else
+ System.err
+ .println("[org.aspectj.osgi.service.weaving] info not weaving bundle '"
+ + weavingContext.getClassLoaderName()
+ + "'");
+ }
}
- } catch (final Exception e) {
- definitions.clear();
- warn("parse definitions failed", e);
}
-
- return definitions;
}
// Bug 215177: Adapt to updated (AJ 1.5.4) super class signature:
@@ -183,6 +171,32 @@ public class OSGiWeavingAdaptor extends ClassLoaderWeavingAdaptor {
}
}
+ /**
+ * Load and cache the aop.xml/properties according to the classloader
+ * visibility rules
+ *
+ * @param weaver
+ * @param loader
+ */
+ private List parseDefinitionsForBundle() {
+ final List definitions = new ArrayList();
+ final Set seenBefore = new HashSet();
+
+ try {
+ parseDefinitionsFromVisibility(definitions, seenBefore);
+ parseDefinitionsFromRequiredBundles(definitions, seenBefore);
+ if (definitions.isEmpty()) {
+ info("no configuration found. Disabling weaver for bundler "
+ + weavingContext.getClassLoaderName());
+ }
+ } catch (final Exception e) {
+ definitions.clear();
+ warn("parse definitions failed", e);
+ }
+
+ return definitions;
+ }
+
private void parseDefinitionsFromRequiredBundles(final List definitions,
final Set seenBefore) {
final Bundle[] bundles = weavingContext.getBundles();
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 dc3ed84c9..069a3873c 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
@@ -124,7 +124,7 @@ public class OSGiWeavingContext extends DefaultWeavingContext {
public List getDefinitions(final ClassLoader loader,
final WeavingAdaptor adaptor) {
final List definitions = ((OSGiWeavingAdaptor) adaptor)
- .parseDefinitionsForBundle();
+ .getAspectDefinitions();
return definitions;
}

Back to the top