You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by kw...@apache.org on 2008/05/10 00:27:11 UTC

svn commit: r654964 - in /incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src: main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/ main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessin...

Author: kwilliams
Date: Fri May  9 15:27:11 2008
New Revision: 654964

URL: http://svn.apache.org/viewvc?rev=654964&view=rev
Log:
More tests for conversation callback-accessing, TUSCANY-2247

Added:
    incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/
    incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/AServiceCallback.java   (with props)
    incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/BService.java   (with props)
    incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/impl/
    incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/impl/AServiceImpl.java   (with props)
    incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/impl/BServiceImpl.java   (with props)
    incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/resources/callback-accessing.composite   (with props)
Modified:
    incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/test/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/CallbackTestCase.java

Added: incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/AServiceCallback.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/AServiceCallback.java?rev=654964&view=auto
==============================================================================
--- incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/AServiceCallback.java (added)
+++ incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/AServiceCallback.java Fri May  9 15:27:11 2008
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.vtest.javaapi.conversation.callback.accessing;
+
+import org.osoa.sca.annotations.Conversational;
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Simple Remotable Service
+ */
+@Remotable
+@Conversational
+public interface AServiceCallback {
+
+    public void callBack(String someState);
+    
+}

Propchange: incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/AServiceCallback.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/AServiceCallback.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/BService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/BService.java?rev=654964&view=auto
==============================================================================
--- incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/BService.java (added)
+++ incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/BService.java Fri May  9 15:27:11 2008
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.vtest.javaapi.conversation.callback.accessing;
+
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Conversational;
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Simple Service
+ */
+@Remotable
+@Conversational
+@Callback(AServiceCallback.class)
+public interface BService {
+
+    public void setState(String someState);
+    
+    public String getState();
+
+    public void testCallBack(String string);
+
+    public void testCallBack2(String string);
+
+}

Propchange: incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/BService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/BService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/impl/AServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/impl/AServiceImpl.java?rev=654964&view=auto
==============================================================================
--- incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/impl/AServiceImpl.java (added)
+++ incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/impl/AServiceImpl.java Fri May  9 15:27:11 2008
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.vtest.javaapi.conversation.callback.accessing.impl;
+
+import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.AService;
+import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.Utilities;
+import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.accessing.AServiceCallback;
+import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.accessing.BService;
+import org.junit.Assert;
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+@Service(AService.class)
+@Scope("CONVERSATION")
+public class AServiceImpl implements AService, AServiceCallback {
+
+    @Reference
+    protected ServiceReference<BService> b;
+
+    private String someState;
+
+    public void callBack(String someState) {
+        System.out.println("A-callback called with this state => " + someState);
+        this.someState = someState;
+    }
+
+    public void testCallback() {
+        b.getService().testCallBack("Some string");
+        int count = 4;
+        while (someState == null && count > 0) {
+            Utilities.delayQuarterSecond();
+            count--;
+        }
+        if (someState == null)
+            Assert.fail("Callback not received by this instance");
+    }
+
+    public void testCallback2() {
+        b.getService().testCallBack2("Some string");
+        int count = 4;
+        while (someState == null && count > 0) {
+            Utilities.delayQuarterSecond();
+            count--;
+        }
+        if (someState == null)
+            Assert.fail("Callback not received by this instance");
+    }
+}

Propchange: incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/impl/AServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/impl/AServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/impl/BServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/impl/BServiceImpl.java?rev=654964&view=auto
==============================================================================
--- incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/impl/BServiceImpl.java (added)
+++ incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/impl/BServiceImpl.java Fri May  9 15:27:11 2008
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.vtest.javaapi.conversation.callback.accessing.impl;
+
+import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.accessing.AServiceCallback;
+import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.accessing.BService;
+import org.osoa.sca.CallableReference;
+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;
+
+@Service(BService.class)
+@Scope("CONVERSATION")
+public class BServiceImpl implements BService {
+
+    String someState;
+
+    @Callback
+    protected CallableReference<AServiceCallback> callback;
+    
+    @Context
+    protected ComponentContext componentContext;
+
+    public void setState(String someState) {
+        this.someState = someState;
+    }
+
+    public String getState() {
+        return someState;
+    }
+
+    public void testCallBack(String someState) {
+        callback.getService().callBack(someState);
+    }
+
+    public void testCallBack2(String someState) {
+        AServiceCallback callback = componentContext.getRequestContext().getCallback();
+        callback.callBack(someState);
+    }
+
+}

Propchange: incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/impl/BServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/accessing/impl/BServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/resources/callback-accessing.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/resources/callback-accessing.composite?rev=654964&view=auto
==============================================================================
--- incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/resources/callback-accessing.composite (added)
+++ incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/resources/callback-accessing.composite Fri May  9 15:27:11 2008
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+	* Licensed to the Apache Software Foundation (ASF) under one
+	* or more contributor license agreements.  See the NOTICE file
+	* distributed with this work for additional information
+	* regarding copyright ownership.  The ASF licenses this file
+	* to you under the Apache License, Version 2.0 (the
+	* "License"); you may not use this file except in compliance
+	* with the License.  You may obtain a copy of the License at
+	*
+	*   http://www.apache.org/licenses/LICENSE-2.0
+	*
+	* Unless required by applicable law or agreed to in writing,
+	* software distributed under the License is distributed on an
+	* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+	* KIND, either express or implied.  See the License for the
+	* specific language governing permissions and limitations
+	* under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+	targetNamespace="http://java-api-tests" name="Conversation-callback-multi">
+
+	<component name="AComponent">
+		<implementation.java
+			class="org.apache.tuscany.sca.vtest.javaapi.conversation.callback.accessing.impl.AServiceImpl" />
+		<reference name="b" target="BComponent" />
+	</component>
+
+	<component name="BComponent">
+		<implementation.java
+			class="org.apache.tuscany.sca.vtest.javaapi.conversation.callback.accessing.impl.BServiceImpl" />
+	</component>
+
+</composite>

Propchange: incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/resources/callback-accessing.composite
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/resources/callback-accessing.composite
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/resources/callback-accessing.composite
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/test/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/CallbackTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/test/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/CallbackTestCase.java?rev=654964&r1=654963&r2=654964&view=diff
==============================================================================
--- incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/test/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/CallbackTestCase.java (original)
+++ incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/test/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/CallbackTestCase.java Fri May  9 15:27:11 2008
@@ -284,7 +284,37 @@
         domain = SCADomain.newInstance("callback-multi.composite");
         aService = domain.getService(AService.class, "AComponent");
         aService.testCallback();
-        aService.testCallback2(); //Includes test for 670,671
+        aService.testCallback2(); // Includes test for 670,671
+
+    }
+
+    /**
+     * Lines 675-706
+     * <p>
+     * In addition to injecting a reference to a callback service, it is also
+     * possible to obtain a reference to a Callback instance by annotating a
+     * field or method with the "@Callback" annotation. A reference implementing
+     * the callback service interface may be obtained using
+     * CallableReference.getService(). The following fragments come from a
+     * service implementation that uses the callback API:
+     * <p>
+     * Alternatively a callback may be retrieved programmatically using the
+     * RequestContext API. The snippet below show how to retrieve a callback in
+     * a method programmatically:
+     * <p>
+     * Lines 695, 696
+     * <p>
+     * Alternatively a callback may be retrieved programmatically using the
+     * RequestContext API. The snippet below show how to retrieve a callback in
+     * a method programmatically:
+     */
+    @Test
+    public void accessingCallbacks() throws Exception {
+        System.out.println("Setting up for callback accessing tests");
+        domain = SCADomain.newInstance("callback-accessing.composite");
+        aService = domain.getService(AService.class, "AComponent");
+        aService.testCallback();
+        aService.testCallback2(); //Lines 695-696
 
     }
 }