summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-12-08 15:52:30 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-12-08 15:52:30 +0000
commitda3f698d67a4034bcb94f2b4c0b6a7b26c7ee423 (patch)
treec09de2c1f036683e17eb9a8883732855e882b597 /sca-java-2.x/trunk
parentd56a64505d24516a9ec86d9eba72ad2adac00651 (diff)
Update EndpointReferenceBinder with a plug point for an UnknownEndpointHandler thats called when an endpoint isn't found in the registry. Don't know if this is the best approach yet but it gives something to try with itests too see how it works
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1043464 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk')
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java35
1 files changed, 28 insertions, 7 deletions
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 67455bad09..47c0ca4fc5 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
@@ -42,6 +42,7 @@ import org.apache.tuscany.sca.assembly.builder.PolicyBuilder;
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.impl.RuntimeEndpointImpl;
import org.apache.tuscany.sca.core.assembly.impl.RuntimeEndpointReferenceImpl;
import org.apache.tuscany.sca.definitions.Definitions;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
@@ -62,6 +63,7 @@ import org.apache.tuscany.sca.runtime.EndpointReferenceBinder;
import org.apache.tuscany.sca.runtime.EndpointRegistry;
import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.apache.tuscany.sca.runtime.UnknownEndpointHandler;
import org.oasisopen.sca.ServiceRuntimeException;
/**
@@ -83,6 +85,7 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
protected BuilderExtensionPoint builders;
protected CompositeActivator compositeActivator;
protected Monitor monitor;
+ protected UnknownEndpointHandler unknownEndpointHandler;
public EndpointReferenceBinderImpl(ExtensionPointRegistry extensionPoints) {
@@ -96,6 +99,8 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
MonitorFactory monitorFactory = utils.getUtility(MonitorFactory.class);
monitor = monitorFactory.createMonitor();
+
+ this.unknownEndpointHandler = utils.getUtility(UnknownEndpointHandler.class);
this.builders = extensionPoints.getExtensionPoint(BuilderExtensionPoint.class);
this.compositeActivator = extensionPoints.getExtensionPoint(CompositeActivator.class);
@@ -274,13 +279,29 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
endpointReference.getTargetEndpoint().setBinding(endpointReference.getBinding());
endpointReference.setStatus(EndpointReference.Status.RESOLVED_BINDING);
} else {
- Monitor.error(monitor,
- this,
- "endpoint-validation-messages",
- "NoEndpointsFound",
- endpointReference.toString());
- throw new ServiceRuntimeException("Unable to bind " +
- monitor.getLastProblem().toString());
+ Binding b = null;
+ if (unknownEndpointHandler != null) {
+ b = unknownEndpointHandler.handleUnknownEndpoint(endpointReference);
+ }
+ if (b != null) {
+ Endpoint matchedEndpoint = new RuntimeEndpointImpl(extensionPoints);
+ matchedEndpoint.setBinding(b);
+ matchedEndpoint.setRemote(true);
+ endpointReference.setTargetEndpoint(matchedEndpoint);
+ endpointReference.setBinding(b);
+ endpointReference.setUnresolved(false);
+ endpointReference.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);
+ matchAudit.append("Match because the UnknownEndpointHandler provided a binding: " + b.getType() + " uri: " + b.getURI());
+ matchAudit.appendSeperator();
+ } else {
+ Monitor.error(monitor,
+ this,
+ "endpoint-validation-messages",
+ "NoEndpointsFound",
+ endpointReference.toString());
+ throw new ServiceRuntimeException("Unable to bind " +
+ monitor.getLastProblem().toString());
+ }
}
}
}