diff options
3 files changed, 70 insertions, 4 deletions
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java b/sca-java-2.x/branches/2.0-Beta1/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java index 8922c232b0..c2deacbb35 100644 --- a/sca-java-2.x/branches/2.0-Beta1/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java +++ b/sca-java-2.x/branches/2.0-Beta1/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java @@ -1098,8 +1098,17 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt //now resolve the implementation so that even if there is a shared instance //for this that is resolved, the specified intents and policysets are safe in the //component and not lost + List<Intent> intents = implementation.getRequiredIntents(); + List<PolicySet> policySets = implementation.getPolicySets(); + + implementation = resolveImplementation(implementation, resolver, context); + implementation.getPolicySets().clear(); + implementation.getPolicySets().addAll(policySets); + implementation.getRequiredIntents().clear(); + implementation.getRequiredIntents().addAll(intents); + component.setImplementation(implementation); } diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java b/sca-java-2.x/branches/2.0-Beta1/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java index 7965002304..0c88a01b19 100644 --- a/sca-java-2.x/branches/2.0-Beta1/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java +++ b/sca-java-2.x/branches/2.0-Beta1/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java @@ -145,7 +145,30 @@ public interface Constants { String AUTHORIZATION_FINE_GRAIN = "authorization.fineGrain"; QName AUTHORIZATION_FINE_GRAIN_INTENT = new QName(SCA11_NS, AUTHORIZATION_FINE_GRAIN); - // TODO - add transaction intent constants + String MANAGED_TRANSACTION = "managedTransaction"; + QName MANAGED_TRANSACTION_INTENT = new QName(SCA11_NS, MANAGED_TRANSACTION); + + String NO_MANAGED_TRANSACTION = "noManagedTransaction"; + QName NO_MANAGED_TRANSACTION_INTENT = new QName(SCA11_NS, NO_MANAGED_TRANSACTION); + + String MANAGED_TRANSACTION_LOCAL = "managedTransaction.local"; + QName MANAGED_TRANSACTION_LOCAL_INTENT = new QName(SCA11_NS, MANAGED_TRANSACTION_LOCAL); + + String MANAGED_TRANSACTION_GLOBAL = "managedTransaction.global"; + QName MANAGED_TRANSACTION_GLOBAL_INTENT = new QName(SCA11_NS, MANAGED_TRANSACTION_GLOBAL); + + String PROPAGATES_TRANSACTION = "propagatesTransaction"; + QName PROPAGATES_TRANSACTION_INTENT = new QName(SCA11_NS, PROPAGATES_TRANSACTION); + + String SUSPENDS_TRANSACTION = "suspendsTransaction"; + QName SUSPENDS_TRANSACTION_INTENT = new QName(SCA11_NS, SUSPENDS_TRANSACTION); + + String TRANSACTED_ONE_WAY = "transactedOneWay"; + QName TRANSACTED_ONE_WAY_INTENT = new QName(SCA11_NS, TRANSACTED_ONE_WAY); + + String IMMEDIATE_ONE_WAY = "immediateOneWay"; + QName IMMEDIATE_ONE_WAY_INTENT = new QName(SCA11_NS, IMMEDIATE_ONE_WAY); + String NOLISTENER = "noListener"; QName NOLISTENER_INTENT = new QName(SCA11_NS, NOLISTENER); diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java b/sca-java-2.x/branches/2.0-Beta1/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java index b58635d6d1..2b59e892be 100644 --- a/sca-java-2.x/branches/2.0-Beta1/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java +++ b/sca-java-2.x/branches/2.0-Beta1/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java @@ -49,6 +49,7 @@ import org.apache.tuscany.sca.interfacedef.util.Audit; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.policy.BindingType; +import org.apache.tuscany.sca.policy.ExtensionType; import org.apache.tuscany.sca.policy.Intent; import org.apache.tuscany.sca.policy.IntentMap; import org.apache.tuscany.sca.policy.PolicySet; @@ -559,8 +560,8 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder { // this they must be satisfied by reference policy sets // Failing this the intent is unresolved and the reference and // service don't match - List<Intent> eprIntents = new ArrayList<Intent>(); - eprIntents.addAll(endpointReference.getRequiredIntents()); + + // TODO - seems that we should do this loop on a binding by binding basis // rather than each time we do matching @@ -573,6 +574,13 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder { } } + // 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>(); + eprIntents.addAll(endpointReference.getRequiredIntents()); + // first check the binding type for (Intent intent : endpointReference.getRequiredIntents()){ if (bindingType != null && @@ -703,7 +711,33 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder { return match; } - protected boolean isQualifiedBy(Intent qualifiableIntent, Intent qualifiedIntent){ + // Copied from ComponentPolicyBuilder, should probably be refactored + protected void removeConstrainedIntents(EndpointReference subject, BindingType bindingType) { + List<Intent> intents = subject.getRequiredIntents(); + + // Remove the intents whose @contrains do not include the current element + if(bindingType != null){ + List<Intent> copy = new ArrayList<Intent>(intents); + for (Intent i : copy) { + if (i.getConstrainedTypes().size() > 0){ + boolean constraintFound = false; + for (ExtensionType constrainedType : i.getConstrainedTypes()){ + if (constrainedType.getType().equals(bindingType.getType()) || + constrainedType.getType().equals(bindingType.getBaseType())){ + constraintFound = true; + break; + } + } + if(!constraintFound){ + intents.remove(i); + } + } + } + } + } + + + protected boolean isQualifiedBy(Intent qualifiableIntent, Intent qualifiedIntent){ if (qualifiedIntent.getQualifiableIntent() == qualifiableIntent){ return true; } else { |