tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r571866 - in /incubator/tuscany/java/sca/modules: core-spi/src/main/java/org/apache/tuscany/sca/runtime/ core/src/main/java/org/apache/tuscany/sca/core/assembly/ host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/
Date Sat, 01 Sep 2007 20:20:39 GMT
Author: rfeng
Date: Sat Sep  1 13:20:37 2007
New Revision: 571866

URL: http://svn.apache.org/viewvc?rev=571866&view=rev
Log:
Refactor the getInvocationChain(Operation) to RuntimeWire

Modified:
    incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeAssemblyFactory.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeComponentImpl.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeComponentReferenceImpl.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeComponentServiceImpl.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java
    incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java

Modified: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java?rev=571866&r1=571865&r2=571866&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java
(original)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java
Sat Sep  1 13:20:37 2007
@@ -21,6 +21,7 @@
 
 import java.util.List;
 
+import org.apache.tuscany.sca.interfacedef.Operation;
 import org.apache.tuscany.sca.invocation.InvocationChain;
 
 /**
@@ -59,6 +60,13 @@
      *         wire
      */
     List<InvocationChain> getInvocationChains();
+    
+    /**
+     * Lookup the invocation chain by operation
+     * @param operation The operation
+     * @return The invocation chain for the given operation
+     */
+    InvocationChain getInvocationChain(Operation operation);
 
     /**
      * @return a clone of the runtime wire

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeAssemblyFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeAssemblyFactory.java?rev=571866&r1=571865&r2=571866&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeAssemblyFactory.java
(original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeAssemblyFactory.java
Sat Sep  1 13:20:37 2007
@@ -24,38 +24,30 @@
 import org.apache.tuscany.sca.assembly.ComponentReference;
 import org.apache.tuscany.sca.assembly.ComponentService;
 import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
-import org.apache.tuscany.sca.core.invocation.ProxyFactory;
-import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
 
 /**
+ * The runtime version of assembly factory
  * @version $Rev$ $Date$
  */
 public class RuntimeAssemblyFactory extends DefaultAssemblyFactory implements AssemblyFactory
{
-    private final ProxyFactory proxyFactory;
-    private final InterfaceContractMapper interfaceContractMapper;
-    
-    /**
-     * @param proxyFactory
-     */
-    public RuntimeAssemblyFactory(InterfaceContractMapper interfaceContractMapper, ProxyFactory
proxyFactory) {
+   
+    public RuntimeAssemblyFactory() {
         super();
-        this.proxyFactory = proxyFactory;
-        this.interfaceContractMapper = interfaceContractMapper;
     }
 
     @Override
     public Component createComponent() {
-        return new RuntimeComponentImpl(proxyFactory);
+        return new RuntimeComponentImpl();
     }
 
     @Override
     public ComponentReference createComponentReference() {
-        return new RuntimeComponentReferenceImpl(interfaceContractMapper);
+        return new RuntimeComponentReferenceImpl();
     }
 
     @Override
     public ComponentService createComponentService() {
-        return new RuntimeComponentServiceImpl(interfaceContractMapper);
+        return new RuntimeComponentServiceImpl();
     }
 
 }

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeComponentImpl.java?rev=571866&r1=571865&r2=571866&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeComponentImpl.java
(original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeComponentImpl.java
Sat Sep  1 13:20:37 2007
@@ -20,7 +20,6 @@
 package org.apache.tuscany.sca.core.assembly;
 
 import org.apache.tuscany.sca.assembly.impl.ComponentImpl;
-import org.apache.tuscany.sca.core.invocation.ProxyFactory;
 import org.apache.tuscany.sca.core.scope.ScopeContainer;
 import org.apache.tuscany.sca.core.scope.ScopedRuntimeComponent;
 import org.apache.tuscany.sca.provider.ImplementationProvider;
@@ -33,16 +32,13 @@
 public class RuntimeComponentImpl extends ComponentImpl implements RuntimeComponent, ScopedRuntimeComponent
{
     protected RuntimeComponentContext componentContext;
     protected ImplementationProvider implementationProvider;
-    protected ProxyFactory proxyService;
     protected ScopeContainer scopeContainer;
     protected boolean started;
 
     /**
-     * @param proxyService
      */
-    public RuntimeComponentImpl(ProxyFactory proxyService) {
+    public RuntimeComponentImpl() {
         super();
-        this.proxyService = proxyService;
     }
 
     public ImplementationProvider getImplementationProvider() {

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeComponentReferenceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeComponentReferenceImpl.java?rev=571866&r1=571865&r2=571866&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeComponentReferenceImpl.java
(original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeComponentReferenceImpl.java
Sat Sep  1 13:20:37 2007
@@ -26,7 +26,6 @@
 
 import org.apache.tuscany.sca.assembly.Binding;
 import org.apache.tuscany.sca.assembly.impl.ComponentReferenceImpl;
-import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
 import org.apache.tuscany.sca.interfacedef.Operation;
 import org.apache.tuscany.sca.invocation.InvocationChain;
 import org.apache.tuscany.sca.invocation.Invoker;
@@ -38,13 +37,11 @@
 public class RuntimeComponentReferenceImpl extends ComponentReferenceImpl implements RuntimeComponentReference
{
     private List<RuntimeWire> wires;
     private Map<Binding, ReferenceBindingProvider> bindingProviders = new HashMap<Binding,
ReferenceBindingProvider>();
-    private InterfaceContractMapper mapper;
 
     private RuntimeComponent component;
 
-    public RuntimeComponentReferenceImpl(InterfaceContractMapper mapper) {
+    public RuntimeComponentReferenceImpl() {
         super();
-        this.mapper = mapper;
     }
 
     public synchronized List<RuntimeWire> getRuntimeWires() {
@@ -77,13 +74,8 @@
         if (wire == null) {
             return null;
         }
-        for (InvocationChain chain : wire.getInvocationChains()) {
-            Operation op = chain.getSourceOperation();
-            if (mapper.isCompatible(operation, op, op.getInterface().isRemotable())) {
-                return chain.getHeadInvoker();
-            }
-        }
-        return null;
+        InvocationChain chain = wire.getInvocationChain(operation);
+        return chain == null ? null : chain.getHeadInvoker();
     }
 
     /**

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeComponentServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeComponentServiceImpl.java?rev=571866&r1=571865&r2=571866&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeComponentServiceImpl.java
(original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeComponentServiceImpl.java
Sat Sep  1 13:20:37 2007
@@ -27,7 +27,6 @@
 import org.apache.tuscany.sca.assembly.Binding;
 import org.apache.tuscany.sca.assembly.impl.ComponentServiceImpl;
 import org.apache.tuscany.sca.interfacedef.InterfaceContract;
-import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
 import org.apache.tuscany.sca.interfacedef.Operation;
 import org.apache.tuscany.sca.invocation.InvocationChain;
 import org.apache.tuscany.sca.invocation.Invoker;
@@ -37,14 +36,12 @@
 import org.osoa.sca.ServiceRuntimeException;
 
 public class RuntimeComponentServiceImpl extends ComponentServiceImpl implements RuntimeComponentService
{
-    private InterfaceContractMapper mapper;
     private List<RuntimeWire> wires = new ArrayList<RuntimeWire>();
     private List<RuntimeWire> callbackWires = new ArrayList<RuntimeWire>();
     private Map<Binding, ServiceBindingProvider> bindingProviders = new HashMap<Binding,
ServiceBindingProvider>();
 
-    public RuntimeComponentServiceImpl(InterfaceContractMapper mapper) {
+    public RuntimeComponentServiceImpl() {
         super();
-        this.mapper = mapper;
     }
 
     public List<RuntimeWire> getRuntimeWires() {
@@ -98,13 +95,7 @@
                 throw new ServiceRuntimeException(e);
             }
         }
-        for (InvocationChain chain : wire.getInvocationChains()) {
-            Operation op = chain.getTargetOperation();
-            if (mapper.isCompatible(operation, op, op.getInterface().isRemotable())) {
-                return chain;
-            }
-        }
-        return null;
+        return wire.getInvocationChain(operation);
     }
 
     public InvocationChain getInvocationChain(Binding binding, Operation operation) {

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java?rev=571866&r1=571865&r2=571866&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java
(original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java
Sat Sep  1 13:20:37 2007
@@ -85,6 +85,23 @@
         return chains;
     }
 
+    public InvocationChain getInvocationChain(Operation operation) {
+        for (InvocationChain chain : getInvocationChains()) {
+            Operation op = null;
+            if (wireSource.getContract() != null) {
+                // Reference chain
+                op = chain.getSourceOperation();
+            } else {
+                // Service chain
+                op = chain.getTargetOperation();
+            }
+            if (interfaceContractMapper.isCompatible(operation, op, op.getInterface().isRemotable()))
{
+                return chain;
+            }
+        }
+        return null;
+    }
+
     /**
      * Initialize the invocation chains
      */
@@ -128,7 +145,7 @@
     public EndpointReference getTarget() {
         return wireTarget;
     }
-    
+
     public void setTarget(EndpointReference target) {
         this.wireTarget = target;
         this.chains = null;
@@ -215,9 +232,9 @@
      */
     @Override
     public Object clone() throws CloneNotSupportedException {
-        RuntimeWireImpl copy =(RuntimeWireImpl) super.clone();
-        copy.wireSource = (EndpointReference) wireSource.clone();
-        copy.wireTarget = (EndpointReference) wireTarget.clone();
+        RuntimeWireImpl copy = (RuntimeWireImpl)super.clone();
+        copy.wireSource = (EndpointReference)wireSource.clone();
+        copy.wireTarget = (EndpointReference)wireTarget.clone();
         copy.chains = null;
         return copy;
     }

Modified: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java?rev=571866&r1=571865&r2=571866&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java
(original)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java
Sat Sep  1 13:20:37 2007
@@ -97,7 +97,7 @@
         proxyFactory = ReallySmallRuntimeBuilder.createProxyFactory(registry, mapper, messageFactory);
 
         // Create model factories
-        assemblyFactory = new RuntimeAssemblyFactory(mapper, proxyFactory);
+        assemblyFactory = new RuntimeAssemblyFactory();
         factories.addFactory(assemblyFactory);
         PolicyFactory policyFactory = new DefaultPolicyFactory();
         factories.addFactory(policyFactory);



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


Mime
View raw message