diff options
Diffstat (limited to '')
-rw-r--r-- | sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java | 35 |
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()); + } } } } |