summaryrefslogtreecommitdiffstats
path: root/java/sca
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-10-22 22:40:19 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-10-22 22:40:19 +0000
commit0491f669ce7f70b5b45476d311bdfe018d6bea24 (patch)
tree31fd752cb61a6aa6abf74f462ca0cfd6b53efe74 /java/sca
parent5e9776cf291d66d2e4789d90957098d3f3fa2386 (diff)
Start to add InvocationChain for bindings
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@707218 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca')
-rw-r--r--java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/TestMessageProcessor.java4
-rw-r--r--java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeWire.java4
-rw-r--r--java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Phase.java10
-rw-r--r--java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java6
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java13
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java13
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/PhaseManager.java61
-rw-r--r--java/sca/modules/core/src/test/resources/META-INF/services/org.apache.tuscany.sca.invocation.PhaseTest4
8 files changed, 106 insertions, 9 deletions
diff --git a/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/TestMessageProcessor.java b/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/TestMessageProcessor.java
index cfe7a649d9..80368a0fb6 100644
--- a/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/TestMessageProcessor.java
+++ b/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/TestMessageProcessor.java
@@ -22,7 +22,7 @@ package org.apache.tuscany.sca.binding.jms;
import javax.jms.Message;
import javax.jms.Session;
-import org.apache.tuscany.sca.binding.jms.impl.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.impl.JMSBindingImpl;
import org.apache.tuscany.sca.binding.jms.provider.XMLTextMessageProcessor;
public class TestMessageProcessor extends XMLTextMessageProcessor {
@@ -31,7 +31,7 @@ public class TestMessageProcessor extends XMLTextMessageProcessor {
public static boolean extractPayloadFromJMSMessageCalled;
public static boolean setOperationNameCalled;
- public TestMessageProcessor(JMSBinding jmsBinding) {
+ public TestMessageProcessor(JMSBindingImpl jmsBinding) {
super(jmsBinding);
}
public Object extractPayloadFromJMSMessage(Message message) {
diff --git a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeWire.java b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeWire.java
index 696705aa74..966f6dc8f5 100644
--- a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeWire.java
+++ b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeWire.java
@@ -33,7 +33,6 @@ import org.apache.tuscany.sca.runtime.RuntimeWire;
* Mock RuntimeWire implementation. Only few methods needs to be implemented.
*/
public class TestRuntimeWire implements RuntimeWire {
-
private Object invocationTarget;
public TestRuntimeWire(Object invocationTarget) {
@@ -97,4 +96,7 @@ public class TestRuntimeWire implements RuntimeWire {
return null;
}
+ public InvocationChain getBindingInvocationChain() {
+ return null;
+ }
}
diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Phase.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Phase.java
index 2deb273f84..b4d3ec4962 100644
--- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Phase.java
+++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Phase.java
@@ -37,6 +37,16 @@ public interface Phase {
// reference binding invoker
String REFERENCE_BINDING = "reference.binding";
+ String REFERENCE_BINDING_DISPATCHER = "reference.binding.dispatcher";
+ String REFERENCE_BINDING_WIREFORMAT = "reference.binding.wireformat";
+ String REFERENCE_BINDING_POLICY = "reference.binding.policy";
+ String REFERENCE_BINDING_TRANSPORT = "reference.binding.transport";
+
+ String SERVICE_BINDING_TRANSPORT = "service.binding.transport";
+ String SERVICE_BINDING_WIREFORMAT = "service.binding.wireformat";
+ String SERVICE_BINDING_POLICY = "service.binding.policy";
+ String SERVICE_BINDING_OPERATION_SELECTOR = "service.binding.operationselector";
+
// The first phase for incoming invocations via a service
String SERVICE_BINDING = "service.binding";
diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java
index da37385af1..609e2aa89b 100644
--- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java
+++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java
@@ -76,6 +76,12 @@ public interface RuntimeWire extends Cloneable {
InvocationChain getInvocationChain(Operation operation);
/**
+ * Get the invocation chain for the binding-specific handling
+ * @return
+ */
+ InvocationChain getBindingInvocationChain();
+
+ /**
* Invoke an operation with given arguments
* @param operation The operation
* @param args The arguments
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java
index c25c580fe6..beb86fefe1 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java
@@ -24,6 +24,7 @@ import java.util.List;
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.core.invocation.InvocationChainImpl;
import org.apache.tuscany.sca.endpointresolver.EndpointResolver;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.Operation;
@@ -47,6 +48,7 @@ public class EndpointWireImpl implements RuntimeWire {
private EndpointResolver endpointResolver;
private EndpointReference source;
private RuntimeWire wire;
+ private InvocationChain binidngInvocationChain;
/**
* @param endpoint
@@ -150,6 +152,17 @@ public class EndpointWireImpl implements RuntimeWire {
public void rebuild() {
}
+
+ public synchronized InvocationChain getBindingInvocationChain() {
+ if (binidngInvocationChain == null) {
+ if (source instanceof RuntimeComponentReference) {
+ binidngInvocationChain = new InvocationChainImpl(null, null, true);
+ } else {
+ binidngInvocationChain = new InvocationChainImpl(null, null, false);
+ }
+ }
+ return binidngInvocationChain;
+ }
// TODO: TUSCANY-2580: give RuntimeComponentReferenceImpl a way to get at the endpoint
public Endpoint getEndpoint() {
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java
index 2c8cc49d47..991aa57abe 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java
@@ -76,6 +76,7 @@ public class RuntimeWireImpl implements RuntimeWire {
private RuntimeWireImpl clonedFrom;
private List<InvocationChain> chains;
+ private InvocationChain binidngInvocationChain;
/**
* @param source
@@ -110,6 +111,18 @@ public class RuntimeWireImpl implements RuntimeWire {
}
return chains;
}
+
+ public synchronized InvocationChain getBindingInvocationChain() {
+ if (binidngInvocationChain == null) {
+ Contract source = wireSource.getContract();
+ if (source instanceof RuntimeComponentReference) {
+ binidngInvocationChain = new InvocationChainImpl(null, null, true);
+ } else {
+ binidngInvocationChain = new InvocationChainImpl(null, null, false);
+ }
+ }
+ return binidngInvocationChain;
+ }
public InvocationChain getInvocationChain(Operation operation) {
for (InvocationChain chain : getInvocationChains()) {
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/PhaseManager.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/PhaseManager.java
index 94d67bffcc..aff89100ca 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/PhaseManager.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/PhaseManager.java
@@ -19,6 +19,25 @@
package org.apache.tuscany.sca.core.invocation;
+import static org.apache.tuscany.sca.invocation.Phase.IMPLEMENTATION;
+import static org.apache.tuscany.sca.invocation.Phase.IMPLEMENTATION_POLICY;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_BINDING;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_BINDING_DISPATCHER;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_BINDING_POLICY;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_BINDING_TRANSPORT;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_BINDING_WIREFORMAT;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_INTERFACE;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_POLICY;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_BINDING;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_BINDING_OPERATION_SELECTOR;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_BINDING_POLICY;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_BINDING_TRANSPORT;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_BINDING_WIREFORMAT;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_INTERFACE;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_POLICY;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -42,15 +61,24 @@ public class PhaseManager {
private static final Logger log = Logger.getLogger(PhaseManager.class.getName());
public static final String STAGE_REFERENCE = "reference";
+ public static final String STAGE_REFERENCE_BINDING = "reference.binding";
+ public static final String STAGE_SERVICE_BINDING = "service.binding";
public static final String STAGE_SERVICE = "service";
public static final String STAGE_IMPLEMENTATION = "implementation";
+
private static final String[] SYSTEM_REFERENCE_PHASES =
- {Phase.REFERENCE, Phase.REFERENCE_INTERFACE, Phase.REFERENCE_POLICY, Phase.REFERENCE_BINDING};
+ {REFERENCE, REFERENCE_INTERFACE, REFERENCE_POLICY, REFERENCE_BINDING};
+ private static final String[] SYSTEM_REFERENCE_BINDING_PHASES =
+ {REFERENCE_BINDING_DISPATCHER, REFERENCE_BINDING_WIREFORMAT, REFERENCE_BINDING_POLICY, REFERENCE_BINDING_TRANSPORT};
+
+ private static final String[] SYSTEM_SERVICE_BINDING_PHASES =
+ {SERVICE_BINDING_TRANSPORT, SERVICE_BINDING_WIREFORMAT, SERVICE_BINDING_POLICY, SERVICE_BINDING_OPERATION_SELECTOR};
+
private static final String[] SYSTEM_SERVICE_PHASES =
- {Phase.SERVICE_BINDING, Phase.SERVICE_POLICY, Phase.SERVICE_INTERFACE, Phase.SERVICE};
+ {SERVICE_BINDING, SERVICE_POLICY, SERVICE_INTERFACE, SERVICE};
- private static final String[] SYSTEM_IMPLEMENTATION_PHASES = {Phase.IMPLEMENTATION_POLICY, Phase.IMPLEMENTATION};
+ private static final String[] SYSTEM_IMPLEMENTATION_PHASES = {IMPLEMENTATION_POLICY, IMPLEMENTATION};
private String pattern = Phase.class.getName();
private Map<String, Stage> stages;
@@ -116,6 +144,14 @@ public class PhaseManager {
return getPhases(STAGE_SERVICE);
}
+ public List<String> getReferenceBindingPhases() {
+ return getPhases(STAGE_REFERENCE_BINDING);
+ }
+
+ public List<String> getServiceBindingPhases() {
+ return getPhases(STAGE_SERVICE_BINDING);
+ }
+
public List<String> getImplementationPhases() {
return getPhases(STAGE_IMPLEMENTATION);
}
@@ -124,6 +160,8 @@ public class PhaseManager {
if (phases == null) {
phases = new ArrayList<String>();
phases.addAll(getReferencePhases());
+ phases.addAll(getReferenceBindingPhases());
+ phases.addAll(getServiceBindingPhases());
phases.addAll(getServicePhases());
phases.addAll(getImplementationPhases());
}
@@ -228,9 +266,22 @@ public class PhaseManager {
for (int i = 1; i < SYSTEM_REFERENCE_PHASES.length; i++) {
referenceStage.getSorter().addEdge(SYSTEM_REFERENCE_PHASES[i - 1], SYSTEM_REFERENCE_PHASES[i]);
}
- referenceStage.getLastSet().add(Phase.REFERENCE_BINDING);
+ referenceStage.getLastSet().add(REFERENCE_BINDING);
stages.put(referenceStage.getName(), referenceStage);
+ Stage referenceBindingStage = new Stage(STAGE_REFERENCE_BINDING);
+ for (int i = 1; i < SYSTEM_REFERENCE_BINDING_PHASES.length; i++) {
+ referenceBindingStage.getSorter().addEdge(SYSTEM_REFERENCE_BINDING_PHASES[i - 1], SYSTEM_REFERENCE_BINDING_PHASES[i]);
+ }
+ stages.put(referenceBindingStage.getName(), referenceBindingStage);
+
+ Stage serviceBindingStage = new Stage(STAGE_SERVICE_BINDING);
+ for (int i = 1; i < SYSTEM_SERVICE_BINDING_PHASES.length; i++) {
+ serviceBindingStage.getSorter().addEdge(SYSTEM_SERVICE_BINDING_PHASES[i - 1], SYSTEM_SERVICE_BINDING_PHASES[i]);
+ }
+ stages.put(serviceBindingStage.getName(), serviceBindingStage);
+
+
Stage serviceStage = new Stage(STAGE_SERVICE);
for (int i = 1; i < SYSTEM_SERVICE_PHASES.length; i++) {
serviceStage.getSorter().addEdge(SYSTEM_SERVICE_PHASES[i - 1], SYSTEM_SERVICE_PHASES[i]);
@@ -242,7 +293,7 @@ public class PhaseManager {
implementationStage.getSorter().addEdge(SYSTEM_IMPLEMENTATION_PHASES[i - 1],
SYSTEM_IMPLEMENTATION_PHASES[i]);
}
- implementationStage.getLastSet().add(Phase.IMPLEMENTATION);
+ implementationStage.getLastSet().add(IMPLEMENTATION);
stages.put(implementationStage.getName(), implementationStage);
}
}
diff --git a/java/sca/modules/core/src/test/resources/META-INF/services/org.apache.tuscany.sca.invocation.PhaseTest b/java/sca/modules/core/src/test/resources/META-INF/services/org.apache.tuscany.sca.invocation.PhaseTest
index 9ed0928a33..ad23df3761 100644
--- a/java/sca/modules/core/src/test/resources/META-INF/services/org.apache.tuscany.sca.invocation.PhaseTest
+++ b/java/sca/modules/core/src/test/resources/META-INF/services/org.apache.tuscany.sca.invocation.PhaseTest
@@ -18,5 +18,7 @@
name=implementation.last, stage=implementation, after=*
name=reference.first, stage=reference, before=*
name=reference.transaction, stage=reference, after=reference.interface
+name=reference.binding.header, stage=reference.binding, after=reference.binding.transport
+name=service.binding.header, stage=service.binding, after=service.binding.transport
name=service.transaction, stage=service, after=service.binding, before=component.service
-name=implementation.transaction, stage=implementation, before=implementation.policy \ No newline at end of file
+name=implementation.transaction, stage=implementation, before=implementation.policy