summaryrefslogtreecommitdiffstats
path: root/loadtime
diff options
context:
space:
mode:
Diffstat (limited to 'loadtime')
-rw-r--r--loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java4
-rw-r--r--loadtime/src/org/aspectj/weaver/loadtime/DefaultWeavingContext.java26
-rw-r--r--loadtime/testsrc/org/aspectj/weaver/loadtime/WeavingContextTest.java25
3 files changed, 51 insertions, 4 deletions
diff --git a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
index 40497e103..6aa204393 100644
--- a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
+++ b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
@@ -130,7 +130,7 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
}
};
- List definitions = parseDefinitions(classLoader);
+ List definitions = weavingContext.getDefinitions(classLoader,this);
if (definitions.isEmpty()) {
disable(); // TODO maw Needed to ensure messages are flushed
if (trace.isTraceEnabled()) trace.exit("initialize",definitions);
@@ -178,7 +178,7 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
* @param weaver
* @param loader
*/
- private List parseDefinitions(final ClassLoader loader) {
+ List parseDefinitions(final ClassLoader loader) {
if (trace.isTraceEnabled()) trace.enter("parseDefinitions",this,loader);
List definitions = new ArrayList();
diff --git a/loadtime/src/org/aspectj/weaver/loadtime/DefaultWeavingContext.java b/loadtime/src/org/aspectj/weaver/loadtime/DefaultWeavingContext.java
index 02c8a091e..6ffd2cb28 100644
--- a/loadtime/src/org/aspectj/weaver/loadtime/DefaultWeavingContext.java
+++ b/loadtime/src/org/aspectj/weaver/loadtime/DefaultWeavingContext.java
@@ -14,6 +14,11 @@ package org.aspectj.weaver.loadtime;
import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;
+import java.util.List;
+
+import org.aspectj.weaver.tools.Trace;
+import org.aspectj.weaver.tools.TraceFactory;
+import org.aspectj.weaver.tools.WeavingAdaptor;
/**
* Use in non-OSGi environment
@@ -21,17 +26,19 @@ import java.util.Enumeration;
* @author David Knibb
*/
public class DefaultWeavingContext implements IWeavingContext {
-
+
protected ClassLoader loader;
-
private String shortName;
+ private static Trace trace = TraceFactory.getTraceFactory().getTrace(DefaultWeavingContext.class);
+
/**
* Construct a new WeavingContext to use the specifed ClassLoader
* This is the constructor which should be used.
* @param loader
*/
public DefaultWeavingContext(ClassLoader loader) {
+ super();
this.loader = loader;
}
@@ -93,4 +100,19 @@ public class DefaultWeavingContext implements IWeavingContext {
}
return isLocallyDefined;
}
+
+ /**
+ * Simply call weaving adaptor back to parse aop.xml
+ *
+ * @param weaver
+ * @param loader
+ */
+ public List getDefinitions(final ClassLoader loader, final WeavingAdaptor adaptor) {
+ if (trace.isTraceEnabled()) trace.enter("getDefinitions",this,new Object[] { loader, adaptor });
+
+ List definitions = ((ClassLoaderWeavingAdaptor)adaptor).parseDefinitions(loader);
+
+ if (trace.isTraceEnabled()) trace.exit("getDefinitions",definitions);
+ return definitions;
+ }
}
diff --git a/loadtime/testsrc/org/aspectj/weaver/loadtime/WeavingContextTest.java b/loadtime/testsrc/org/aspectj/weaver/loadtime/WeavingContextTest.java
index c056b9ee6..97e037317 100644
--- a/loadtime/testsrc/org/aspectj/weaver/loadtime/WeavingContextTest.java
+++ b/loadtime/testsrc/org/aspectj/weaver/loadtime/WeavingContextTest.java
@@ -15,9 +15,12 @@ import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Enumeration;
+import java.util.List;
import junit.framework.TestCase;
+import org.aspectj.weaver.tools.WeavingAdaptor;
+
public class WeavingContextTest extends TestCase {
private boolean called;
@@ -115,6 +118,24 @@ public class WeavingContextTest extends TestCase {
assertTrue("IWeavingContext not called",called);
}
+ public void testGetDefinitions () throws Exception {
+ File file = new File("../loadtime/testdata");
+ URL fileURL = file.getCanonicalFile().toURL();
+ URLClassLoader loader = new URLClassLoader(new URL[] { fileURL },null);
+ IWeavingContext context = new TestWeavingContext(loader) {
+
+ public List getDefinitions(ClassLoader loader, WeavingAdaptor adaptor) {
+ called = true;
+ return super.getDefinitions(loader,adaptor);
+ }
+
+ };
+ ClassLoaderWeavingAdaptor adaptor = new ClassLoaderWeavingAdaptor();
+ adaptor.initialize(loader,context);
+
+ assertTrue("getDefinitions not called",called);
+ }
+
private static class TestWeavingContext implements IWeavingContext {
private ClassLoader loader;
@@ -157,6 +178,10 @@ public class WeavingContextTest extends TestCase {
}
return isLocallyDefined;
}
+
+ public List getDefinitions(ClassLoader loader, WeavingAdaptor adaptor) {
+ return ((ClassLoaderWeavingAdaptor)adaptor).parseDefinitions(loader);
+ }
}
protected void setUp() throws Exception {