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 19:17:13 UTC

svn commit: r499507 - in /incubator/tuscany/sandbox/jboynes/sca-client/src: main/java/org/osoa/sca/ComponentContext.java main/java/org/osoa/sca/CompositeContext.java main/java/org/osoa/sca/ServiceReference.java test/java/sample/client/BasicClient.java

Author: jboynes
Date: Wed Jan 24 10:17:12 2007
New Revision: 499507

URL: http://svn.apache.org/viewvc?view=rev&rev=499507
Log:
add mechanism for components to dynamically access their references
separate internal component access and external reference access for unmanaged code acting as a composite

Modified:
    incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/ComponentContext.java
    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/ServiceReference.java
    incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/client/BasicClient.java

Modified: incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/ComponentContext.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/ComponentContext.java?view=diff&rev=499507&r1=499506&r2=499507
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/ComponentContext.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca-client/src/main/java/org/osoa/sca/ComponentContext.java Wed Jan 24 10:17:12 2007
@@ -20,4 +20,22 @@
      * @throws IllegalArgumentException if the supplied instance is not a reference supplied by the implementation
      */
     <B> ServiceReference<B> cast(B target) throws IllegalArgumentException;
+
+    /**
+     * Returns a proxy for a reference defined by this component.
+     *
+     * @param businessInterface the interface that will be used to invoke the service
+     * @param referenceName the name of the reference
+     * @return an object that implements the business interface
+     */
+    <B> B getService(Class<B> businessInterface, String referenceName);
+
+    /**
+     * Returns a ServiceReference for a reference defined by this component.
+     *
+     * @param businessInterface the interface that will be used to invoke the service
+     * @param referenceName the name of the reference
+     * @return a ServiceReference for the designated reference
+     */
+    <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String referenceName);
 }

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=499507&r1=499506&r2=499507
==============================================================================
--- 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 10:17:12 2007
@@ -27,8 +27,7 @@
  */
 public interface CompositeContext extends ComponentContext {
     /**
-     * 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.
+     * Returns a proxy reference to a service provided by a component within 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
@@ -37,11 +36,10 @@
     <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.
+     * Returns a ServiceReference to a service provided by a component within 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
+     * @param serviceName       the name of service provided by a component in this composite
      * @return a reference to the designated service
      */
     <B> ServiceReference<B> locateServiceReference(Class<B> businessInterface, String serviceName);

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=499507&r1=499506&r2=499507
==============================================================================
--- 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 10:17:12 2007
@@ -26,7 +26,7 @@
  */
 public interface ServiceReference<B> {
     /**
-     * Returns a type-safe Java proxy to the target of this reference.
+     * Returns a type-safe reference to the target of this reference.
      * The instance returned is guaranteed to implement the business interface for this reference
      * but may not be a proxy as defined by java.lang.reflect.Proxy.
      *

Modified: 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=diff&rev=499507&r1=499506&r2=499507
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/client/BasicClient.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca-client/src/test/java/sample/client/BasicClient.java Wed Jan 24 10:17:12 2007
@@ -23,4 +23,18 @@
         ServiceReference<HelloService> ref2 = context.cast(helloService);
         assert ref == ref2;
     }
+
+    public void useReferenceDirectly() {
+        HelloService helloService = context.locateService(HelloService.class, "helloReference");
+        helloService.hello("World");
+    }
+
+    public void useReferenceViaReference() {
+        ServiceReference<HelloService> ref = context.locateServiceReference(HelloService.class, "helloReference");
+        HelloService helloService = ref.getTarget();
+        helloService.hello("World");
+
+        ServiceReference<HelloService> ref2 = context.cast(helloService);
+        assert ref == ref2;
+    }
 }



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