diff options
author | nash <nash@13f79535-47bb-0310-9956-ffa450edef68> | 2009-09-13 22:43:33 +0000 |
---|---|---|
committer | nash <nash@13f79535-47bb-0310-9956-ffa450edef68> | 2009-09-13 22:43:33 +0000 |
commit | a130ca46f0d6805c3d31f5f6818c8ec6924cac8c (patch) | |
tree | b887165e13042b57f16b976634010c187d2b056a /branches/sca-java-1.x/itest/recursive | |
parent | bc1bcc9e57a1151773d424dcd3ddf437d7d2a2bc (diff) |
Copy r810820, r810822 and r810850 changes from 1.5.1 branch to 1.x branch
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@814415 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.x/itest/recursive')
3 files changed, 17 insertions, 11 deletions
diff --git a/branches/sca-java-1.x/itest/recursive/src/main/java/composite/SourceImpl.java b/branches/sca-java-1.x/itest/recursive/src/main/java/composite/SourceImpl.java index b9a0c7ff74..72bf552a1e 100644 --- a/branches/sca-java-1.x/itest/recursive/src/main/java/composite/SourceImpl.java +++ b/branches/sca-java-1.x/itest/recursive/src/main/java/composite/SourceImpl.java @@ -27,6 +27,7 @@ import org.osoa.sca.annotations.Service; @Scope("COMPOSITE") public class SourceImpl implements Source, SourceCallback { + public static int callbackCount = 0; private Target targetReference; private Target targetReference2; @@ -49,6 +50,9 @@ public class SourceImpl implements Source, SourceCallback { } public void receiveResult(String result) { + synchronized(this) { + callbackCount += 1; + } System.out.println("Work thread " + Thread.currentThread()); System.out.println("Result: " + result); } diff --git a/branches/sca-java-1.x/itest/recursive/src/main/java/composite/TargetImpl.java b/branches/sca-java-1.x/itest/recursive/src/main/java/composite/TargetImpl.java index 86686e9233..e744aa7967 100644 --- a/branches/sca-java-1.x/itest/recursive/src/main/java/composite/TargetImpl.java +++ b/branches/sca-java-1.x/itest/recursive/src/main/java/composite/TargetImpl.java @@ -18,7 +18,9 @@ */ package composite; +import org.osoa.sca.ComponentContext; import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Context; import org.osoa.sca.annotations.Scope; import org.osoa.sca.annotations.Service; @@ -27,15 +29,16 @@ import org.osoa.sca.annotations.Service; @Scope("COMPOSITE") public class TargetImpl implements Target { - private SourceCallback sourceCallback; + private ComponentContext ctx; - @Callback - public void setSourceCallback(SourceCallback sourceCallback) { - this.sourceCallback = sourceCallback; + @Context + public void setContext(ComponentContext context) { + ctx = context; } public void someMethod(String arg) { System.out.println("Target: " + arg); + SourceCallback sourceCallback = (SourceCallback)ctx.getRequestContext().getCallbackReference().getService(); sourceCallback.receiveResult(arg + " -> Target.someMethod"); } } diff --git a/branches/sca-java-1.x/itest/recursive/src/test/java/composite/CompositeTestCase.java b/branches/sca-java-1.x/itest/recursive/src/test/java/composite/CompositeTestCase.java index 5482e47463..928cb3fea9 100644 --- a/branches/sca-java-1.x/itest/recursive/src/test/java/composite/CompositeTestCase.java +++ b/branches/sca-java-1.x/itest/recursive/src/test/java/composite/CompositeTestCase.java @@ -39,13 +39,12 @@ public class CompositeTestCase extends TestCase { } public void test() throws Exception { - try { - System.out.println("Main thread " + Thread.currentThread()); - source.clientMethod("Client.main"); - System.out.println("Sleeping ..."); - Thread.sleep(1000); - } catch (Throwable t) { - t.printStackTrace(); + System.out.println("Main thread " + Thread.currentThread()); + source.clientMethod("Client.main"); + System.out.println("Sleeping ..."); + Thread.sleep(1000); + if (SourceImpl.callbackCount != 2) { + throw new IllegalStateException("Expected callbacks not received"); } } } |