Add more intent validation and fix up inner composite policy set processing

git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@979307 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
bdaniel 2010-07-26 14:29:34 +00:00
commit 17c842b3d4
4 changed files with 70 additions and 41 deletions

View file

@ -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;
}

View file

@ -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());
}
}
}
}
}
}

View file

@ -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();

View file

@ -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