You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jm...@apache.org on 2006/03/04 00:09:58 UTC

svn commit: r382957 - in /incubator/tuscany/java/sca: binding.axis/src/main/java/org/apache/tuscany/binding/axis/engine/config/ binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/ container.java/src/test/java/org/apache/tuscany/contai...

Author: jmarino
Date: Fri Mar  3 15:09:57 2006
New Revision: 382957

URL: http://svn.apache.org/viewcvs?rev=382957&view=rev
Log:
change EntryPointContext.getInstance() to return proxy; to return the InvocationHandler, use EntryPointcontext.getImplementationInstance()

Modified:
    incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/engine/config/AxisEngineConfigurationFactory.java
    incubator/tuscany/java/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceEntryPointInOutSyncMessageReceiver.java
    incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/EntryPointToJavaTestCase.java
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/EntryPointContext.java
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/EntryPointContextImpl.java

Modified: incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/engine/config/AxisEngineConfigurationFactory.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/engine/config/AxisEngineConfigurationFactory.java?rev=382957&r1=382956&r2=382957&view=diff
==============================================================================
--- incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/engine/config/AxisEngineConfigurationFactory.java (original)
+++ incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/engine/config/AxisEngineConfigurationFactory.java Fri Mar  3 15:09:57 2006
@@ -137,7 +137,7 @@
                 EntryPoint entryPoint = (EntryPoint) i.next();
                 Binding binding = (Binding) entryPoint.getBindings().get(0);
                 if (binding instanceof WebServiceBinding) {
-                    
+                    //FIXME This should not use the proxy factory - use EntryPointContext#getInstance()
                     // Get the proxy factory associated with the entry point 
                     final ProxyFactory proxyFactory=(ProxyFactory)entryPoint.getConfiguredService().getProxyFactory();
                     

Modified: incubator/tuscany/java/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceEntryPointInOutSyncMessageReceiver.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceEntryPointInOutSyncMessageReceiver.java?rev=382957&r1=382956&r2=382957&view=diff
==============================================================================
--- incubator/tuscany/java/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceEntryPointInOutSyncMessageReceiver.java (original)
+++ incubator/tuscany/java/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceEntryPointInOutSyncMessageReceiver.java Fri Mar  3 15:09:57 2006
@@ -117,7 +117,7 @@
             Method operationMethod= clazz.getMethod(axisOperationName, argsClazz);
             
              
-            InvocationHandler handler = (InvocationHandler) entryPointContext.getInstance(null);
+            InvocationHandler handler = (InvocationHandler) entryPointContext.getImplementationInstance();
            
          
             Object response = handler.invoke(null, operationMethod,  args);

Modified: incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/EntryPointToJavaTestCase.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/EntryPointToJavaTestCase.java?rev=382957&r1=382956&r2=382957&view=diff
==============================================================================
--- incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/EntryPointToJavaTestCase.java (original)
+++ incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/EntryPointToJavaTestCase.java Fri Mar  3 15:09:57 2006
@@ -60,7 +60,7 @@
         child.fireEvent(EventContext.REQUEST_START, null);
         EntryPointContext ctx = (EntryPointContext) child.getContext("source");
         Assert.assertNotNull(ctx);
-        InvocationHandler handler = (InvocationHandler) ctx.getInstance(null);
+        InvocationHandler handler = (InvocationHandler) ctx.getImplementationInstance();
         Assert.assertEquals(0, mockInterceptor.getCount());
         Object response = handler.invoke(null, hello, new Object[] { "foo" });
         Assert.assertEquals("Hello foo", response);
@@ -71,7 +71,7 @@
         child.fireEvent(EventContext.REQUEST_START, null);
         ctx = (EntryPointContext) child.getContext("source");
         Assert.assertNotNull(ctx);
-        handler = (InvocationHandler) ctx.getInstance(null);
+        handler = (InvocationHandler) ctx.getImplementationInstance();
         Assert.assertEquals(1, mockInterceptor.getCount());
         response = handler.invoke(null, hello, new Object[] { "foo" });
         Assert.assertEquals("Hello foo", response);
@@ -106,7 +106,7 @@
         
         EntryPointContext ctx = (EntryPointContext) child.getContext("source");
         Assert.assertNotNull(ctx);
-        InvocationHandler handler = (InvocationHandler) ctx.getInstance(null);
+        InvocationHandler handler = (InvocationHandler) ctx.getImplementationInstance();
         Assert.assertEquals(0, mockInterceptor.getCount());
         Object response = handler.invoke(null, hello, new Object[] { "foo" });
         Assert.assertEquals("Hello foo", response);
@@ -175,7 +175,7 @@
         child.fireEvent(EventContext.REQUEST_START, null);
         EntryPointContext ctx = (EntryPointContext) child.getContext("source");
         Assert.assertNotNull(ctx);
-        InvocationHandler handler = (InvocationHandler) ctx.getInstance(null);
+        InvocationHandler handler = (InvocationHandler) ctx.getImplementationInstance();
         Assert.assertEquals(0, mockInterceptor.getCount());
         Object response = handler.invoke(null, hello, new Object[] { "foo" });
         Assert.assertEquals("Hello foo", response);
@@ -186,7 +186,7 @@
         child.fireEvent(EventContext.REQUEST_START, null);
         ctx = (EntryPointContext) child.getContext("source");
         Assert.assertNotNull(ctx);
-        handler = (InvocationHandler) ctx.getInstance(null);
+        handler = (InvocationHandler) ctx.getImplementationInstance();
         Assert.assertEquals(1, mockInterceptor.getCount());
         response = handler.invoke(null, hello, new Object[] { "foo" });
         Assert.assertEquals("Hello foo", response);
@@ -213,7 +213,7 @@
         child.fireEvent(EventContext.REQUEST_START, null);
         EntryPointContext ctx = (EntryPointContext) child.getContext("source");
         Assert.assertNotNull(ctx);
-        InvocationHandler handler = (InvocationHandler) ctx.getInstance(null);
+        InvocationHandler handler = (InvocationHandler) ctx.getImplementationInstance();
         Assert.assertEquals(0, mockInterceptor.getCount());
         Object response = handler.invoke(null, hello, new Object[] { "foo" });
         Assert.assertEquals("Hello foo", response);
@@ -221,7 +221,7 @@
 
         ctx = (EntryPointContext) child.getContext("source");
         Assert.assertNotNull(ctx);
-        handler = (InvocationHandler) ctx.getInstance(null);
+        handler = (InvocationHandler) ctx.getImplementationInstance();
         response = handler.invoke(null, hello, new Object[] { "foo" });
         HelloWorldService service1 = (HelloWorldService)child.getContext("target").getInstance(null);
         Assert.assertEquals(2, service1.count());
@@ -232,7 +232,7 @@
         child.fireEvent(EventContext.REQUEST_START, null);
         ctx = (EntryPointContext) child.getContext("source");
         Assert.assertNotNull(ctx);
-        handler = (InvocationHandler) ctx.getInstance(null);
+        handler = (InvocationHandler) ctx.getImplementationInstance();
         Assert.assertEquals(2, mockInterceptor.getCount());
         response = handler.invoke(null, hello, new Object[] { "foo" });
         Assert.assertEquals("Hello foo", response);

Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/EntryPointContext.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/EntryPointContext.java?rev=382957&r1=382956&r2=382957&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/EntryPointContext.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/EntryPointContext.java Fri Mar  3 15:09:57 2006
@@ -29,15 +29,26 @@
  * to perform the invocation as in:
  * 
  * <pre>
- *             AggregateContext aggregateContext = ...
- *             EntryPointContext ctx = (EntryPointContext) aggregateContext.getContext(&quot;source&quot;);
- *             Assert.assertNotNull(ctx);
- *             InvocationHandler handler = (InvocationHandler) ctx.getInstance(null);
- *             Object response = handler.invoke(null, operation, new Object[] { param });
+ *              AggregateContext aggregateContext = ...
+ *              EntryPointContext ctx = (EntryPointContext) aggregateContext.getContext(&quot;source&quot;);
+ *              Assert.assertNotNull(ctx);
+ *              InvocationHandler handler = (InvocationHandler) ctx.getImplementationInstance();
+ *              Object response = handler.invoke(null, operation, new Object[] { param });
  * </pre>
  * 
  * The <code>Proxy</code> instance passed to <code>InvocationHandler</code> may be null as the client is invoking
  * directly on the handler.
+ * <p>
+ * Alternatively, the following will return a proxy implementing the service interface exposed by the entry point:
+ * 
+ * <pre>
+ *              AggregateContext aggregateContext = ...
+ *              EntryPointContext ctx = (EntryPointContext) aggregateContext.getContext(&quot;source&quot;);
+ *              Assert.assertNotNull(ctx);
+ *              HelloWorld proxy = (Helloworld) ctx.getInstance(null); // service name not necessary
+ * </pre>
+ * 
+ * The proxy returned will be backed by the entry point invocation chain.
  * 
  * @version $Rev$ $Date$
  */

Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/EntryPointContextImpl.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/EntryPointContextImpl.java?rev=382957&r1=382956&r2=382957&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/EntryPointContextImpl.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/EntryPointContextImpl.java Fri Mar  3 15:09:57 2006
@@ -22,6 +22,7 @@
 import org.apache.tuscany.core.context.QualifiedName;
 import org.apache.tuscany.core.context.TargetException;
 import org.apache.tuscany.core.invocation.jdk.JDKInvocationHandler;
+import org.apache.tuscany.core.invocation.spi.ProxyCreationException;
 import org.apache.tuscany.core.invocation.spi.ProxyFactory;
 import org.apache.tuscany.core.message.MessageFactory;
 
@@ -40,6 +41,9 @@
 
     private InvocationHandler invocationHandler;
 
+    // a proxy implementing the service exposed by the entry point backed by the invocation handler
+    private Object proxy;
+
     // ----------------------------------
     // Constructors
     // ----------------------------------
@@ -69,7 +73,16 @@
     // ----------------------------------
 
     public Object getInstance(QualifiedName qName) throws TargetException {
-        return invocationHandler;
+        if (proxy == null) {
+            try {
+                proxy = proxyFactory.createProxy();
+            } catch (ProxyCreationException e) {
+                TargetException te = new TargetException(e);
+                te.addContextName(getName());
+                throw te;
+            }
+        }
+        return proxy;
     }
 
     public Object getInstance(QualifiedName qName, boolean notify) throws TargetException {