]> source.dussan.org Git - aspectj.git/commitdiff
220255: testcode
authoraclement <aclement>
Tue, 26 Feb 2008 00:57:52 +0000 (00:57 +0000)
committeraclement <aclement>
Tue, 26 Feb 2008 00:57:52 +0000 (00:57 +0000)
12 files changed:
tests/multiIncremental/pr220255/base/BussFacade.java [new file with mode: 0644]
tests/multiIncremental/pr220255/base/ClientCode.java [new file with mode: 0644]
tests/multiIncremental/pr220255/base/ClientProxy.java [new file with mode: 0644]
tests/multiIncremental/pr220255/base/Clientside.java [new file with mode: 0644]
tests/multiIncremental/pr220255/base/Factory.java [new file with mode: 0644]
tests/multiIncremental/pr220255/base/FactoryMarker.aj [new file with mode: 0644]
tests/multiIncremental/pr220255/base/MyInterface.java [new file with mode: 0644]
tests/multiIncremental/pr220255/base/MyServiceImpl.java [new file with mode: 0644]
tests/multiIncremental/pr220255/base/NeedsXYZ.java [new file with mode: 0644]
tests/multiIncremental/pr220255/base/ServiceCall.aj [new file with mode: 0644]
tests/multiIncremental/pr220255/base/YetAnotherClass.java [new file with mode: 0644]
tests/multiIncremental/pr220255/inc1/MyServiceImpl.java [new file with mode: 0644]

diff --git a/tests/multiIncremental/pr220255/base/BussFacade.java b/tests/multiIncremental/pr220255/base/BussFacade.java
new file mode 100644 (file)
index 0000000..8c7092a
--- /dev/null
@@ -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 (file)
index 0000000..8cd4287
--- /dev/null
@@ -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 (file)
index 0000000..0ddfa48
--- /dev/null
@@ -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 (file)
index 0000000..99e1e5f
--- /dev/null
@@ -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 (file)
index 0000000..9c74c8f
--- /dev/null
@@ -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 (file)
index 0000000..b2de710
--- /dev/null
@@ -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 (file)
index 0000000..8cf7fc3
--- /dev/null
@@ -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 (file)
index 0000000..911fe81
--- /dev/null
@@ -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 (file)
index 0000000..9e60e22
--- /dev/null
@@ -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 (file)
index 0000000..3e9b449
--- /dev/null
@@ -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 (file)
index 0000000..acb9a57
--- /dev/null
@@ -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 (file)
index 0000000..ef69e66
--- /dev/null
@@ -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);
+    }
+
+}