From: aclement Date: Tue, 26 Feb 2008 00:57:52 +0000 (+0000) Subject: 220255: testcode X-Git-Tag: V1_6_0M2~7 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9bf93cb12883ffb32db388a5d2a76b97cafca622;p=aspectj.git 220255: testcode --- diff --git a/tests/multiIncremental/pr220255/base/BussFacade.java b/tests/multiIncremental/pr220255/base/BussFacade.java new file mode 100644 index 000000000..8c7092af9 --- /dev/null +++ b/tests/multiIncremental/pr220255/base/BussFacade.java @@ -0,0 +1,5 @@ + + +public @interface BussFacade { + +} diff --git a/tests/multiIncremental/pr220255/base/ClientCode.java b/tests/multiIncremental/pr220255/base/ClientCode.java new file mode 100644 index 000000000..8cd428707 --- /dev/null +++ b/tests/multiIncremental/pr220255/base/ClientCode.java @@ -0,0 +1,30 @@ + + + + +@NeedsXYZ +public class ClientCode +{ + + MyInterface __Interface__ = null; + + ClientProxy specialConfigProxy = new ClientProxy(); + + + void doIt() { + System.out.println("hold onto your hat..."); + System.out.println("the answer is:"+ __Interface__.doB(42)); // direct Call is intercepted here + + System.out.println("and now, " + + specialConfigProxy.additionalValueServiceForTheCustomer() + ); // indirect call is intercepted in the proxy + } + + + + public static void main(String[] args) { + + new ClientCode().doIt(); + + } +} diff --git a/tests/multiIncremental/pr220255/base/ClientProxy.java b/tests/multiIncremental/pr220255/base/ClientProxy.java new file mode 100644 index 000000000..0ddfa48bc --- /dev/null +++ b/tests/multiIncremental/pr220255/base/ClientProxy.java @@ -0,0 +1,18 @@ + + +public class ClientProxy extends MyServiceImpl +{ + + // just for this demo here; this cast allows + // us to call to the interface (without the cast + // we'd get a class cast exception) + MyInterface this_in_disguise = this; + + + @Clientside + public String additionalValueServiceForTheCustomer() { + return "if you don't know what to ask, then you " + + this_in_disguise.doA(42); // call through to the server side + } + +} diff --git a/tests/multiIncremental/pr220255/base/Clientside.java b/tests/multiIncremental/pr220255/base/Clientside.java new file mode 100644 index 000000000..99e1e5fb9 --- /dev/null +++ b/tests/multiIncremental/pr220255/base/Clientside.java @@ -0,0 +1,6 @@ + + +public @interface Clientside { + + +} diff --git a/tests/multiIncremental/pr220255/base/Factory.java b/tests/multiIncremental/pr220255/base/Factory.java new file mode 100644 index 000000000..9c74c8ff5 --- /dev/null +++ b/tests/multiIncremental/pr220255/base/Factory.java @@ -0,0 +1,5 @@ + + +public @interface Factory { + +} diff --git a/tests/multiIncremental/pr220255/base/FactoryMarker.aj b/tests/multiIncremental/pr220255/base/FactoryMarker.aj new file mode 100644 index 000000000..b2de710c9 --- /dev/null +++ b/tests/multiIncremental/pr220255/base/FactoryMarker.aj @@ -0,0 +1,23 @@ + + + +// NOTE: the presence of this Aspect, together with ServiceCall.aj +// seems to trigger the infinite loop on the second or third re-build. +// +// Sometimes it triggered even if the @NeedsXYZ isn't used at all + +public aspect FactoryMarker +{ + + public interface BootSpringKontext { }; + + declare parents : @NeedsXYZ * implements BootSpringKontext; + + public Object[] BootSpringKontext.loadXYZ() { + return new Object[] {"load it"}; + } + + + declare @method : Object[] loadXYZ*() : @Factory; + +} diff --git a/tests/multiIncremental/pr220255/base/MyInterface.java b/tests/multiIncremental/pr220255/base/MyInterface.java new file mode 100644 index 000000000..8cf7fc3f5 --- /dev/null +++ b/tests/multiIncremental/pr220255/base/MyInterface.java @@ -0,0 +1,10 @@ + +@BussFacade +public interface MyInterface +{ + + String doA(int lo); + + String doB(int lolo); + +} diff --git a/tests/multiIncremental/pr220255/base/MyServiceImpl.java b/tests/multiIncremental/pr220255/base/MyServiceImpl.java new file mode 100644 index 000000000..911fe81ab --- /dev/null +++ b/tests/multiIncremental/pr220255/base/MyServiceImpl.java @@ -0,0 +1,15 @@ + +public class MyServiceImpl implements MyInterface +{ + + public String doA(int lololo) { + System.out.println("really did it "+lololo); + return "really got it: "+lololo; + } + + + public String doB(int lala) { + return doA(lala); + } + +} diff --git a/tests/multiIncremental/pr220255/base/NeedsXYZ.java b/tests/multiIncremental/pr220255/base/NeedsXYZ.java new file mode 100644 index 000000000..9e60e2214 --- /dev/null +++ b/tests/multiIncremental/pr220255/base/NeedsXYZ.java @@ -0,0 +1,4 @@ + +public @interface NeedsXYZ { + +} diff --git a/tests/multiIncremental/pr220255/base/ServiceCall.aj b/tests/multiIncremental/pr220255/base/ServiceCall.aj new file mode 100644 index 000000000..3e9b449ca --- /dev/null +++ b/tests/multiIncremental/pr220255/base/ServiceCall.aj @@ -0,0 +1,59 @@ +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.Signature; + + +@Clientside +public aspect ServiceCall +{ + + public pointcut ServicePoint() + : call( * (@BussFacade *).*(..) ) + && !@within(Clientside) + && !@annotation(Clientside) + && ( !@within(ServiceImplementation) + || @withincode(Clientside) + ) + ; + + declare @type + : hasmethod(* (@BussFacade *).*(..)) : @ServiceImplementation + ; + + public @interface ServiceImplementation { } + + + private pointcut call_Service(Object businessFacade) + : ServicePoint() + && target(businessFacade); + + + protected Object findImpl(Object bussFacade, JoinPoint.StaticPart location) + { + Class dienstID; + if ( null!=bussFacade ) + dienstID = bussFacade.getClass(); + else { + Signature sig = location.getSignature(); + dienstID = sig.getDeclaringType(); + } + Object impl = new MyServiceImpl(); // call ServiceLocator here + return impl; + } + + + + Object around(Object bussFacade) + : call_Service(bussFacade) + { + try { + Object umgelenkt = findImpl(bussFacade, thisJoinPointStaticPart); + Object res = proceed(umgelenkt); + return res; + } + catch(Throwable T) { + System.out.println("oh my"); + throw new RuntimeException(T); + } + } + +} diff --git a/tests/multiIncremental/pr220255/base/YetAnotherClass.java b/tests/multiIncremental/pr220255/base/YetAnotherClass.java new file mode 100644 index 000000000..acb9a57fd --- /dev/null +++ b/tests/multiIncremental/pr220255/base/YetAnotherClass.java @@ -0,0 +1,8 @@ + + + +@NeedsXYZ +public class YetAnotherClass +{ + +} diff --git a/tests/multiIncremental/pr220255/inc1/MyServiceImpl.java b/tests/multiIncremental/pr220255/inc1/MyServiceImpl.java new file mode 100644 index 000000000..ef69e6619 --- /dev/null +++ b/tests/multiIncremental/pr220255/inc1/MyServiceImpl.java @@ -0,0 +1,15 @@ + +public class MyServiceImpl implements MyInterface +{ + + public String doA(int lololo) { + System.out.println("really did it "+lololo); + return "really got it: "+lololo; + } + + + public String doB(int lala) { + return doA(lala); + } + +}