You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jb...@apache.org on 2007/01/24 16:11:18 UTC

svn commit: r499432 - in /incubator/tuscany/sandbox/jboynes/sca-client/src: main/java/org/osoa/sca/ test/java/sample/ test/java/sample/client/ test/java/sample/implementation/

Author: jboynes
Date: Wed Jan 24 07:11:17 2007
New Revision: 499432

URL: http://svn.apache.org/viewvc?view=rev&rev=499432
Log:
undo conversation changes
add support for type-safe casts for references

Added:
    incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/
    incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/HelloCallback.java   (with props)
    incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/HelloService.java   (with props)
    incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/client/
    incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/client/BasicClient.java   (with props)
    incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/implementation/
Removed:
    incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/CallbackReference.java
    incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/Conversation.java
Modified:
    incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/CompositeContext.java
    incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/RequestContext.java
    incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/ServiceReference.java

Modified: incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/CompositeContext.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/CompositeContext.java?view=diff&rev=499432&r1=499431&r2=499432
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/CompositeContext.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/CompositeContext.java Wed Jan 24 07:11:17 2007
@@ -26,25 +26,32 @@
  */
 public interface CompositeContext extends ComponentContext {
     /**
-     * Returns a reference to a service within this composite.
+     * Returns a proxy reference to a service within this composite.
      * The service may be provided by a component or a reference that is defined in this composite.
      *
      * @param businessInterface the interface that will be used to invoke the service
      * @param serviceName       the name of service provided by a component or reference in this composite
-     * @return an object that implements the service's interface; may be a proxy
+     * @return an object that implements the service's interface
      */
-    <T> T locateService(Class<T> businessInterface, String serviceName);
+    <B> B locateService(Class<B> businessInterface, String serviceName);
 
     /**
      * Returns a ServiceReference to a service within this composite.
      * The service may be provided by a component or a reference that is defined in this composite.
      *
      * @param businessInterface the interface that will be used to invoke the service
-     * @param callbackInterface the interface that will be used for callbacks from the service
      * @param serviceName       the name of service provided by a component or reference in this composite
      * @return a reference to the designated service
      */
-    <B, CB> ServiceReference<B, CB> locateServiceReference(Class<B> businessInterface,
-                                                           Class<CB> callbackInterface,
-                                                           String serviceName);
+    <B> ServiceReference<B> locateServiceReference(Class<B> businessInterface, String serviceName);
+
+    /**
+     * Cast a type-safe reference to a ServiceReference.
+     * Converts a type-safe reference returned by locateService to an equivalent ServiceReference.
+     *
+     * @param target a reference proxy returned by a previous invocation of locateService()
+     * @return a ServiceReference equivalent for the proxy
+     * @throws IllegalArgumentException if the supplied instance is not a reference supplied by the implementation
+     */
+    <B> ServiceReference<B> cast(B target) throws IllegalArgumentException;
 }

Modified: incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/RequestContext.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/RequestContext.java?view=diff&rev=499432&r1=499431&r2=499432
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/RequestContext.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/RequestContext.java Wed Jan 24 07:11:17 2007
@@ -39,12 +39,4 @@
      * @return the name of the service that was invoked
      */
     String getServiceName();
-
-    /**
-     * Returns a reference to the callback for the current request.
-     *
-     * @param callbackInterface the callback interface the reference should use
-     * @return a reference to the callback for the current request
-     */
-    <CB> CallbackReference<CB> getCallbackReference(Class<CB> callbackInterface);
 }

Modified: incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/ServiceReference.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/ServiceReference.java?view=diff&rev=499432&r1=499431&r2=499432
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/ServiceReference.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/ServiceReference.java Wed Jan 24 07:11:17 2007
@@ -24,7 +24,7 @@
  *
  * @version $Rev$ $Date$
  */
-public interface ServiceReference<B, CB> {
+public interface ServiceReference<B> {
     /**
      * Returns a type-safe Java proxy to the target of this reference.
      * The instance returned is guaranteed to implement the business interface for this reference
@@ -35,74 +35,16 @@
     B getTarget();
 
     /**
-     * Returns the Java type of the business interface associated with this reference.
+     * Returns the Java class for the business interface associated with this reference.
      *
      * @return the Class for the business interfcace associated with this reference
      */
     Class<B> getBusinessInterface();
 
     /**
-     * Returns the Java type of the callback interface associated with this reference.
-     * @return the Java type of the callback interface associated with this reference
-     */
-    Class<CB> getCallbackInterface();
-
-    /**
      * Returns true if this reference is conversational.
      *
      * @return true if this reference is conversational
      */
     boolean isConversational();
-
-    /**
-     * Initiate a new conversation with the target service.
-     * The sessionId for the conversation will be generated by the SCA runtime.
-     *
-     * @return a new conversation with the target service
-     */
-    Conversation newSession();
-
-    /**
-     * Initiate a new conversation with the target service and designate a callback instance.
-     * The sessionId for the conversation will be generated by the SCA runtime.
-     *
-     * @param callback the object that callbacks should be dispatched to
-     * @return a new conversation with the target service
-     */
-    Conversation newSession(CB callback);
-
-    /**
-     * Initiate a new conversation with the target service and designate a callback reference.
-     * The sessionId for the conversation will be generated by the SCA runtime.
-     *
-     * @param callback a reference to a client that callbacks should be dispatched to
-     * @return a new conversation with the target service
-     */
-    Conversation newSession(CallbackReference<CB> callback);
-
-    /**
-     * Enlist the target service in an existing user-defined conversation.
-     *
-     * @param sessionId an Object that uniquely identifies the conversation; must be Serializable
-     * @return a new conversation with the target service
-     */
-    Conversation joinSession(Object sessionId);
-
-    /**
-     * Enlist the target service in an existing user-defined conversation.
-     *
-     * @param callback the object that callbacks should be dispatched to
-     * @param sessionId an Object that uniquely identifies the conversation; must be Serializable
-     * @return a new conversation with the target service
-     */
-    Conversation joinSession(CB callback, Object sessionId);
-
-    /**
-     * Enlist the target service in an existing user-defined conversation.
-     *
-     * @param callback a reference to a client that callbacks should be dispatched to
-     * @param sessionId an Object that uniquely identifies the conversation; must be Serializable
-     * @return a new conversation with the target service
-     */
-    Conversation joinSession(CallbackReference<CB> callback, Object sessionId);
 }

Added: incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/HelloCallback.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/HelloCallback.java?view=auto&rev=499432
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/HelloCallback.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/HelloCallback.java Wed Jan 24 07:11:17 2007
@@ -0,0 +1,8 @@
+package sample;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface HelloCallback {
+    String getLocale();
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/HelloCallback.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/HelloCallback.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/HelloService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/HelloService.java?view=auto&rev=499432
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/HelloService.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/HelloService.java Wed Jan 24 07:11:17 2007
@@ -0,0 +1,8 @@
+package sample;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface HelloService {
+    String hello(String message);
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/HelloService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/HelloService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/client/BasicClient.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/client/BasicClient.java?view=auto&rev=499432
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/client/BasicClient.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/client/BasicClient.java Wed Jan 24 07:11:17 2007
@@ -0,0 +1,26 @@
+package sample.client;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.ServiceReference;
+import sample.HelloService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BasicClient {
+    private CompositeContext context;
+
+    public void useComponentDirectly() {
+        HelloService helloService = context.locateService(HelloService.class, "helloService");
+        helloService.hello("World");
+    }
+
+    public void useComponentViaReference() {
+        ServiceReference<HelloService> ref = context.locateServiceReference(HelloService.class, "helloService");
+        HelloService helloService = ref.getTarget();
+        helloService.hello("World");
+
+        ServiceReference<HelloService> ref2 = context.cast(helloService);
+        assert ref == ref2;
+    }
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/client/BasicClient.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/client/BasicClient.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org