TUSCANY-3959 - Correct interface matching so that it takes account of mayProvides intents.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1185139 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a206102be7
commit
7d550f3ba9
5 changed files with 132 additions and 12 deletions
|
|
@ -444,11 +444,11 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
|
|||
// TUSCANY-3873 - add policy from the service
|
||||
// we don't care about intents at this stage
|
||||
endpointReference.getPolicySets().addAll(matchedEndpoint.getPolicySets());
|
||||
|
||||
// TODO - we need to re-run the appliesTo processing here but there is some question about what
|
||||
// appliesTo means. It's also difficult to get to the PolicyAppliesToBuilder from here and
|
||||
// need a new EntensionInterface to support access. So for now I'm just cheating and looking to
|
||||
// see if the XPath expression contains the binding type as a string while we discuss appliesTo
|
||||
|
||||
List<PolicySet> psToRemove = new ArrayList<PolicySet>();
|
||||
|
||||
for (PolicySet ps : endpointReference.getPolicySets() ) {
|
||||
|
|
@ -765,18 +765,14 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
|
|||
systemDefinitions = ((RuntimeEndpoint)endpoint).getCompositeContext().getSystemDefinitions();
|
||||
}
|
||||
|
||||
for (BindingType loopBindingType : systemDefinitions.getBindingTypes()){
|
||||
if (loopBindingType.getType().equals(binding.getType())){
|
||||
bindingType = loopBindingType;
|
||||
break;
|
||||
}
|
||||
}
|
||||
bindingType = systemDefinitions.getBindingType(binding.getType());
|
||||
|
||||
// Before we start examining intents, remove any whose constrained
|
||||
// types don't include the binding type
|
||||
removeConstrainedIntents(endpointReference, bindingType);
|
||||
|
||||
List<Intent> eprIntents = new ArrayList<Intent>();
|
||||
List<Intent> eprMayProvideInterationIntents = new ArrayList<Intent>();
|
||||
eprIntents.addAll(endpointReference.getRequiredIntents());
|
||||
|
||||
// first check the binding type
|
||||
|
|
@ -787,6 +783,9 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
|
|||
} else if (bindingType != null &&
|
||||
bindingType.getMayProvidedIntents().contains(intent)){
|
||||
eprIntents.remove(intent);
|
||||
if (intent.getType().equals(Intent.Type.interaction)){
|
||||
eprMayProvideInterationIntents.add(intent);
|
||||
}
|
||||
} else {
|
||||
// TODO - this code also appears in the ComponentPolicyBuilder
|
||||
// so should rationalize
|
||||
|
|
@ -820,7 +819,29 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
|
|||
matchAudit.append("No match because there are unresolved intents " + eprIntents.toString() + " ");
|
||||
matchAudit.appendSeperator();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// TUSCANY-3959 - something that's not explicitly stated in the spec. mayProvides intents don't
|
||||
// don't lead to policy sets as the binding natively implements the intent. So
|
||||
// we need to check that these intents match explicitly between reference and service
|
||||
// sides
|
||||
if (eprMayProvideInterationIntents.size() > 0){
|
||||
for (Intent eprIntent : eprMayProvideInterationIntents){
|
||||
boolean match = false;
|
||||
for (Intent epIntent : endpoint.getRequiredIntents()){
|
||||
if (epIntent.equals(eprIntent)){
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!match){
|
||||
matchAudit.append("No match because the reference has a mayProvide intent that the service doesn't have " + eprIntent.getName());
|
||||
matchAudit.appendSeperator();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if there are no policies on epr or ep side then
|
||||
// they match
|
||||
|
|
@ -932,7 +953,7 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
|
|||
|
||||
if (constrainedTypes.size() > 0){
|
||||
boolean constraintFound = false;
|
||||
for (ExtensionType constrainedType : i.getConstrainedTypes()){
|
||||
for (ExtensionType constrainedType : constrainedTypes){
|
||||
if (constrainedType.getType().equals(bindingType.getType()) ||
|
||||
constrainedType.getType().equals(bindingType.getBaseType())){
|
||||
constraintFound = true;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* 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
|
||||
* 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.
|
||||
-->
|
||||
<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
|
||||
xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
|
||||
xmlns:foo="http://foo" targetNamespace="http://foo"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
name="MissmatchPolicyDistributedClient" >
|
||||
|
||||
<component name="DistributedClientComponent">
|
||||
<implementation.java class="org.apache.tuscany.sca.itest.interfaces.ClientComponentImpl" />
|
||||
<reference name="aCallBackService" target="DistributedServiceComponent" requires="sca:SOAP.v1_2"/>
|
||||
</component>
|
||||
|
||||
</composite>
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* 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
|
||||
* 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.
|
||||
-->
|
||||
<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
|
||||
xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
|
||||
xmlns:foo="http://foo" targetNamespace="http://foo"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
name="MissmatchPolicyDistributedService" >
|
||||
|
||||
<component name="DistributedServiceComponent">
|
||||
<implementation.java class="org.apache.tuscany.sca.itest.interfaces.ServiceComponentImpl" />
|
||||
<service name="ServiceComponent" requires="authentication">
|
||||
<binding.ws/>
|
||||
</service>
|
||||
</component>
|
||||
</composite>
|
||||
|
|
@ -201,6 +201,45 @@ public class InerfaceMissmatchTestCase {
|
|||
node2.stop();
|
||||
Assert.assertTrue(ex.getMessage().startsWith("Unable to bind []"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remotable client and service interfaces where the interfaces match and the service and reference
|
||||
* have missmatching policy.
|
||||
* Components running in the separate composite/JVM, i.e. there is a remote registry
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testPolicyDistributedRemotable() throws Exception {
|
||||
|
||||
|
||||
String [] contributions = {"./target/classes"};
|
||||
Node node1 = NodeFactory.newInstance().createNode(URI.create("uri:default"),
|
||||
"org/apache/tuscany/sca/itest/interfaces/missmatch/distributed/MissmatchPolicyDistributedClient.composite",
|
||||
contributions);
|
||||
node1.start();
|
||||
|
||||
Node node2 = NodeFactory.newInstance().createNode(URI.create("uri:default"),
|
||||
"org/apache/tuscany/sca/itest/interfaces/missmatch/distributed/MissmatchPolicyDistributedService.composite",
|
||||
contributions);
|
||||
// force binding.ws on node2 to use a different port from node 1(which will default to 8080
|
||||
((NodeImpl)node2).getConfiguration().addBinding(WebServiceBinding.TYPE, "http://localhost:8081/");
|
||||
node2.start();
|
||||
|
||||
ClientComponent local = node1.getService(ClientComponent.class, "DistributedClientComponent");
|
||||
ParameterObject po = new ParameterObject();
|
||||
|
||||
try {
|
||||
String response = local.foo1(po);
|
||||
node1.stop();
|
||||
node2.stop();
|
||||
Assert.fail("Expected exception indicating that interfaces don't match");
|
||||
} catch (ServiceRuntimeException ex){
|
||||
node1.stop();
|
||||
node2.stop();
|
||||
Assert.assertTrue(ex.getMessage().startsWith("Unable to bind []"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,8 +36,7 @@
|
|||
<component name="Payment">
|
||||
<implementation.java class="org.apache.tuscany.sca.itest.policies.impl.PaymentImpl" />
|
||||
<reference name="creditCardPayment">
|
||||
<binding.sca requires="sca:integrity tuscany:logging" uri="CreditCardPayment">
|
||||
</binding.sca>
|
||||
<binding.sca requires="sca:integrity.transport tuscany:logging" uri="CreditCardPayment"/>
|
||||
</reference>
|
||||
<reference name="customerRegistry" target="Customer/Registry" requires="sca:suspendsTransaction tuscany:logging"/>
|
||||
</component>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue