diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules')
4 files changed, 70 insertions, 41 deletions
diff --git a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java index 07d4d59226..5db7ca78a3 100644 --- a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java +++ b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java @@ -33,7 +33,6 @@ import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.assembly.Component; import org.apache.tuscany.sca.assembly.ComponentReference; import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.CompositeReference; import org.apache.tuscany.sca.assembly.CompositeService; import org.apache.tuscany.sca.assembly.Contract; @@ -43,7 +42,6 @@ import org.apache.tuscany.sca.assembly.Service; import org.apache.tuscany.sca.assembly.builder.BuilderContext; import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint; import org.apache.tuscany.sca.assembly.builder.Messages; -import org.apache.tuscany.sca.assembly.xml.Constants; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.definitions.Definitions; import org.apache.tuscany.sca.monitor.Monitor; @@ -465,23 +463,10 @@ public class ComponentPolicyBuilderImpl { protected void removeConstrainedIntents(PolicySubject subject, BuilderContext context) { List<Intent> intents = subject.getRequiredIntents(); - QName baseType = null; - QName type = null; // Remove the intents whose @contrains do not include the current element ExtensionType extensionType = subject.getExtensionType(); - - // Need to check elements that don't have an extension type, like Composites - // References don't have an extension type, but they're checked at wiring time - if ( extensionType == null ) { - if ( subject instanceof Composite ) - type = Constants.COMPOSITE_QNAME; - } else { - type = extensionType.getType(); - baseType = extensionType.getBaseType(); - } - - if(type != null){ + if(extensionType != null){ List<Intent> copy = new ArrayList<Intent>(intents); for (Intent i : copy) { List<ExtensionType> constrainedTypes = i.getConstrainedTypes(); @@ -491,8 +476,8 @@ public class ComponentPolicyBuilderImpl { if (constrainedTypes.size() > 0){ boolean constraintFound = false; for (ExtensionType constrainedType : i.getConstrainedTypes()){ - if (constrainedType.getType().equals(type) || - constrainedType.getType().equals(baseType)){ + if (constrainedType.getType().equals(extensionType.getType()) || + constrainedType.getType().equals(extensionType.getBaseType())){ constraintFound = true; break; } diff --git a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java index 6fd43f1d3d..51c23f0939 100644 --- a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java +++ b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java @@ -197,18 +197,10 @@ public class CompositePolicyBuilderImpl extends ComponentPolicyBuilderImpl imple } } - if (implementation instanceof Composite) { - - // POL-4009 componentType attached policySets are ignored when policySets are - // attached to the using component definition. - if ( !component.getPolicySets().isEmpty() || !composite.getPolicySets().isEmpty() ) { - implementation.getPolicySets().clear(); - } - + if (implementation instanceof Composite) { resolveAndCheck(implementation, context); inherit(implementation, Intent.Type.implementation, true, component, composite); computePolicies((Composite)implementation, context); - removeConstrainedIntents(implementation, context); expandDefaultIntents(implementation,context); checkIntentsResolved(implementation,context); } else { @@ -254,12 +246,41 @@ public class CompositePolicyBuilderImpl extends ComponentPolicyBuilderImpl imple error(context.getMonitor(), "TransactedOneWayWithManagedTransactionLocal", this, + "reference", epr.getComponent().getName(), epr.getReference().getName()); + } else if ( Constants.PROPAGATES_TRANSACTION_INTENT.equals(eprIntent.getName())) { + error(context.getMonitor(), + "PropagatesTransactionWithLocalTran", + this, + "reference", + epr.getComponent().getName(), + epr.getReference().getName()); + } + } + } + } + for ( ComponentService service : component.getServices() ) { + for ( Endpoint ep : service.getEndpoints() ) { + for ( Intent epIntent : ep.getRequiredIntents() ) { + if ( Constants.TRANSACTED_ONE_WAY_INTENT.equals(epIntent.getName())) { + error(context.getMonitor(), + "TransactedOneWayWithManagedTransactionLocal", + this, + "service", + ep.getComponent().getName(), + ep.getService().getName()); + } else if ( Constants.PROPAGATES_TRANSACTION_INTENT.equals(epIntent.getName())) { + error(context.getMonitor(), + "PropagatesTransactionWithLocalTran", + this, + "service", + ep.getComponent().getName(), + ep.getService().getName()); } } } - } + } } else if ( Constants.NO_MANAGED_TRANSACTION_INTENT.equals(implIntent.getName())) { for ( ComponentService service : component.getServices() ) { for ( Endpoint ep : service.getEndpoints() ) { @@ -268,12 +289,27 @@ public class CompositePolicyBuilderImpl extends ComponentPolicyBuilderImpl imple error(context.getMonitor(), "PropagatesTransactionWithNoManagedTran", this, + "service", ep.getComponent().getName(), ep.getService().getName()); } } } } + for ( ComponentReference reference : component.getReferences() ) { + for ( EndpointReference epr : reference.getEndpointReferences() ) { + for ( Intent eprIntent : epr.getRequiredIntents() ) { + if ( Constants.PROPAGATES_TRANSACTION_INTENT.equals(eprIntent.getName())) { + error(context.getMonitor(), + "PropagatesTransactionWithNoManagedTran", + this, + "reference", + epr.getComponent().getName(), + epr.getReference().getName()); + } + } + } + } } } diff --git a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java index f911d5a5e4..5d30c048ec 100644 --- a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java +++ b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java @@ -112,16 +112,7 @@ public class PolicyAttachmentBuilderImpl implements CompositeBuilder { if (definitions == null || (definitions.getPolicySets().isEmpty() && definitions.getExternalAttachments().isEmpty()) ) { return composite; } - // Recursively apply the xpath against the composites referenced by <implementation.composite> - for (Component component : composite.getComponents()) { - Implementation impl = component.getImplementation(); - if (impl instanceof Composite) { - Composite patched = applyXPath((Composite)impl, definitions, monitor); - if (patched != impl) { - component.setImplementation(patched); - } - } - } + Document document = null; @@ -149,6 +140,23 @@ public class PolicyAttachmentBuilderImpl implements CompositeBuilder { } } + // Recursively apply the xpath against the composites referenced by <implementation.composite> + // If the composite or component has policy sets attached, we have to ignore policy sets + // attached to the inner composite. + if ( composite.getPolicySets().isEmpty() ) { + for (Component component : composite.getComponents()) { + if ( component.getPolicySets().isEmpty() ) { + Implementation impl = component.getImplementation(); + if (impl instanceof Composite) { + Composite patched = applyXPath((Composite)impl, definitions, monitor); + if (patched != impl) { + component.setImplementation(patched); + } + } + } + } + } + return composite; } finally { monitor.popContext(); diff --git a/sca-java-2.x/trunk/modules/builder/src/main/resources/org/apache/tuscany/sca/builder/builder-validation-messages.properties b/sca-java-2.x/trunk/modules/builder/src/main/resources/org/apache/tuscany/sca/builder/builder-validation-messages.properties index 9f6b307246..2d519a28ad 100644 --- a/sca-java-2.x/trunk/modules/builder/src/main/resources/org/apache/tuscany/sca/builder/builder-validation-messages.properties +++ b/sca-java-2.x/trunk/modules/builder/src/main/resources/org/apache/tuscany/sca/builder/builder-validation-messages.properties @@ -32,8 +32,8 @@ IntentNotSatisfiedAtBuild = The intent {0} associated with policy subject {1} h MutuallyExclusiveIntentsAtBuild = [POL40009,ASM60009,ASM60010,JCA70001,JCA70003] Intent {0} and {1} are mutually exclusive IntentNotFoundAtBuild = Intent {0} is not defined in SCA definitions NoListenerIntentSpecifiedOnService = The noListener intent may only be specified on a reference. -TransactedOneWayWithManagedTransactionLocal = The Component Reference {1} can not require transactedOneWay because the implementation for Component {0} requires managedTransaction.local -PropagatesTransactionWithNoManagedTran = The component service {1} can not require propagatesTransaction because the implementation for component {0} requires noManagedTransaction +TransactedOneWayWithManagedTransactionLocal = The Component {0} {2} can not require transactedOneWay because the implementation for Component {1} requires managedTransaction.local +PropagatesTransactionWithNoManagedTran = The component {0} {2} can not require propagatesTransaction because the implementation for component {1} requires noManagedTransaction TransactedOneWayWithTwoWayOp = The component reference {0} can not require transactedOneWay because the operation {1} is a two way operation ImmediateOneWayWithTwoWayOp = The component reference {0} can not require immediateOneWay because the operation {1} is a two way operation - +PropagatesTransactionWithLocalTran = The component {0} {2} can not require propagatesTransaction because the implementation for component {1} requires managedTransaction.local |