summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DefaultSCABindingMapper.java
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2011-07-11 10:54:38 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2011-07-11 10:54:38 +0000
commitdbf4d8905d3dcee44dc2d54270a5979560ce7f37 (patch)
treea84449b62a3cc19b988bc688b29ae3eae19ede43 /sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DefaultSCABindingMapper.java
parentf7e7402c450c81c4ca5a58adb7b3603db94a44f5 (diff)
TUSCANY-3884 - Convert the default binding to delegate for local calls as well as remote calls. Means that the binding is more consistent in it's layout and the delegation selection logic is more cleanly separated from the code that handles passing messages.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1145118 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DefaultSCABindingMapper.java32
1 files changed, 29 insertions, 3 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DefaultSCABindingMapper.java b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DefaultSCABindingMapper.java
index 284411054a..c87779d58d 100644
--- a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DefaultSCABindingMapper.java
+++ b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DefaultSCABindingMapper.java
@@ -47,6 +47,8 @@ import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
import org.apache.tuscany.sca.provider.SCABindingMapper;
import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
import org.apache.tuscany.sca.runtime.DomainRegistryFactoryExtensionPoint;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
import org.oasisopen.sca.ServiceRuntimeException;
@@ -60,6 +62,7 @@ public class DefaultSCABindingMapper implements SCABindingMapper {
protected ProviderFactoryExtensionPoint providerFactories;
protected StAXArtifactProcessorExtensionPoint processors;
protected QName defaultMappedBinding;
+ protected QName defaultLocalBinding;
protected boolean supportsDistributedSCA;
public DefaultSCABindingMapper(ExtensionPointRegistry registry, Map<String, String> attributes) {
@@ -67,6 +70,7 @@ public class DefaultSCABindingMapper implements SCABindingMapper {
providerFactories = registry.getExtensionPoint(ProviderFactoryExtensionPoint.class);
processors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
defaultMappedBinding = getDefaultMappedBinding(attributes);
+ defaultLocalBinding = new QName(Base.SCA11_TUSCANY_NS, "binding.local");
supportsDistributedSCA = isDistributed();
}
@@ -151,7 +155,6 @@ public class DefaultSCABindingMapper implements SCABindingMapper {
}
public RuntimeEndpoint map(RuntimeEndpoint endpoint) {
-
QName bindingType = chooseBinding(endpoint);
if (!isBindingSupported(bindingType)) {
logger.warning("Mapped binding for binding.sca is not supported: " + bindingType);
@@ -242,6 +245,7 @@ public class DefaultSCABindingMapper implements SCABindingMapper {
return binding;
}
+ /*
public boolean isRemotable(RuntimeEndpoint endpoint) {
return supportsDistributedSCA && isBindingSupported(chooseBinding(endpoint));
}
@@ -249,6 +253,7 @@ public class DefaultSCABindingMapper implements SCABindingMapper {
public boolean isRemotable(RuntimeEndpointReference endpointReference) {
return supportsDistributedSCA && isBindingSupported(chooseBinding(endpointReference));
}
+ */
/**
* Choose the physical binding for service-side remotable binding.sca
@@ -256,7 +261,14 @@ public class DefaultSCABindingMapper implements SCABindingMapper {
* @return
*/
protected QName chooseBinding(RuntimeEndpoint endpoint) {
- return defaultMappedBinding;
+ if(endpoint.getService().getInterfaceContract() != null
+ && ((RuntimeComponentService)endpoint.getService()).getInterfaceContract().getInterface().isRemotable()
+ && supportsDistributedSCA
+ && isBindingSupported(defaultMappedBinding)) {
+ return defaultMappedBinding;
+ }
+
+ return defaultLocalBinding;
}
/**
@@ -265,7 +277,21 @@ public class DefaultSCABindingMapper implements SCABindingMapper {
* @return
*/
protected QName chooseBinding(RuntimeEndpointReference endpointReference) {
- return defaultMappedBinding;
+ if(endpointReference.getTargetEndpoint().isRemote()) {
+ RuntimeComponentReference ref = (RuntimeComponentReference)endpointReference.getReference();
+ if(ref.getInterfaceContract() != null && !ref.getInterfaceContract().getInterface().isRemotable()) {
+ throw new ServiceRuntimeException("Reference interface not remotable for component: "
+ + endpointReference.getComponent().getName()
+ + " and reference: "
+ + ref.getName());
+ }
+
+ if(supportsDistributedSCA && isBindingSupported(defaultMappedBinding)) {
+ return defaultMappedBinding;
+ }
+ }
+
+ return defaultLocalBinding;
}
}