summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/core/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java9
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java81
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/Constants.java30
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeInvoker.java60
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java128
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/resources/endpoint-validation-messages.properties2
6 files changed, 260 insertions, 50 deletions
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
index 4cae8d0085..31738c3a5d 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
@@ -182,7 +182,7 @@ public class RuntimeEndpointImpl extends EndpointImpl implements RuntimeEndpoint
new ExtensibleWireProcessor(registry.getExtensionPoint(RuntimeWireProcessorExtensionPoint.class));
this.messageFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(MessageFactory.class);
- this.invoker = new RuntimeInvoker(this.messageFactory, this);
+ this.invoker = new RuntimeInvoker(registry, this);
this.phaseManager = utilities.getUtility(PhaseManager.class);
this.serializer = utilities.getUtility(EndpointSerializer.class);
@@ -285,6 +285,11 @@ public class RuntimeEndpointImpl extends EndpointImpl implements RuntimeEndpoint
public Message invoke(Operation operation, Message msg) {
return invoker.invoke(operation, msg);
}
+
+ public void invokeAsync(Operation operation, Message msg) {
+ msg.setOperation(operation);
+ invoker.invokeAsync(msg);
+ }
/**
* Navigate the component/componentType inheritence chain to find the leaf contract
@@ -647,7 +652,7 @@ public class RuntimeEndpointImpl extends EndpointImpl implements RuntimeEndpoint
@Override
public Object clone() throws CloneNotSupportedException {
RuntimeEndpointImpl copy = (RuntimeEndpointImpl)super.clone();
- copy.invoker = new RuntimeInvoker(copy.messageFactory, copy);
+ copy.invoker = new RuntimeInvoker(registry, copy);
return copy;
}
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java
index 36480f3435..b18af33a39 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java
@@ -31,18 +31,24 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.ComponentReference;
import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.CompositeReference;
import org.apache.tuscany.sca.assembly.CompositeService;
import org.apache.tuscany.sca.assembly.Contract;
import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.builder.BindingBuilder;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
import org.apache.tuscany.sca.assembly.impl.EndpointReferenceImpl;
import org.apache.tuscany.sca.context.CompositeContext;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory;
+import org.apache.tuscany.sca.core.invocation.AsyncResponseHandler;
import org.apache.tuscany.sca.core.invocation.ExtensibleWireProcessor;
import org.apache.tuscany.sca.core.invocation.NonBlockingInterceptor;
import org.apache.tuscany.sca.core.invocation.RuntimeInvoker;
@@ -51,8 +57,10 @@ import org.apache.tuscany.sca.core.invocation.impl.PhaseManager;
import org.apache.tuscany.sca.interfacedef.Compatibility;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
import org.apache.tuscany.sca.invocation.Interceptor;
import org.apache.tuscany.sca.invocation.InvocationChain;
import org.apache.tuscany.sca.invocation.Invoker;
@@ -68,7 +76,9 @@ import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
import org.apache.tuscany.sca.runtime.EndpointReferenceBinder;
import org.apache.tuscany.sca.runtime.EndpointRegistry;
import org.apache.tuscany.sca.runtime.EndpointSerializer;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
import org.apache.tuscany.sca.runtime.RuntimeWireProcessor;
import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint;
@@ -169,7 +179,7 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen
new ExtensibleWireProcessor(registry.getExtensionPoint(RuntimeWireProcessorExtensionPoint.class));
this.messageFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(MessageFactory.class);
- this.invoker = new RuntimeInvoker(this.messageFactory, this);
+ this.invoker = new RuntimeInvoker(registry, this);
this.phaseManager = utilities.getUtility(PhaseManager.class);
this.serializer = utilities.getUtility(EndpointSerializer.class);
@@ -227,6 +237,11 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen
public Message invoke(Operation operation, Message msg) {
return invoker.invoke(operation, msg);
}
+
+ public void invokeAsync(Operation operation, Message msg) {
+ msg.setOperation(operation);
+ invoker.invokeAsync(msg);
+ }
/**
* Navigate the component/componentType inheritence chain to find the leaf contract
@@ -472,7 +487,7 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen
@Override
public Object clone() throws CloneNotSupportedException {
RuntimeEndpointReferenceImpl copy = (RuntimeEndpointReferenceImpl)super.clone();
- copy.invoker = new RuntimeInvoker(copy.messageFactory, copy);
+ copy.invoker = new RuntimeInvoker(registry, copy);
return copy;
}
@@ -615,5 +630,65 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen
}
return interfaceContract.getNormalizedWSDLContract();
- }
+ }
+
+ public void createAsyncCallbackEndpoint(){
+ CompositeContext compositeContext = getCompositeContext();
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ RuntimeAssemblyFactory assemblyFactory = (RuntimeAssemblyFactory)modelFactories.getFactory(AssemblyFactory.class);
+
+ RuntimeEndpoint endpoint = (RuntimeEndpoint)assemblyFactory.createEndpoint();
+ endpoint.bind(compositeContext);
+ endpoint.setComponent(getComponent());
+
+ // Create pseudo-service
+ ComponentService service = assemblyFactory.createComponentService();
+ JavaInterfaceFactory javaInterfaceFactory =
+ (JavaInterfaceFactory)modelFactories.getFactory(JavaInterfaceFactory.class);
+ JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
+ try {
+ interfaceContract.setInterface(javaInterfaceFactory.createJavaInterface(AsyncResponseHandler.class));
+ } catch (InvalidInterfaceException e1) {
+ // Nothing to do here - will not happen
+ } // end try
+
+ service.setInterfaceContract(interfaceContract);
+ String serviceName = getReference().getName() + "_asyncCallback";
+ service.setName(serviceName);
+ service.getEndpoints().add(endpoint);
+ service.setForCallback(true);
+ endpoint.setService(service);
+
+ // Set pseudo-service onto the component
+ getComponent().getServices().add(service);
+
+ // Create a binding
+ // Mike had to go via the XML but I don't remember why
+ Binding binding = null;
+ try {
+ binding = (Binding)getBinding().clone();
+ } catch (Exception ex){
+ //
+ }
+ String callbackURI = "/" + component.getName() + "/" + service.getName();
+ binding.setURI(callbackURI);
+
+ BuilderExtensionPoint builders = registry.getExtensionPoint(BuilderExtensionPoint.class);
+ BindingBuilder builder = builders.getBindingBuilder(binding.getType());
+ if (builder != null) {
+ org.apache.tuscany.sca.assembly.builder.BuilderContext builderContext = new BuilderContext(registry);
+ builder.build(component, service, binding, builderContext, true);
+ } // end if
+
+ endpoint.setBinding(binding);
+
+ // Need to establish policies here (binding has some...)
+ endpoint.getRequiredIntents().addAll(getRequiredIntents());
+ endpoint.getPolicySets().addAll(getPolicySets());
+ String epURI = getComponent().getName() + "#service-binding(" + serviceName + "/" + serviceName + ")";
+ endpoint.setURI(epURI);
+ endpoint.setUnresolved(false);
+
+ setCallbackEndpoint(endpoint);
+ }
}
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/Constants.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/Constants.java
new file mode 100644
index 0000000000..3e2a71027d
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/Constants.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.core.invocation;
+
+/**
+ * Constants used during invocation in the runtime
+ *
+
+ */
+public interface Constants {
+ String MESSAGE_ID = "MESSAGE_ID";
+
+}
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeInvoker.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeInvoker.java
index 0751fd631b..b5e3eec282 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeInvoker.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeInvoker.java
@@ -20,28 +20,45 @@
package org.apache.tuscany.sca.core.invocation;
import java.lang.reflect.InvocationTargetException;
+import java.util.UUID;
+import java.util.concurrent.ExecutorService;
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.context.ThreadMessageContext;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.InvocationChain;
import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.InvokerAsync;
import org.apache.tuscany.sca.invocation.Message;
import org.apache.tuscany.sca.invocation.MessageFactory;
import org.apache.tuscany.sca.runtime.Invocable;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.apache.tuscany.sca.work.WorkScheduler;
/**
* Invoker for a endpoint or endpoint reference
* @version $Rev$ $Date$
*/
-public class RuntimeInvoker implements Invoker {
+public class RuntimeInvoker implements Invoker, InvokerAsync {
+ protected ExtensionPointRegistry registry;
protected MessageFactory messageFactory;
protected Invocable invocable;
+
+ // Run async service invocations using a ThreadPoolExecutor
+ private ExecutorService theExecutor;
- public RuntimeInvoker(MessageFactory messageFactory, Invocable invocable) {
- this.messageFactory = messageFactory;
+ public RuntimeInvoker(ExtensionPointRegistry registry, Invocable invocable) {
+ this.registry = registry;
+ this.messageFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(MessageFactory.class);
this.invocable = invocable;
+
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ WorkScheduler scheduler = utilities.getUtility(WorkScheduler.class);
+ theExecutor = scheduler.getExecutorService();
}
public Message invokeBinding(Message msg) {
@@ -93,5 +110,42 @@ public class RuntimeInvoker implements Invoker {
ThreadMessageContext.setMessageContext(msgContext);
}
}
+
+ public void invokeAsync(Message msg) {
+ if (invocable instanceof Endpoint) {
+ msg.setTo((Endpoint)invocable);
+ } else if (invocable instanceof EndpointReference) {
+ RuntimeEndpointReference epr = (RuntimeEndpointReference)invocable;
+ if (epr.isOutOfDate()) {
+ epr.rebuild();
+ }
+ msg.setFrom((EndpointReference)invocable);
+ }
+
+ Operation operation = msg.getOperation();
+ InvocationChain chain = invocable.getInvocationChain(operation);
+
+ if (chain == null) {
+ throw new IllegalArgumentException("No matching operation is found: " + operation.getName());
+ }
+
+ // create an async message ID if there isn't one there already
+ if (!msg.getHeaders().containsKey(Constants.MESSAGE_ID)){
+ msg.getHeaders().put(Constants.MESSAGE_ID, UUID.randomUUID().toString());UUID.randomUUID().toString();
+ }
+
+ // Perform the async invocation
+ InvokerAsync headInvoker = (InvokerAsync)chain.getHeadInvoker();
+
+ Message msgContext = ThreadMessageContext.setMessageContext(msg);
+ try {
+ // TODO - is this the way we'll pass async messages down the chain?
+ headInvoker.invokeAsync(msg);
+ } finally {
+ ThreadMessageContext.setMessageContext(msgContext);
+ }
+
+ return;
+ }
}
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
index 905fed4e01..ffe48005ea 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
@@ -107,8 +107,9 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
* @param endpointReference
*/
public void bindBuildTime(EndpointRegistry endpointRegistry,
- EndpointReference endpointReference) {
- bind(endpointRegistry, endpointReference, false);
+ EndpointReference endpointReference,
+ BuilderContext builderContext) {
+ bind(endpointRegistry, endpointReference, builderContext, false);
}
/**
@@ -120,7 +121,7 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
*/
public void bindRunTime(EndpointRegistry endpointRegistry,
EndpointReference endpointReference) {
- bind(endpointRegistry, endpointReference, true);
+ bind(endpointRegistry, endpointReference, null, true);
}
/**
@@ -132,6 +133,7 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
*/
public void bind(EndpointRegistry endpointRegistry,
EndpointReference endpointReference,
+ BuilderContext builderContext,
boolean runtime){
logger.fine("Binding " + endpointReference.toString());
@@ -159,7 +161,7 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
continue;
}
- if (haveMatchingPolicy(endpointReference, endpoint, matchAudit) &&
+ if (haveMatchingPolicy(endpointReference, endpoint, matchAudit, builderContext) &&
haveMatchingInterfaceContracts(endpointReference, endpoint, matchAudit)){
// matching service so find if this reference already has
// an endpoint reference for this endpoint
@@ -216,7 +218,9 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
|| endpointReference.getCallbackEndpoint().isUnresolved())) {
selectCallbackEndpoint(endpointReference,
endpointReference.getReference().getCallbackService(),
- matchAudit);
+ matchAudit,
+ builderContext,
+ runtime);
}
} else if (endpointReference.getStatus() == EndpointReference.Status.WIRED_TARGET_FOUND_READY_FOR_MATCHING ){
// The endpoint reference is already resolved to either
@@ -226,12 +230,15 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
selectForwardEndpoint(endpointReference,
endpointReference.getTargetEndpoint().getService().getEndpoints(),
- matchAudit);
+ matchAudit,
+ builderContext);
if (hasCallback(endpointReference)){
selectCallbackEndpoint(endpointReference,
endpointReference.getReference().getCallbackService(),
- matchAudit);
+ matchAudit,
+ builderContext,
+ runtime);
}
} else if (endpointReference.getStatus() == EndpointReference.Status.WIRED_TARGET_IN_BINDING_URI ||
endpointReference.getStatus() == EndpointReference.Status.WIRED_TARGET_NOT_FOUND ||
@@ -241,10 +248,23 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
// find the service in the endpoint registry
List<Endpoint> endpoints = endpointRegistry.findEndpoint(endpointReference);
- if ((endpoints.size() == 0) &&
- (runtime == true) ) {
-
- // tweak to test if this could be a resolve binding. This is the back end of the test
+ if (endpoints.size() > 0){
+ selectForwardEndpoint(endpointReference,
+ endpoints,
+ matchAudit,
+ builderContext);
+
+ // If the reference was matched try to match the callback
+ if (endpointReference.getStatus().equals(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED) &&
+ hasCallback(endpointReference)){
+ selectCallbackEndpoint(endpointReference,
+ endpointReference.getReference().getCallbackService(),
+ matchAudit,
+ builderContext,
+ runtime);
+ }
+ } else if (runtime) {
+ // tweak to test if this could be a resolved binding. This is the back end of the test
// in the builder that pulls the URI out of the binding if there are no targets
// on the reference. have to wait until here to see if the binding uri matches any
// available services. If not we assume here that it's a resolved binding
@@ -260,16 +280,6 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
throw new ServiceRuntimeException("Unable to bind " +
monitor.getLastProblem().toString());
}
- }
-
- selectForwardEndpoint(endpointReference,
- endpoints,
- matchAudit);
-
- if (hasCallback(endpointReference)){
- selectCallbackEndpoint(endpointReference,
- endpointReference.getReference().getCallbackService(),
- matchAudit);
}
}
@@ -285,21 +295,46 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
"EndpointReferenceCantBeMatched",
endpointReference.toString(),
matchAudit);
+ throw new ServiceRuntimeException("Unable to bind " +
+ monitor.getLastProblem().toString());
} else {
Monitor.warning(monitor,
this,
"endpoint-validation-messages",
"ComponentReferenceTargetNotFound",
endpointReference.toString());
+ return;
}
- throw new ServiceRuntimeException("Unable to bind " +
- monitor.getLastProblem().toString());
+
}
// Now the endpoint reference is resolved check that the binding interfaces contract
// and the reference contract are compatible
- ((RuntimeEndpointReference)endpointReference).validateReferenceInterfaceCompatibility();
+ try {
+ ((RuntimeEndpointReference)endpointReference).validateReferenceInterfaceCompatibility();
+ } catch (ServiceRuntimeException ex) {
+ // don't re-throw this exception at build time just record the
+ // error. If it's thrown here is messes up the order in which
+ // build time errors are reported and that in turn messes
+ // up the output of the compliance tests.
+ if (runtime){
+ throw ex;
+ } else {
+ Monitor.error(monitor,
+ this,
+ "endpoint-validation-messages",
+ "EndpointReferenceCantBeMatched",
+ endpointReference.toString(),
+ ex.getMessage());
+ }
+ }
+
+ // if the reference is an async reference fluff up the
+ // response service/endpoint
+ if (endpointReference.isAsyncInvocation()){
+ ((RuntimeEndpointReference)endpointReference).createAsyncCallbackEndpoint();
+ }
// System.out.println("MATCH AUDIT:" + matchAudit.toString());
}
@@ -323,7 +358,7 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
* @param endpointReference
* @param endpoints
*/
- private void selectForwardEndpoint(EndpointReference endpointReference, List<Endpoint> endpoints, Audit matchAudit) {
+ private void selectForwardEndpoint(EndpointReference endpointReference, List<Endpoint> endpoints, Audit matchAudit, BuilderContext builderContext) {
Endpoint matchedEndpoint = null;
@@ -337,7 +372,7 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
} else {
// find the first endpoint that matches this endpoint reference
for (Endpoint endpoint : endpoints){
- if (haveMatchingPolicy(endpointReference, endpoint, matchAudit) &&
+ if (haveMatchingPolicy(endpointReference, endpoint, matchAudit, builderContext) &&
haveMatchingInterfaceContracts(endpointReference, endpoint, matchAudit)){
matchedEndpoint = endpoint;
break;
@@ -374,7 +409,7 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
* @param endpointReference
* @param endpoints
*/
- private void selectCallbackEndpoint(EndpointReference endpointReference, ComponentService callbackService, Audit matchAudit) {
+ private void selectCallbackEndpoint(EndpointReference endpointReference, ComponentService callbackService, Audit matchAudit, BuilderContext builderContext, boolean runtime) {
// find the first callback endpoint that matches a callback endpoint reference
// at the service
@@ -382,7 +417,7 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
match:
for ( EndpointReference callbackEndpointReference : endpointReference.getTargetEndpoint().getCallbackEndpointReferences()){
for (Endpoint endpoint : callbackService.getEndpoints()){
- if (haveMatchingPolicy(callbackEndpointReference, endpoint, matchAudit) &&
+ if (haveMatchingPolicy(callbackEndpointReference, endpoint, matchAudit, builderContext) &&
haveMatchingInterfaceContracts(callbackEndpointReference, endpoint, matchAudit)){
callbackEndpoint = (RuntimeEndpoint)endpoint;
break match;
@@ -435,13 +470,18 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
// build it
build(callbackEndpoint);
- // activate it
- compositeActivator.activate(((RuntimeEndpointReferenceImpl)endpointReference).getCompositeContext(),
- callbackEndpoint);
-
- // start it
- compositeActivator.start(((RuntimeEndpointReferenceImpl)endpointReference).getCompositeContext(),
- callbackEndpoint);
+ // Only activate the callback endpoint if the bind is being done at runtime
+ // and hence everthing else is running. If we don't activate here then the
+ // endpoint will be activate at the same time as all the other endpoints
+ if (runtime) {
+ // activate it
+ compositeActivator.activate(((RuntimeEndpointReferenceImpl)endpointReference).getCompositeContext(),
+ callbackEndpoint);
+
+ // start it
+ compositeActivator.start(((RuntimeEndpointReferenceImpl)endpointReference).getCompositeContext(),
+ callbackEndpoint);
+ }
}
endpointReference.setCallbackEndpoint(callbackEndpoint);
@@ -477,7 +517,7 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
* - Perform policy specific match
*
*/
- private boolean haveMatchingPolicy(EndpointReference endpointReference, Endpoint endpoint, Audit matchAudit){
+ private boolean haveMatchingPolicy(EndpointReference endpointReference, Endpoint endpoint, Audit matchAudit, BuilderContext builderContext){
matchAudit.append("Match policy of " + endpointReference.toString() + " to " + endpoint.toString() + " ");
List<PolicySet> referencePolicySets = new ArrayList<PolicySet>();
@@ -568,12 +608,17 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
// Failing this the intent is unresolved and the reference and
// service don't match
-
-
// TODO - seems that we should do this loop on a binding by binding basis
// rather than each time we do matching
BindingType bindingType = null;
- Definitions systemDefinitions = ((RuntimeEndpoint)endpoint).getCompositeContext().getSystemDefinitions();
+
+ Definitions systemDefinitions = null;
+ if (builderContext != null){
+ systemDefinitions = builderContext.getDefinitions();
+ } else {
+ systemDefinitions = ((RuntimeEndpoint)endpoint).getCompositeContext().getSystemDefinitions();
+ }
+
for (BindingType loopBindingType : systemDefinitions.getBindingTypes()){
if (loopBindingType.getType().equals(binding.getType())){
bindingType = loopBindingType;
@@ -707,8 +752,9 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
endpointReference.getPolicySets().addAll(referencePolicySets);
if (builder != null) {
- // TODO - where to get builder context from?
- BuilderContext builderContext = new BuilderContext(monitor);
+ if (builderContext == null){
+ builderContext = new BuilderContext(monitor);
+ }
match = builder.build(endpointReference, endpoint, builderContext);
}
diff --git a/sca-java-2.x/trunk/modules/core/src/main/resources/endpoint-validation-messages.properties b/sca-java-2.x/trunk/modules/core/src/main/resources/endpoint-validation-messages.properties
index 6e12d11d68..75f635fb1a 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/resources/endpoint-validation-messages.properties
+++ b/sca-java-2.x/trunk/modules/core/src/main/resources/endpoint-validation-messages.properties
@@ -20,4 +20,4 @@
#
NoEndpointsFound = No endpoints found in the domain that match the reference {0}
EndpointReferenceCantBeMatched = = Unable to match the endpoint reference {0} with the policy of the service to which it refers, matching process was {1}
-ComponentReferenceTargetNotFound = Component reference target not found, it might be a remote service running elsewhere in the SCA Domain: {1}
+ComponentReferenceTargetNotFound = Component reference target not found at deployment time, it might be a remote service elsewhere in the SCA Domain so we'll try and resolve it again at runtime: {1}