} 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);
}
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);
}
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;
--- /dev/null
+<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>
+
--- /dev/null
+<aspectj>
+<weaver>
+<exclude within="pkg..* AND !pkg.sub..*"/>
+</weaver>
+<aspects>
+<aspect name="tracing.Tracer"/>
+</aspects>
+</aspectj>
+
--- /dev/null
+<aspectj>
+<weaver>
+<include within="pkg..* AND !pkg.sub..*"/>
+<dump within="pkg..* AND !pkg.sub..*"/>
+</weaver>
+<aspects>
+<aspect name="tracing.Tracer"/>
+</aspects>
+</aspectj>
+
--- /dev/null
+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();
+ }
+}
--- /dev/null
+package pkg.sub;
+
+public class Foo {
+ public void foo() {}
+}
--- /dev/null
+package tracing;
+
+public aspect Tracer {
+ before() : execution(* foo()) {
+ System.err.println(thisJoinPoint);
+ }
+}
--- /dev/null
+package tracing.staticinit;
+
+public aspect Tracer {
+ before() : staticinitialization(pkg..*) {
+ System.err.println(thisJoinPoint);
+ }
+}
--- /dev/null
+package tracing.staticinit.sub;
+
+public aspect Tracer {
+ before() : staticinitialization(pkg..*) {
+ System.err.println("sub: "+thisJoinPoint);
+ }
+}
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");
}
</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>
\ No newline at end of file