@@ -193,17 +193,17 @@ public class DocumentParser extends DefaultHandler { | |||
} else if (ASPECTS_ELEMENT.equals(qName)) { | |||
m_inAspects = true; | |||
} else if (INCLUDE_ELEMENT.equals(qName) && m_inWeaver) { | |||
String typePattern = attributes.getValue(WITHIN_ATTRIBUTE); | |||
String typePattern = getWithinAttribute(attributes); | |||
if (!isNull(typePattern)) { | |||
m_definition.getIncludePatterns().add(typePattern); | |||
} | |||
} else if (EXCLUDE_ELEMENT.equals(qName) && m_inWeaver) { | |||
String typePattern = attributes.getValue(WITHIN_ATTRIBUTE); | |||
String typePattern = getWithinAttribute(attributes); | |||
if (!isNull(typePattern)) { | |||
m_definition.getExcludePatterns().add(typePattern); | |||
} | |||
} else if (DUMP_ELEMENT.equals(qName) && m_inWeaver) { | |||
String typePattern = attributes.getValue(WITHIN_ATTRIBUTE); | |||
String typePattern = getWithinAttribute(attributes); | |||
if (!isNull(typePattern)) { | |||
m_definition.getDumpPatterns().add(typePattern); | |||
} | |||
@@ -212,12 +212,12 @@ public class DocumentParser extends DefaultHandler { | |||
m_definition.setDumpBefore(true); | |||
} | |||
} else if (EXCLUDE_ELEMENT.equals(qName) && m_inAspects) { | |||
String typePattern = attributes.getValue(WITHIN_ATTRIBUTE); | |||
String typePattern = getWithinAttribute(attributes); | |||
if (!isNull(typePattern)) { | |||
m_definition.getAspectExcludePatterns().add(typePattern); | |||
} | |||
} else if (INCLUDE_ELEMENT.equals(qName) && m_inAspects) { | |||
String typePattern = attributes.getValue(WITHIN_ATTRIBUTE); | |||
String typePattern = getWithinAttribute(attributes); | |||
if (!isNull(typePattern)) { | |||
m_definition.getAspectIncludePatterns().add(typePattern); | |||
} | |||
@@ -227,6 +227,10 @@ public class DocumentParser extends DefaultHandler { | |||
super.startElement(uri, localName, qName, attributes); | |||
} | |||
private String getWithinAttribute(Attributes attributes) { | |||
return replaceXmlAnd(attributes.getValue(WITHIN_ATTRIBUTE)); | |||
} | |||
public void endElement(String uri, String localName, String qName) throws SAXException { | |||
if (CONCRETE_ASPECT_ELEMENT.equals(qName)) { | |||
m_lastConcreteAspect = null; |
@@ -0,0 +1,10 @@ | |||
<aspectj> | |||
<aspects> | |||
<aspect name="tracing.Tracer"/> | |||
<aspect name="tracing.staticinit.Tracer"/> | |||
<aspect name="tracing.staticinit.sub.Tracer"/> | |||
<include within="tracing..* AND !tracing.staticinit.sub..*"/> | |||
<exclude within="tracing..* AND !tracing.staticinit..*"/> | |||
</aspects> | |||
</aspectj> | |||
@@ -0,0 +1,9 @@ | |||
<aspectj> | |||
<weaver> | |||
<exclude within="pkg..* AND !pkg.sub..*"/> | |||
</weaver> | |||
<aspects> | |||
<aspect name="tracing.Tracer"/> | |||
</aspects> | |||
</aspectj> | |||
@@ -0,0 +1,10 @@ | |||
<aspectj> | |||
<weaver> | |||
<include within="pkg..* AND !pkg.sub..*"/> | |||
<dump within="pkg..* AND !pkg.sub..*"/> | |||
</weaver> | |||
<aspects> | |||
<aspect name="tracing.Tracer"/> | |||
</aspects> | |||
</aspectj> | |||
@@ -0,0 +1,46 @@ | |||
package pkg; | |||
import java.io.File; | |||
public class Main { | |||
public static void main(String argz[]) { | |||
foo(); | |||
} | |||
public static void foo() { | |||
(new pkg.sub.Foo()).foo(); | |||
File dumpDir = new File("_ajdump"); | |||
lsLR(dumpDir); | |||
// the LTW harness should clean up _ajdump files! | |||
cleanup(dumpDir); | |||
} | |||
public static void lsLR(File dir) { | |||
String[] files = dir.list(); | |||
if (files == null) return; | |||
for (int i=0; i<files.length; i++) { | |||
File f = new File(dir, files[i]); | |||
if (f.isFile()) { | |||
System.err.println(files[i]); | |||
} else { | |||
lsLR(f); | |||
} | |||
} | |||
} | |||
public static void cleanup(File dir) { | |||
String[] files = dir.list(); | |||
if (files == null) return; | |||
for (int i=0; i<files.length; i++) { | |||
File f = new File(dir, files[i]); | |||
if (f.isFile()) { | |||
f.delete(); | |||
} else { | |||
cleanup(f); | |||
} | |||
} | |||
dir.delete(); | |||
} | |||
} |
@@ -0,0 +1,5 @@ | |||
package pkg.sub; | |||
public class Foo { | |||
public void foo() {} | |||
} |
@@ -0,0 +1,7 @@ | |||
package tracing; | |||
public aspect Tracer { | |||
before() : execution(* foo()) { | |||
System.err.println(thisJoinPoint); | |||
} | |||
} |
@@ -0,0 +1,7 @@ | |||
package tracing.staticinit; | |||
public aspect Tracer { | |||
before() : staticinitialization(pkg..*) { | |||
System.err.println(thisJoinPoint); | |||
} | |||
} |
@@ -0,0 +1,7 @@ | |||
package tracing.staticinit.sub; | |||
public aspect Tracer { | |||
before() : staticinitialization(pkg..*) { | |||
System.err.println("sub: "+thisJoinPoint); | |||
} | |||
} |
@@ -30,8 +30,18 @@ public class LTWTests extends org.aspectj.testing.XMLBasedAjcTestCase { | |||
return new File("../tests/src/org/aspectj/systemtest/ajc150/ltw/ltw.xml"); | |||
} | |||
public void testInclusionAndPattern() { | |||
runTest("Inclusion and patterns"); | |||
} | |||
public void testExclusionAndPattern() { | |||
runTest("Exclusion and patterns"); | |||
} | |||
public void testAndPatternsAspects() { | |||
runTest("And patterns aspects"); | |||
} | |||
public void test001(){ | |||
runTest("Ensure 1st aspect is rewoven when weaving 2nd aspect"); | |||
} |
@@ -593,5 +593,50 @@ | |||
</stdout> | |||
</ant> | |||
</ajc-test> | |||
<ajc-test dir="ltw/inclExcl" title="Inclusion and patterns" keywords="ltw"> | |||
<compile | |||
files="pkg\sub\Foo.aj, pkg\Main.aj" | |||
options="-outjar base.jar" | |||
/> | |||
<compile | |||
files="tracing/Tracer.aj" | |||
/> | |||
<run class="pkg.Main" ltw="aop-include.xml"> | |||
<stderr> | |||
<line text="execution(void pkg.Main.foo())"/> | |||
<line text="Main.class"/> | |||
</stderr> | |||
</run> | |||
</ajc-test> | |||
<ajc-test dir="ltw/inclExcl" title="Exclusion and patterns" keywords="ltw"> | |||
<compile | |||
files="pkg\sub\Foo.aj, pkg\Main.aj" | |||
options="-outjar base.jar" | |||
/> | |||
<compile | |||
files="tracing/Tracer.aj" | |||
/> | |||
<run class="pkg.Main" ltw="aop-exclude.xml"> | |||
<stderr> | |||
<line text="execution(void pkg.sub.Foo.foo())"/> | |||
</stderr> | |||
</run> | |||
</ajc-test> | |||
<ajc-test dir="ltw/inclExcl" title="And patterns aspects" keywords="ltw"> | |||
<compile | |||
files="pkg\sub\Foo.aj, pkg\Main.aj" | |||
options="-outjar base.jar" | |||
/> | |||
<compile | |||
files="tracing/Tracer.aj, tracing/staticinit/Tracer.aj, tracing/staticinit/sub/Tracer.aj" | |||
/> | |||
<run class="pkg.Main" ltw="aop-aspectinclexcl.xml"> | |||
<stderr> | |||
<line text="staticinitialization(pkg.Main.<clinit>)"/> | |||
<line text="staticinitialization(pkg.sub.Foo.<clinit>)"/> | |||
</stderr> | |||
</run> | |||
</ajc-test> | |||