summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/core
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-03-19 16:12:22 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-03-19 16:12:22 +0000
commitdcbff0df93448ef786c2e5cb0320f3895759171b (patch)
tree444d508a0e30ac3c8b00ff394cf46fc64b9f4aab /java/sca/modules/core
parent40f139f0e78679d6e9ce837de910f603f819b917 (diff)
Switch over to new endpoint reference/endpoint model. These are the changes required to exploit the model in the runtime up to the point were the old EndpointReference is retrieved from a wire. The next step is to convert this over too and exploit the new endpoint references fully. There is still tidying to do (search for TODO - EPR) in particular I haven't removed any of the old files yet. So beware don't put changes into CompositeActivator or RuntimeWire as the runtime isn't using them
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@756070 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/core')
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl2.java21
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointWireImpl.java5
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentReferenceImpl.java17
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java5
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl2.java29
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallableReferenceImpl.java25
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java37
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/CallbackReferenceImpl.java53
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java5
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java4
-rw-r--r--java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.assembly.CompositeActivator2
11 files changed, 162 insertions, 41 deletions
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl2.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl2.java
index b84717467f..8efee3a0ec 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl2.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl2.java
@@ -289,9 +289,14 @@ public class CompositeActivatorImpl2 implements CompositeActivator {
}
return;
}
+
+ /* TODO - EPR - activate services at all levels as promoted endpoin references are maintained
+ * on the higher level services
if (service.getService() instanceof CompositeService) {
return;
}
+ */
+
if (logger.isLoggable(Level.FINE)) {
logger.fine("Activating component service: " + component.getURI() + "#" + service.getName());
}
@@ -367,6 +372,7 @@ public class CompositeActivatorImpl2 implements CompositeActivator {
// so we need to represent the reference that will call us
EndpointReference2 endpointReference = assemblyFactory.createEndpointReference();
endpointReference.setBinding(endpoint.getBinding());
+ endpointReference.setTargetEndpoint(endpoint);
// create the interface contract for the binding and service ends of the wire
// that are created as forward only contracts
@@ -496,7 +502,7 @@ public class CompositeActivatorImpl2 implements CompositeActivator {
return;
}
- // TODO - what is this all about?
+ // TODO - EPR what is this all about?
// [rfeng] Comment out the following statements to avoid the on-demand activation
// RuntimeComponentReference runtimeRef = (RuntimeComponentReference)reference;
// runtimeRef.getRuntimeWires().clear();
@@ -539,7 +545,7 @@ public class CompositeActivatorImpl2 implements CompositeActivator {
configureComponentContext(runtimeComponent);
-/* TODO - won't start until reference is actually started later
+/* TODO - EPR won't start until reference is actually started later
for (ComponentReference reference : component.getReferences()) {
if (logger.isLoggable(Level.FINE)) {
logger.fine("Starting component reference: " + component.getURI() + "#" + reference.getName());
@@ -679,11 +685,11 @@ public class CompositeActivatorImpl2 implements CompositeActivator {
// Service start/stop
- // TODO - done as part of the component start above
+ // TODO - EPR done as part of the component start above
// Reference start/stop
// Used by component context start
- // TODO - I don't know why reference wires don't get added until component start
+ // TODO - EPR I don't know why reference wires don't get added until component start
public void start(RuntimeComponent component, RuntimeComponentReference componentReference) {
synchronized (componentReference) {
@@ -692,13 +698,12 @@ public class CompositeActivatorImpl2 implements CompositeActivator {
return;
}
- // create wire for all endpoint references. An endpoint reference says that a
+ // create a wire for each endpoint reference. An endpoint reference says that a
// target has been specified and hence the reference has been wired in some way.
// The service may not have been found yet, depending on the way the composite
// is deployed, but it is expected to be found. In the case where the reference
// is unwired (a target has not been specified) there will be no endpoint
// reference and this will lead to null being injected
-
for (EndpointReference2 endpointReference : componentReference.getEndpointReferences()){
// if there is a binding an endpoint has been found for the endpoint reference
@@ -762,7 +767,7 @@ public class CompositeActivatorImpl2 implements CompositeActivator {
endpointReference.setInterfaceContract(sourceContract.makeUnidirectional(false));
-/* TODO - should have been done previously during matching
+/* TODO - EPR should have been done previously during matching
ComponentService callbackService = reference.getCallbackService();
if (callbackService != null) {
// select a reference callback binding to pass with invocations on this wire
@@ -790,7 +795,7 @@ public class CompositeActivatorImpl2 implements CompositeActivator {
Endpoint2 endpoint = endpointReference.getTargetEndpoint();
endpoint.setInterfaceContract(bindingContract);
-/* TODO - review in the light of new matching code
+/* TODO - EPR review in the light of new matching code
// TUSCANY-2029 - We should use the URI of the serviceBinding because the target may be a Component in a
// nested composite.
if (serviceBinding != null) {
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointWireImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointWireImpl.java
index b089abba4f..1e11c7062e 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointWireImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointWireImpl.java
@@ -23,6 +23,7 @@ import java.lang.reflect.InvocationTargetException;
import java.util.List;
import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference2;
import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.core.assembly.CompositeActivator;
import org.apache.tuscany.sca.core.invocation.impl.InvocationChainImpl;
@@ -183,4 +184,8 @@ public class EndpointWireImpl implements RuntimeWire {
EndpointWireImpl copy = (EndpointWireImpl)super.clone();
return copy;
}
+
+ public EndpointReference2 getEndpointReference(){
+ return null;
+ }
}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentReferenceImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentReferenceImpl.java
index eda274bd29..994094ab23 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentReferenceImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentReferenceImpl.java
@@ -25,6 +25,7 @@ import java.util.List;
import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference2;
import org.apache.tuscany.sca.assembly.impl.ComponentReferenceImpl;
import org.apache.tuscany.sca.endpointresolver.EndpointResolver;
import org.apache.tuscany.sca.interfacedef.Operation;
@@ -63,6 +64,7 @@ public class RuntimeComponentReferenceImpl extends ComponentReferenceImpl implem
return wires;
}
+ // TODO - EPR - shouldn't rely on this anymore
public RuntimeWire getRuntimeWire(Binding binding) {
for (RuntimeWire wire : getRuntimeWires()) {
if (wire.getSource().getBinding() == binding) {
@@ -70,17 +72,16 @@ public class RuntimeComponentReferenceImpl extends ComponentReferenceImpl implem
}
}
- // TODO: TUSCANY-2580: before returning null see if a candidate binding matches
+ return null;
+ }
+
+ public RuntimeWire getRuntimeWire(EndpointReference2 endpointReference) {
for (RuntimeWire wire : getRuntimeWires()) {
- if (wire instanceof EndpointWireImpl) {
- Endpoint endpoint = ((EndpointWireImpl)wire).getEndpoint();
- for (Binding b : endpoint.getCandidateBindings()) {
- if (b == binding) {
- return wire;
- }
- }
+ if (wire.getEndpointReference() == endpointReference) {
+ return wire;
}
}
+
return null;
}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java
index 62c2791060..a9ff97d770 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java
@@ -28,6 +28,7 @@ import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentReference;
import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.EndpointReference2;
import org.apache.tuscany.sca.core.conversation.ConversationManager;
import org.apache.tuscany.sca.core.invocation.NonBlockingInterceptor;
import org.apache.tuscany.sca.core.invocation.RuntimeWireInvoker;
@@ -458,4 +459,8 @@ public class RuntimeWireImpl implements RuntimeWire {
private void setClonedFrom(RuntimeWireImpl wire) {
clonedFrom = wire;
}
+
+ public EndpointReference2 getEndpointReference(){
+ return null;
+ }
}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl2.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl2.java
index a9150a8dc7..945045ed32 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl2.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl2.java
@@ -275,16 +275,32 @@ public class RuntimeWireImpl2 implements RuntimeWire {
}
+ // ===============================================================
+ // TODO - EPR remove when we convert fully over to EndpointReference2
+
// TODO - remove. Just here during development
static EndpointReference epr;
public EndpointReference getSource() {
- // TODO - convert this into method that returns EndpointReference2
+ // TODO - EPR convert this into method that returns EndpointReference2
+
+ // convert the source info into old endpoint reference format
epr = new EndpointReferenceImpl((RuntimeComponent)endpointReference.getComponent(),
endpointReference.getReference(),
endpointReference.getBinding(),
endpointReference.getInterfaceContract());
+ if (endpointReference.getCallbackEndpoint() != null){
+ // convert the source callback endpoint into old endpoint reference format
+ EndpointReference cepr;
+ cepr = new EndpointReferenceImpl((RuntimeComponent)endpointReference.getComponent(),
+ endpointReference.getCallbackEndpoint().getService(),
+ endpointReference.getCallbackEndpoint().getBinding(),
+ endpointReference.getCallbackEndpoint().getInterfaceContract());
+ epr.setCallbackEndpoint(cepr);
+ }
+
+
// TODO - somtimes used to reset the interface contract so we
// copy it back in in the rebuild method below
return epr;
@@ -293,8 +309,9 @@ public class RuntimeWireImpl2 implements RuntimeWire {
public EndpointReference getTarget() {
- // TODO - convert this into method that return Endpoint2
+ // TODO - EPR convert this into method that returns Endpoint2
+ // convert the target info into old endpoint reference format
EndpointReference epr = new EndpointReferenceImpl((RuntimeComponent)endpoint.getComponent(),
endpoint.getService(),
endpoint.getBinding(),
@@ -306,6 +323,8 @@ public class RuntimeWireImpl2 implements RuntimeWire {
// TODO - can we use the idea of setTarget to rebuild the wire?
}
+
+ // ===================================================================
public void rebuild() {
// TODO - can we use the idea of setTarget to rebuild the wire?
@@ -317,6 +336,10 @@ public class RuntimeWireImpl2 implements RuntimeWire {
// to call this when it resets the interface contract
endpointReference.setInterfaceContract(epr.getInterfaceContract());
}
+
+ public EndpointReference2 getEndpointReference(){
+ return endpointReference;
+ }
/**
* Add the interceptor for a reference binding
@@ -440,7 +463,7 @@ public class RuntimeWireImpl2 implements RuntimeWire {
public Object clone() throws CloneNotSupportedException {
RuntimeWireImpl2 copy = (RuntimeWireImpl2)super.clone();
copy.endpointReference = (EndpointReference2)endpointReference.clone();
- copy.endpoint = (Endpoint2)endpoint.clone();
+ copy.endpoint = copy.endpointReference.getTargetEndpoint();
copy.invoker = new RuntimeWireInvoker(copy.messageFactory, copy.conversationManager, copy);
copy.cachedWire = null; // TUSCANY-2630
return copy;
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallableReferenceImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallableReferenceImpl.java
index c2264302b4..9e5bf6b1ff 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallableReferenceImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallableReferenceImpl.java
@@ -31,6 +31,7 @@ import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.EndpointReference2;
import org.apache.tuscany.sca.assembly.OptimizableBinding;
import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.SCABinding;
@@ -81,7 +82,10 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> {
protected transient RuntimeComponent component;
protected transient RuntimeComponentReference reference;
+ // TODO - EPR - remove wire indexing on bindings as enpoint references
+ // can share reference bindings
protected transient Binding binding;
+ protected transient EndpointReference2 endpointReference;
protected String scdl;
@@ -89,8 +93,6 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> {
private transient ReferenceParameters refParams;
private transient XMLStreamReader xmlReader;
- private transient RuntimeWire endpointWire;
-
/*
* Public constructor for Externalizable serialization/deserialization
*/
@@ -133,6 +135,16 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> {
}
}
}
+
+ // TODO - EPR - If not binding specified assume default binding and find the enpoint reference
+ // related to it
+ for (EndpointReference2 endpointReference : this.reference.getEndpointReferences()){
+ if ((endpointReference.getBinding() != null) &&
+ (endpointReference.getBinding() instanceof SCABinding)){
+ this.endpointReference = endpointReference;
+ break;
+ }
+ }
}
// FIXME: Should we normalize the componentName/serviceName URI into an absolute SCA URI in the SCA binding?
@@ -151,8 +163,8 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> {
public RuntimeWire getRuntimeWire() {
try {
resolve();
- if (endpointWire != null) {
- return endpointWire;
+ if (endpointReference != null){
+ return reference.getRuntimeWire(endpointReference);
} else if (reference != null) {
return reference.getRuntimeWire(binding);
} else {
@@ -165,13 +177,10 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> {
protected void bind(RuntimeWire wire) {
if (wire != null) {
-
- if (wire instanceof EndpointWireImpl) {
- endpointWire = wire;
- }
this.component = wire.getSource().getComponent();
this.reference = (RuntimeComponentReference)wire.getSource().getContract();
this.binding = wire.getSource().getBinding();
+ this.endpointReference = wire.getEndpointReference();
this.compositeActivator = ((ComponentContextExt)component.getComponentContext()).getCompositeActivator();
this.conversationManager = this.compositeActivator.getCompositeContext().getConversationManager();
initCallbackID();
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java
index d935f6b93a..75c82a8861 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java
@@ -23,6 +23,8 @@ import java.io.Reader;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Binding;
@@ -30,10 +32,15 @@ import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentProperty;
import org.apache.tuscany.sca.assembly.ComponentReference;
import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Endpoint2;
+import org.apache.tuscany.sca.assembly.EndpointReference2;
import org.apache.tuscany.sca.assembly.Multiplicity;
import org.apache.tuscany.sca.assembly.OptimizableBinding;
import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint;
+import org.apache.tuscany.sca.assembly.builder.EndpointReferenceBuilder;
import org.apache.tuscany.sca.context.ContextFactoryExtensionPoint;
import org.apache.tuscany.sca.context.PropertyValueFactory;
import org.apache.tuscany.sca.context.RequestContextFactory;
@@ -51,6 +58,8 @@ import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
@@ -73,6 +82,8 @@ public class ComponentContextImpl implements ComponentContextExt {
private final AssemblyFactory assemblyFactory;
private final JavaInterfaceFactory javaInterfaceFactory;
private final PropertyValueFactory propertyFactory;
+ private final EndpointReferenceBuilder endpointReferenceBuilder;
+ private final Monitor monitor;
public ComponentContextImpl(ExtensionPointRegistry registry, RuntimeComponent component) {
this.component = component;
@@ -85,6 +96,11 @@ public class ComponentContextImpl implements ComponentContextExt {
registry.getExtensionPoint(ContextFactoryExtensionPoint.class).getFactory(RequestContextFactory.class);
this.proxyFactory = new ExtensibleProxyFactory(registry.getExtensionPoint(ProxyFactoryExtensionPoint.class));
this.propertyFactory = factories.getFactory(PropertyValueFactory.class);
+
+ this.endpointReferenceBuilder = utilities.getUtility(EndpointReferenceBuilder.class);
+
+ MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class);
+ this.monitor = monitorFactory.createMonitor();
}
public String getURI() {
@@ -304,6 +320,7 @@ public class ComponentContextImpl implements ComponentContextExt {
InvalidInterfaceException {
ComponentReference componentReference = assemblyFactory.createComponentReference();
componentReference.setName("$self$." + service.getName());
+
for (Binding binding : service.getBindings()) {
if (binding instanceof OptimizableBinding) {
OptimizableBinding optimizableBinding = (OptimizableBinding)((OptimizableBinding)binding).clone();
@@ -330,6 +347,26 @@ public class ComponentContextImpl implements ComponentContextExt {
componentReference.setInterfaceContract(interfaceContract);
componentReference.setMultiplicity(Multiplicity.ONE_ONE);
// component.getReferences().add(componentReference);
+
+ // create endpoint reference
+ EndpointReference2 endpointReference = assemblyFactory
+ .createEndpointReference();
+ endpointReference.setComponent(component);
+ endpointReference.setReference(componentReference);
+ endpointReference.setUnresolved(false);
+
+ // create endpoint.
+ Endpoint2 endpoint = assemblyFactory.createEndpoint();
+ endpoint.setComponent(component);
+ endpoint.setService(service);
+ endpoint.setUnresolved(true);
+ endpointReference.setTargetEndpoint(endpoint);
+
+ componentReference.getEndpointReferences().add(endpointReference);
+
+ // do binding matching
+ endpointReferenceBuilder.build(endpointReference, monitor);
+
return componentReference;
}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/CallbackReferenceImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/CallbackReferenceImpl.java
index 79daf537ea..fe2b5a6bde 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/CallbackReferenceImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/CallbackReferenceImpl.java
@@ -27,10 +27,13 @@ import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Endpoint2;
+import org.apache.tuscany.sca.assembly.EndpointReference2;
import org.apache.tuscany.sca.assembly.OptimizableBinding;
import org.apache.tuscany.sca.core.assembly.impl.EndpointReferenceImpl;
import org.apache.tuscany.sca.core.assembly.impl.RuntimeComponentReferenceImpl;
import org.apache.tuscany.sca.core.assembly.impl.RuntimeWireImpl;
+import org.apache.tuscany.sca.core.assembly.impl.RuntimeWireImpl2;
import org.apache.tuscany.sca.core.context.CompositeContext;
import org.apache.tuscany.sca.core.context.impl.CallableReferenceImpl;
import org.apache.tuscany.sca.core.invocation.ProxyFactory;
@@ -149,7 +152,7 @@ public class CallbackReferenceImpl<B> extends CallableReferenceImpl<B> {
private RuntimeWire cloneAndBind(RuntimeWire wire) {
RuntimeWire boundWire = null;
if (resolvedEndpoint != null) {
- boundWire = ((RuntimeWireImpl)wire).lookupCache(resolvedEndpoint);
+ boundWire = ((RuntimeWireImpl2)wire).lookupCache(resolvedEndpoint);
if (boundWire != null) {
return boundWire;
}
@@ -157,20 +160,27 @@ public class CallbackReferenceImpl<B> extends CallableReferenceImpl<B> {
Contract contract = resolvedEndpoint.getContract();
RuntimeComponentReference ref = null;
if (contract == null) {
+ //TODO - EPR - does it ever go through here?
boundWire = (RuntimeWire)wire.clone();
} else if (contract instanceof RuntimeComponentReference) {
ref = (RuntimeComponentReference)contract;
- boundWire = ref.getRuntimeWire(resolvedEndpoint.getBinding());
+ //TODO - EPR - get the bound wire based on endpont reference no binding
+ //boundWire = ref.getRuntimeWire(resolvedEndpoint.getBinding());
+ for (RuntimeWire runtimeWire : ref.getRuntimeWires()){
+ if (runtimeWire.getEndpointReference().getBinding().getName().equals(resolvedEndpoint.getBinding().getName())){
+ boundWire = runtimeWire;
+ break;
+ }
+ }
} else { // contract instanceof RuntimeComponentService
ref = bind((RuntimeComponentReference)wire.getSource().getContract(),
- resolvedEndpoint.getComponent(),
- (RuntimeComponentService)contract);
+ resolvedEndpoint);
boundWire = ref.getRuntimeWires().get(0);
}
configureWire(boundWire);
- ((RuntimeWireImpl)wire).addToCache(resolvedEndpoint, boundWire);
+ ((RuntimeWireImpl2)wire).addToCache(resolvedEndpoint, boundWire);
} catch (CloneNotSupportedException e) {
// will not happen
}
@@ -178,9 +188,12 @@ public class CallbackReferenceImpl<B> extends CallableReferenceImpl<B> {
return boundWire;
}
+ // TODO - EPR - why static & convert to ne endpoint reference
private static RuntimeComponentReference bind(RuntimeComponentReference reference,
- RuntimeComponent component,
- RuntimeComponentService service) throws CloneNotSupportedException {
+ EndpointReference resolvedEndpoint) throws CloneNotSupportedException {
+ RuntimeComponent component = resolvedEndpoint.getComponent();
+ RuntimeComponentService service = (RuntimeComponentService)resolvedEndpoint.getContract();
+
RuntimeComponentReference ref = (RuntimeComponentReference)reference.clone();
ref.getTargets().add(service);
ref.getBindings().clear();
@@ -195,10 +208,28 @@ public class CallbackReferenceImpl<B> extends CallableReferenceImpl<B> {
ref.getBindings().add(binding);
}
}
+
+ ref.getEndpointReferences().clear();
+
+ for(EndpointReference2 endpointReference : reference.getEndpointReferences()){
+ EndpointReference2 clone = (EndpointReference2)endpointReference.clone();
+
+ clone.setReference(ref);
+ clone.getBinding().setURI(resolvedEndpoint.getURI());
+
+ clone.getTargetEndpoint().setComponent(resolvedEndpoint.getComponent());
+ clone.getTargetEndpoint().setService((ComponentService)resolvedEndpoint.getContract());
+ clone.getTargetEndpoint().setBinding(resolvedEndpoint.getBinding());
+
+ ref.getEndpointReferences().add(clone);
+ }
+
return ref;
}
- private void configureWire(RuntimeWire wire) {
+ private void configureWire(RuntimeWire wire ) {
+
+ // TODO - EPR - do we actiually need this code? Combine with bind?
// need to set the endpoint on the binding also so that when the chains are created next
// the sca binding can decide whether to provide local or remote invokers.
// TODO - there is a problem here though in that I'm setting a target on a
@@ -208,10 +239,12 @@ public class CallbackReferenceImpl<B> extends CallableReferenceImpl<B> {
Binding binding = wire.getSource().getBinding();
binding.setURI(resolvedEndpoint.getURI());
- // also need to set the target contract as it varies for the sca binding depending on
+ // set the target contract as it varies for the sca binding depending on
// whether it is local or remote
RuntimeComponentReference ref = (RuntimeComponentReference)wire.getSource().getContract();
- wire.getTarget().setInterfaceContract(ref.getBindingProvider(binding).getBindingInterfaceContract());
+
+ // TODO - EPR
+ wire.getEndpointReference().getTargetEndpoint().setInterfaceContract(ref.getBindingProvider(binding).getBindingInterfaceContract());
}
/**
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java
index 2d88ed36d9..0a8d40c8db 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java
@@ -22,6 +22,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.apache.tuscany.sca.core.assembly.impl.RuntimeWireImpl;
+import org.apache.tuscany.sca.core.assembly.impl.RuntimeWireImpl2;
import org.apache.tuscany.sca.core.context.impl.CallableReferenceImpl;
import org.apache.tuscany.sca.core.conversation.ConversationState;
import org.apache.tuscany.sca.invocation.InvocationChain;
@@ -78,7 +79,7 @@ public class JDKCallbackInvocationHandler extends JDKInvocationHandler {
if (convID == null) {
convID = ((CallbackReferenceImpl)callableReference).getConvID();
if (convID != null) {
- conversation = ((RuntimeWireImpl)wire).getConversationManager().getConversation(convID);
+ conversation = ((RuntimeWireImpl2)wire).getConversationManager().getConversation(convID);
if (callableReference != null) {
((CallableReferenceImpl)callableReference).attachConversation(conversation);
}
@@ -103,7 +104,7 @@ public class JDKCallbackInvocationHandler extends JDKInvocationHandler {
throw e;
} finally {
// allow the cloned wire to be reused by subsequent callbacks
- ((RuntimeWireImpl)wire).releaseWire();
+ ((RuntimeWireImpl2)wire).releaseWire();
}
}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java
index ff58a116b7..6f3e3514bc 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java
@@ -29,6 +29,7 @@ import java.util.Map;
import java.util.UUID;
import org.apache.tuscany.sca.core.assembly.impl.RuntimeWireImpl;
+import org.apache.tuscany.sca.core.assembly.impl.RuntimeWireImpl2;
import org.apache.tuscany.sca.core.context.CallableReferenceExt;
import org.apache.tuscany.sca.core.context.impl.CallableReferenceImpl;
import org.apache.tuscany.sca.core.conversation.ConversationExt;
@@ -100,6 +101,7 @@ public class JDKInvocationHandler implements InvocationHandler, Serializable {
}
protected void init(RuntimeWire wire) {
+ // TODO - EPR needs fixing when we remove the old EndpointReference
if (wire != null) {
try {
// Clone the endpoint reference so that reference parameters can be changed
@@ -387,7 +389,7 @@ public class JDKInvocationHandler implements InvocationHandler, Serializable {
return;
}
- ConversationManager conversationManager = ((RuntimeWireImpl)wire).getConversationManager();
+ ConversationManager conversationManager = ((RuntimeWireImpl2)wire).getConversationManager();
if (conversation == null || conversation.getState() == ConversationState.ENDED) {
diff --git a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.assembly.CompositeActivator b/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.assembly.CompositeActivator
index d5e13292d2..67f5bede89 100644
--- a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.assembly.CompositeActivator
+++ b/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.assembly.CompositeActivator
@@ -15,4 +15,4 @@
# specific language governing permissions and limitations
# under the License.
-org.apache.tuscany.sca.core.assembly.impl.CompositeActivatorImpl
+org.apache.tuscany.sca.core.assembly.impl.CompositeActivatorImpl2