@@ -0,0 +1,13 @@ | |||
package be.cronos.aop; | |||
@InterTypeAspectSupport | |||
public class App { | |||
public static void main(String[] args) { | |||
// System.out.println( "Hello World!" ); //should throw compiler error, | |||
// OK | |||
App app = new App(); | |||
app.foo(42); | |||
} | |||
} |
@@ -0,0 +1,38 @@ | |||
//package be.cronos.experiment; | |||
// | |||
//import junit.framework.Test; | |||
//import junit.framework.TestCase; | |||
//import junit.framework.TestSuite; | |||
// | |||
///** | |||
// * Unit test for simple App. | |||
// */ | |||
//public class AppTest | |||
// extends TestCase | |||
//{ | |||
// /** | |||
// * Create the test case | |||
// * | |||
// * @param testName name of the test case | |||
// */ | |||
// public AppTest( String testName ) | |||
// { | |||
// super( testName ); | |||
// } | |||
// | |||
// /** | |||
// * @return the suite of tests being tested | |||
// */ | |||
// public static Test suite() | |||
// { | |||
// return new TestSuite( AppTest.class ); | |||
// } | |||
// | |||
// /** | |||
// * Rigourous Test :-) | |||
// */ | |||
// public void testApp() | |||
// { | |||
// assertTrue( true ); | |||
// } | |||
//} |
@@ -0,0 +1,16 @@ | |||
package be.cronos.aop; | |||
import be.cronos.aop.InterTypeAspectSupport; | |||
@InterTypeAspectSupport | |||
public class App | |||
{ | |||
public static void main( String[] args ) | |||
{ | |||
//System.out.println( "Hello World!" ); //should throw compiler error, OK | |||
App app = new App(); | |||
app.foo(42); | |||
} | |||
} |
@@ -0,0 +1,12 @@ | |||
package be.cronos.aop; | |||
import java.lang.annotation.ElementType; | |||
import java.lang.annotation.Retention; | |||
import java.lang.annotation.RetentionPolicy; | |||
import java.lang.annotation.Target; | |||
@Retention(RetentionPolicy.RUNTIME) | |||
@Target(ElementType.TYPE) | |||
public @interface InterTypeAspectSupport { | |||
} |
@@ -0,0 +1,16 @@ | |||
package be.cronos.aop.aspects; | |||
//import junit.framework.TestCase; | |||
public aspect EnforceLogging { | |||
pointcut scope(): | |||
!within(*TestCase+); | |||
pointcut printing(): | |||
get(* System.out) || get(* System.err) || call(* printStackTrace()); | |||
declare error | |||
: scope() && printing() | |||
: "Don't print to Console, use logger"; | |||
} |
@@ -0,0 +1,16 @@ | |||
package be.cronos.aop.aspects; | |||
import be.cronos.aop.InterTypeAspectSupport; | |||
public aspect InterTypeAspect { | |||
public interface InterTypeAspectInterface { | |||
} | |||
declare parents : (@InterTypeAspectSupport *) implements InterTypeAspectInterface; | |||
public String InterTypeAspectInterface.foo(int i) { | |||
return "bar"; | |||
} | |||
} |