You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sv...@apache.org on 2008/03/11 19:59:20 UTC
svn commit: r636059 - in /incubator/tuscany/java/sca/modules:
assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/
assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/
implementation-java-xml/src/test/java/org/apache/tuscany/...
Author: svkrish
Date: Tue Mar 11 11:59:14 2008
New Revision: 636059
URL: http://svn.apache.org/viewvc?rev=636059&view=rev
Log:
cleaning up and fixing holes in policy inheritance in operations
Modified:
incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BindingPolicyComputer.java
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ImplementationPolicyComputer.java
incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyComputer.java
incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/sca/implementation/java/xml/ReadTestCase.java
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationUtils.java
Modified: incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java?rev=636059&r1=636058&r2=636059&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java Tue Mar 11 11:59:14 2008
@@ -42,8 +42,10 @@
import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Base;
import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.ConfiguredOperation;
import org.apache.tuscany.sca.assembly.ConstrainingType;
import org.apache.tuscany.sca.assembly.Contract;
@@ -67,6 +69,8 @@
import org.apache.tuscany.sca.policy.PolicySet;
import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
import org.apache.tuscany.sca.policy.impl.IntentAttachPointTypeFactoryImpl;
+import org.apache.tuscany.sca.policy.util.PolicyValidationException;
+import org.apache.tuscany.sca.policy.util.PolicyValidationUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
@@ -234,7 +238,7 @@
* @throws ContributionResolveException
*/
protected Implementation resolveImplementation(Implementation implementation, ModelResolver resolver)
- throws ContributionResolveException {
+ throws ContributionResolveException, PolicyValidationException {
if (implementation != null) {
if (implementation.isUnresolved()) {
implementation = resolver.resolveModel(Implementation.class, implementation);
@@ -247,34 +251,36 @@
if ( implementation instanceof PolicySetAttachPoint ) {
PolicySetAttachPoint policiedImpl = (PolicySetAttachPoint)implementation;
resolveIntents(policiedImpl.getRequiredIntents(), resolver);
+ PolicyValidationUtils.validateIntents(policiedImpl, policiedImpl.getType());
+
resolvePolicySets(policiedImpl.getPolicySets(), resolver);
- validatePolicySets(policiedImpl);
+ PolicyValidationUtils.validatePolicySets(policiedImpl,
+ policiedImpl.getApplicablePolicySets());
if ( implementation instanceof OperationsConfigurator ) {
OperationsConfigurator opsConfigurator = (OperationsConfigurator)implementation;
for ( ConfiguredOperation implOp : opsConfigurator.getConfiguredOperations() ) {
resolveIntents(implOp.getRequiredIntents(), resolver);
+ PolicyValidationUtils.validateIntents(implOp, policiedImpl.getType());
+
resolvePolicySets(implOp.getPolicySets(), resolver);
- validatePolicySets(implOp, policiedImpl.getApplicablePolicySets());
+ PolicyValidationUtils.validatePolicySets(implOp, policiedImpl.getApplicablePolicySets());
}
}
for ( Service service : implementation.getServices() ) {
resolveIntents(service.getRequiredIntents(), resolver);
resolvePolicySets(service.getPolicySets(), resolver);
- validatePolicySets(service, policiedImpl.getApplicablePolicySets());
for ( ConfiguredOperation svcOp : service.getConfiguredOperations() ) {
resolveIntents(svcOp.getRequiredIntents(), resolver);
resolvePolicySets(svcOp.getPolicySets(), resolver);
- validatePolicySets(svcOp, policiedImpl.getApplicablePolicySets());
}
}
for ( Reference reference : implementation.getReferences() ) {
resolveIntents(reference.getRequiredIntents(), resolver);
resolvePolicySets(reference.getPolicySets(), resolver);
- validatePolicySets(reference, policiedImpl.getApplicablePolicySets());
}
}
@@ -304,7 +310,7 @@
resolveContracts(null, contracts, resolver);
}
-
+
/**
* Resolve interface, callback interface and bindings on a list of contracts.
* @param parent element for the contracts
@@ -313,90 +319,137 @@
*/
protected <C extends Contract> void resolveContracts(Base parent, List<C> contracts, ModelResolver resolver)
throws ContributionResolveException {
+
+ String parentName = (parent instanceof Composite) ? ((Composite)parent).getName().toString() :
+ (parent instanceof Component) ? ((Component)parent).getName().toString() : "UNKNOWN";
+
for (Contract contract : contracts) {
- //resolve the intents and policysets as they need to be copied over into the
- //child binding elements
- resolveIntents(contract.getRequiredIntents(), resolver);
- resolvePolicySets(contract.getPolicySets(), resolver);
- resolvePolicySets(contract.getApplicablePolicySets(), resolver);
-
- //inherit the composite / component level policy intents and policysets
- if ( parent != null && parent instanceof PolicySetAttachPoint ) {
- addInheritedIntents(((PolicySetAttachPoint)parent).getRequiredIntents(), contract.getRequiredIntents());
- addInheritedPolicySets(((PolicySetAttachPoint)parent).getPolicySets(), contract.getPolicySets());
- addInheritedPolicySets(((PolicySetAttachPoint)parent).getApplicablePolicySets(), contract.getApplicablePolicySets());
- }
-
- for ( ConfiguredOperation confOp : contract.getConfiguredOperations() ) {
- resolveIntents(confOp.getRequiredIntents(), resolver);
- resolvePolicySets(confOp.getPolicySets(), resolver);
- resolvePolicySets(confOp.getApplicablePolicySets(), resolver);
- }
-
- // Resolve the interface contract
- InterfaceContract interfaceContract = contract.getInterfaceContract();
- if (interfaceContract != null) {
- extensionProcessor.resolve(interfaceContract, resolver);
- }
-
- // Resolve bindings
- for (int i = 0, n = contract.getBindings().size(); i < n; i++) {
- Binding binding = contract.getBindings().get(i);
- extensionProcessor.resolve(binding, resolver);
- if (binding instanceof IntentAttachPoint) {
- IntentAttachPoint policiedBinding = (IntentAttachPoint)binding;
- resolveIntents(policiedBinding.getRequiredIntents(), resolver);
+ try {
+ //resolve the intents and policysets as they need to be copied over into the
+ //child binding elements
+ resolveIntents(contract.getRequiredIntents(), resolver);
+ resolvePolicySets(contract.getPolicySets(), resolver);
+ resolvePolicySets(contract.getApplicablePolicySets(), resolver);
+
+ //inherit the composite / component level policy intents and policysets
+ if ( parent != null && parent instanceof PolicySetAttachPoint ) {
+ addInheritedIntents(((PolicySetAttachPoint)parent).getRequiredIntents(), contract.getRequiredIntents());
+ addInheritedPolicySets(((PolicySetAttachPoint)parent).getPolicySets(), contract.getPolicySets());
+ addInheritedPolicySets(((PolicySetAttachPoint)parent).getApplicablePolicySets(), contract.getApplicablePolicySets());
}
- if (binding instanceof PolicySetAttachPoint) {
- PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)binding;
- resolvePolicySets(policiedBinding.getPolicySets(), resolver);
- //validate if attached policysets apply to the binding
- resolvePolicySets(policiedBinding.getApplicablePolicySets(), resolver);
- validatePolicySets(policiedBinding);
+
+ for ( ConfiguredOperation confOp : contract.getConfiguredOperations() ) {
+ resolveIntents(confOp.getRequiredIntents(), resolver);
+ resolvePolicySets(confOp.getPolicySets(), resolver);
+ resolvePolicySets(confOp.getApplicablePolicySets(), resolver);
+
+ //inherit intents and policysets from parent contract
+ addInheritedIntents(contract.getRequiredIntents(), confOp.getRequiredIntents());
+ addInheritedPolicySets(contract.getPolicySets(), confOp.getPolicySets());
+ addInheritedPolicySets(contract.getApplicablePolicySets(), confOp.getApplicablePolicySets());
}
- if (binding instanceof OperationsConfigurator) {
- OperationsConfigurator opConfigurator = (OperationsConfigurator)binding;
- for (ConfiguredOperation confOp : opConfigurator.getConfiguredOperations()) {
- resolveIntents(confOp.getRequiredIntents(), resolver);
- resolvePolicySets(confOp.getPolicySets(), resolver);
- resolvePolicySets(confOp.getApplicablePolicySets(), resolver);
- }
+
+ // Resolve the interface contract
+ InterfaceContract interfaceContract = contract.getInterfaceContract();
+ if (interfaceContract != null) {
+ extensionProcessor.resolve(interfaceContract, resolver);
}
- }
-
- // Resolve callback bindings
- if (contract.getCallback() != null) {
- resolveIntents(contract.getCallback().getRequiredIntents(), resolver);
- resolvePolicySets(contract.getCallback().getPolicySets(), resolver);
- resolvePolicySets(contract.getCallback().getApplicablePolicySets(), resolver);
- //inherit the contract's policy intents and policysets
- addInheritedIntents(contract.getRequiredIntents(), contract.getCallback().getRequiredIntents());
- addInheritedPolicySets(contract.getPolicySets(), contract.getCallback().getPolicySets());
- addInheritedPolicySets(contract.getApplicablePolicySets(), contract.getCallback().getApplicablePolicySets());
-
- for (int i = 0, n = contract.getCallback().getBindings().size(); i < n; i++) {
- Binding binding = contract.getCallback().getBindings().get(i);
+
+ // Resolve bindings
+ for (int i = 0, n = contract.getBindings().size(); i < n; i++) {
+ Binding binding = contract.getBindings().get(i);
extensionProcessor.resolve(binding, resolver);
-
+
if (binding instanceof IntentAttachPoint) {
IntentAttachPoint policiedBinding = (IntentAttachPoint)binding;
resolveIntents(policiedBinding.getRequiredIntents(), resolver);
+ PolicyValidationUtils.validateIntents(policiedBinding, policiedBinding.getType());
}
+
if (binding instanceof PolicySetAttachPoint) {
PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)binding;
resolvePolicySets(policiedBinding.getPolicySets(), resolver);
+ //validate if attached policysets apply to the binding
resolvePolicySets(policiedBinding.getApplicablePolicySets(), resolver);
- validatePolicySets(policiedBinding);
+ //inherit the applicable policysets from parent contract as whatever applies to that
+ //applies to the binding as well
+ addInheritedPolicySets(contract.getApplicablePolicySets(), policiedBinding.getApplicablePolicySets());
+ PolicyValidationUtils.validatePolicySets(policiedBinding);
}
+
if (binding instanceof OperationsConfigurator) {
OperationsConfigurator opConfigurator = (OperationsConfigurator)binding;
for (ConfiguredOperation confOp : opConfigurator.getConfiguredOperations()) {
resolveIntents(confOp.getRequiredIntents(), resolver);
+ PolicyValidationUtils.validateIntents(confOp, ((PolicySetAttachPoint)binding).getType());
+
resolvePolicySets(confOp.getPolicySets(), resolver);
resolvePolicySets(confOp.getApplicablePolicySets(), resolver);
+ //inherit the applicable policysets from parent binding as whatever applies to that
+ //applies to the binding as well
+ addInheritedPolicySets(((PolicySetAttachPoint)binding).getApplicablePolicySets(),
+ confOp.getApplicablePolicySets());
+ PolicyValidationUtils.validatePolicySets(confOp);
+
+ addInheritedIntents(((PolicySetAttachPoint)binding).getRequiredIntents(),
+ confOp.getRequiredIntents());
+ addInheritedPolicySets(((PolicySetAttachPoint)binding).getPolicySets(),
+ confOp.getPolicySets());
}
}
}
+
+ // Resolve callback bindings
+ if (contract.getCallback() != null) {
+ resolveIntents(contract.getCallback().getRequiredIntents(), resolver);
+ resolvePolicySets(contract.getCallback().getPolicySets(), resolver);
+ resolvePolicySets(contract.getCallback().getApplicablePolicySets(), resolver);
+ //inherit the contract's policy intents and policysets
+ addInheritedIntents(contract.getRequiredIntents(), contract.getCallback().getRequiredIntents());
+ addInheritedPolicySets(contract.getPolicySets(), contract.getCallback().getPolicySets());
+ addInheritedPolicySets(contract.getApplicablePolicySets(), contract.getCallback().getApplicablePolicySets());
+
+ for (int i = 0, n = contract.getCallback().getBindings().size(); i < n; i++) {
+ Binding binding = contract.getCallback().getBindings().get(i);
+ extensionProcessor.resolve(binding, resolver);
+
+ if (binding instanceof IntentAttachPoint) {
+ IntentAttachPoint policiedBinding = (IntentAttachPoint)binding;
+ resolveIntents(policiedBinding.getRequiredIntents(), resolver);
+ PolicyValidationUtils.validateIntents(policiedBinding, policiedBinding.getType());
+ }
+
+ if (binding instanceof PolicySetAttachPoint) {
+ PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)binding;
+ resolvePolicySets(policiedBinding.getPolicySets(), resolver);
+ //validate if attached policysets apply to the binding
+ resolvePolicySets(policiedBinding.getApplicablePolicySets(), resolver);
+ //inherit the applicable policysets from parent contract as whatever applies to that
+ //applies to the binding as well
+ addInheritedPolicySets(contract.getApplicablePolicySets(), policiedBinding.getApplicablePolicySets());
+ PolicyValidationUtils.validatePolicySets(policiedBinding);
+ }
+
+ if (binding instanceof OperationsConfigurator) {
+ OperationsConfigurator opConfigurator = (OperationsConfigurator)binding;
+ for (ConfiguredOperation confOp : opConfigurator.getConfiguredOperations()) {
+ resolveIntents(confOp.getRequiredIntents(), resolver);
+ PolicyValidationUtils.validateIntents(confOp, ((PolicySetAttachPoint)binding).getType());
+
+ resolvePolicySets(confOp.getPolicySets(), resolver);
+ resolvePolicySets(confOp.getApplicablePolicySets(), resolver);
+ //inherit the applicable policysets from parent binding as whatever applies to that
+ //applies to the binding as well
+ addInheritedPolicySets(((PolicySetAttachPoint)binding).getApplicablePolicySets(),
+ confOp.getApplicablePolicySets());
+ PolicyValidationUtils.validatePolicySets(confOp);
+ }
+ }
+ }
+ }
+ } catch ( PolicyValidationException e ) {
+ throw new ContributionResolveException("PolicyValidation exceptions when processing service/reference '"
+ + contract.getName() + "' in '" + parentName + "'");
}
}
}
@@ -714,7 +767,7 @@
}
- protected void validatePolicySets(PolicySetAttachPoint policySetAttachPoint)
+ /*protected void validatePolicySets(PolicySetAttachPoint policySetAttachPoint)
throws ContributionResolveException {
validatePolicySets(policySetAttachPoint, policySetAttachPoint.getApplicablePolicySets());
}
@@ -740,28 +793,5 @@
}
}
-
- /*String appliesTo = null;
- IntentAttachPointType attachPointType = policySetAttachPoint.getType();
- String scdlFragment = ""; //need to write the 'parent' as scdl xml string
-
- if ( attachPointType != null ) {
- //validate policysets specified for the attachPoint
- for (PolicySet policySet : policySetAttachPoint.getPolicySets()) {
- appliesTo = policySet.getAppliesTo();
- if ( !policySet.isUnresolved() ) {
- if (!PolicyValidationUtils.isPolicySetApplicable(scdlFragment, appliesTo, attachPointType)) {
- throw new ContributionResolveException("Policy Set '" + policySet.getName()
- + "' does not apply to binding type "
- + attachPointType.getName());
-
- } }
- else {
- throw new ContributionResolveException("Policy Set '" + policySet.getName()
- + "' is not defined in this domain ");
-
- }
- }
- }*/
- }
+ }*/
}
Modified: incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java?rev=636059&r1=636058&r2=636059&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java Tue Mar 11 11:59:14 2008
@@ -65,6 +65,8 @@
import org.apache.tuscany.sca.policy.PolicyFactory;
import org.apache.tuscany.sca.policy.PolicySet;
import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.util.PolicyValidationException;
+import org.apache.tuscany.sca.policy.util.PolicyValidationUtils;
import org.w3c.dom.Document;
/**
@@ -825,33 +827,42 @@
//resolve component implemenation
Implementation implementation = component.getImplementation();
if (implementation != null) {
- //resolve intents and policysets specified on this implementation
- //before copying them over to the component. Before that, from the component
- //copy over the applicablePolicySets alone as it might have to be
- //used to validate the policysets specified on the implementation
-
- resolveImplIntentsAndPolicySets(implementation, component.getApplicablePolicySets(), resolver);
-
- copyPoliciesToComponent(component, implementation, resolver, true);
-
- //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
- implementation = resolveImplementation(implementation, resolver);
-
- //resolved implementation may contain intents and policysets specified at
- //componentType (either in the componentType side file or in annotations if its a
- //java implementation). This has to be consolidated in to the component.
- copyPoliciesToComponent(component, implementation, resolver, false);
-
- component.setImplementation(implementation);
+ try {
+ //resolve intents and policysets specified on this implementation
+ //before copying them over to the component. Before that, from the component
+ //copy over the applicablePolicySets alone as it might have to be
+ //used to validate the policysets specified on the implementation
+
+ resolveImplIntentsAndPolicySets(implementation,
+ component.getApplicablePolicySets(),
+ resolver);
+
+ copyPoliciesToComponent(component, implementation, resolver, true);
+
+ //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
+ implementation = resolveImplementation(implementation, resolver);
+
+ //resolved implementation may contain intents and policysets specified at
+ //componentType (either in the componentType side file or in annotations if its a
+ //java implementation). This has to be consolidated in to the component.
+ copyPoliciesToComponent(component, implementation, resolver, false);
+
+ component.setImplementation(implementation);
+ } catch ( PolicyValidationException e ) {
+ throw new ContributionResolveException("PolicyValidation exception when processing implementation of component '"
+ + component.getName() + "' due to " + e.getMessage());
+ }
+
}
}
}
private void resolveImplIntentsAndPolicySets(Implementation implementation,
List<PolicySet> inheritedApplicablePolicySets,
- ModelResolver resolver) throws ContributionResolveException
+ ModelResolver resolver) throws ContributionResolveException,
+ PolicyValidationException
{
if ( implementation instanceof PolicySetAttachPoint ) {
PolicySetAttachPoint policiedImpl = (PolicySetAttachPoint)implementation;
@@ -859,16 +870,29 @@
policiedImpl.getApplicablePolicySets().addAll(inheritedApplicablePolicySets);
resolveIntents(policiedImpl.getRequiredIntents(), resolver);
+ PolicyValidationUtils.validateIntents(policiedImpl, policiedImpl.getType());
+
resolvePolicySets(policiedImpl.getPolicySets(), resolver);
resolvePolicySets(policiedImpl.getApplicablePolicySets(), resolver);
- validatePolicySets(policiedImpl);
+
+ PolicyValidationUtils.validatePolicySets(policiedImpl);
if ( implementation instanceof OperationsConfigurator ) {
for ( ConfiguredOperation implConfOp : ((OperationsConfigurator)implementation).getConfiguredOperations() ) {
resolveIntents(implConfOp.getRequiredIntents(), resolver);
+ PolicyValidationUtils.validateIntents(implConfOp, policiedImpl.getType());
+
resolvePolicySets(implConfOp.getPolicySets(), resolver);
resolvePolicySets(implConfOp.getApplicablePolicySets(), resolver);
- validatePolicySets(implConfOp, policiedImpl.getApplicablePolicySets());
+ //add the inherited applicablePolicysets
+ addInheritedPolicySets(policiedImpl.getApplicablePolicySets(), implConfOp.getApplicablePolicySets());
+
+ PolicyValidationUtils.validatePolicySets(implConfOp);
+
+ addInheritedIntents(((PolicySetAttachPoint)implementation).getRequiredIntents(),
+ implConfOp.getRequiredIntents());
+ addInheritedPolicySets(((PolicySetAttachPoint)implementation).getPolicySets(),
+ implConfOp.getPolicySets());
}
}
}
Modified: incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BindingPolicyComputer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BindingPolicyComputer.java?rev=636059&r1=636058&r2=636059&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BindingPolicyComputer.java (original)
+++ incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BindingPolicyComputer.java Tue Mar 11 11:59:14 2008
@@ -50,7 +50,7 @@
computeIntents(contract.getBindings(), contract.getRequiredIntents());
computePolicySets(contract.getApplicablePolicySets(), contract.getBindings(), contract.getPolicySets());
- for ( Binding binding : contract.getBindings() ) {
+ /*for ( Binding binding : contract.getBindings() ) {
if ( binding instanceof IntentAttachPoint ) {
computeIntentsForOperations((IntentAttachPoint)binding);
}
@@ -59,7 +59,7 @@
computePolicySetsForOperations(((PolicySetAttachPoint)binding).getApplicablePolicySets(),
(PolicySetAttachPoint)binding);
}
- }
+ }*/
if ( contract.getCallback() != null ) {
computeIntents(contract.getCallback().getBindings(),
@@ -80,9 +80,7 @@
inheritedIntents);
policiedBinding.getRequiredIntents().addAll(prunedIntents);
- computeIntents(policiedBinding);
- //trimInherentlyProvidedIntents(policiedBinding.getType(),
- // policiedBinding.getRequiredIntents());
+ normalizeIntents(policiedBinding);
computeIntentsForOperations((IntentAttachPoint)policiedBinding);
}
@@ -101,7 +99,7 @@
inheritedPolicySets,
policiedBinding.getApplicablePolicySets());
policiedBinding.getPolicySets().addAll(prunedPolicySets);
- computePolicySets(policiedBinding);
+ normalizePolicySets(policiedBinding);
computePolicySetsForOperations(applicablePolicySets, policiedBinding);
}
Modified: incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ImplementationPolicyComputer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ImplementationPolicyComputer.java?rev=636059&r1=636058&r2=636059&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ImplementationPolicyComputer.java (original)
+++ incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ImplementationPolicyComputer.java Tue Mar 11 11:59:14 2008
@@ -51,7 +51,7 @@
parent.getRequiredIntents());
parent.getRequiredIntents().clear();
parent.getRequiredIntents().addAll(prunedIntents);
- computeIntents(parent);
+ normalizeIntents(parent);
computeIntentsForOperations((OperationsConfigurator)parent,
(IntentAttachPoint)implementation,
@@ -63,7 +63,7 @@
parent.getApplicablePolicySets());
parent.getPolicySets().clear();
parent.getPolicySets().addAll(prunedPolicySets);
- computePolicySets(parent);
+ normalizePolicySets(parent);
computePolicySetsForOperations(parent.getApplicablePolicySets(),
(OperationsConfigurator)parent,
(PolicySetAttachPoint)implementation);
Modified: incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyComputer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyComputer.java?rev=636059&r1=636058&r2=636059&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyComputer.java (original)
+++ incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyComputer.java Tue Mar 11 11:59:14 2008
@@ -61,7 +61,7 @@
for (Intent intent : inheritableIntents) {
if ( !intent.isUnresolved() ) {
for (QName constrained : intent.getConstrains()) {
- if ( isConstrained(constrained, attachPointType)) {
+ if ( PolicyValidationUtils.isConstrained(constrained, attachPointType)) {
validInheritableIntents.add(intent);
break;
}
@@ -83,10 +83,10 @@
}
}
- protected void computeIntents(IntentAttachPoint intentAttachPoint) {
+ protected void normalizeIntents(IntentAttachPoint intentAttachPoint) {
//expand profile intents specified in the attachpoint (binding / implementation)
expandProfileIntents(intentAttachPoint.getRequiredIntents());
-
+
//remove duplicates and ...
//where qualified form of intent exists retain it and remove the qualifiable intent
filterDuplicatesAndQualifiableIntents(intentAttachPoint);
@@ -122,7 +122,7 @@
//expand profile intents specified on operations
expandProfileIntents(confOp.getRequiredIntents());
- validateIntents(confOp, attachPointType);
+ //validateIntents(confOp, attachPointType);
//add intents specified for parent intent attach point (binding / implementation)
//wherever its not overriden in the operation
@@ -167,29 +167,6 @@
}
}
- /*protected List<PolicySet> computeInheritablePolicySets(Base parent,
- IntentAttachPointType attachPointType,
- List<PolicySet> inheritablePolicySets)
- throws PolicyValidationException {
- List<PolicySet> validInheritablePolicySets = new ArrayList<PolicySet>();
- String appliesTo = null;
- String scdlFragment = null; //need to write parent as scdl fragment and pass the xml string
- //from the inherited set of policysets add only what applies to the attach point
- for (PolicySet policySet : inheritablePolicySets) {
- if ( !policySet.isUnresolved() ) {
- appliesTo = policySet.getAppliesTo();
- if (PolicyValidationUtils.isPolicySetApplicable(scdlFragment, appliesTo, attachPointType)) {
- validInheritablePolicySets.add(policySet);
- }
- } else {
- throw new PolicyValidationException("Policy Set '" + policySet.getName()
- + "' is not defined in this domain ");
- }
-
- }
- return validInheritablePolicySets;
- }*/
-
protected List<PolicySet> computeInheritablePolicySets(PolicySetAttachPoint policySetAttachPoint,
List<PolicySet> inheritablePolicySets,
List<PolicySet> applicablePolicySets)
@@ -209,7 +186,7 @@
return validInheritablePolicySets;
}
- protected void computePolicySets(PolicySetAttachPoint policySetAttachPoint ) {
+ protected void normalizePolicySets(PolicySetAttachPoint policySetAttachPoint ) {
//get rid of duplicate entries
HashMap<QName, PolicySet> policySetTable = new HashMap<QName, PolicySet>();
for ( PolicySet policySet : policySetAttachPoint.getPolicySets() ) {
@@ -345,12 +322,6 @@
}
}
- private boolean isConstrained(QName constrained, IntentAttachPointType attachPointType) {
- return (attachPointType != null && attachPointType.getName().getNamespaceURI().equals(constrained
- .getNamespaceURI()) && attachPointType.getName().getLocalPart()
- .startsWith(constrained.getLocalPart()) );
- }
-
private void filterDuplicatesAndQualifiableIntents(IntentAttachPoint intentAttachPoint) {
//remove duplicates
Map<QName, Intent> intentsTable = new HashMap<QName, Intent>();
@@ -381,7 +352,7 @@
for (Intent intent : confOp.getRequiredIntents()) {
if ( !intent.isUnresolved() ) {
for (QName constrained : intent.getConstrains()) {
- if (isConstrained(constrained, attachPointType)) {
+ if (PolicyValidationUtils.isConstrained(constrained, attachPointType)) {
found = true;
break;
}
Modified: incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/sca/implementation/java/xml/ReadTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/sca/implementation/java/xml/ReadTestCase.java?rev=636059&r1=636058&r2=636059&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/sca/implementation/java/xml/ReadTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/sca/implementation/java/xml/ReadTestCase.java Tue Mar 11 11:59:14 2008
@@ -246,10 +246,11 @@
}
opConf = (OperationsConfigurator)composite.getComponents().get(6);
- assertEquals(opConf.getConfiguredOperations().get(0).getPolicySets().size(), 3);
+ assertEquals(opConf.getConfiguredOperations().get(0).getPolicySets().size(), 4);
for ( PolicySet policySet : opConf.getConfiguredOperations().get(0).getPolicySets() ) {
String policySetName = policySet.getName().getLocalPart();
if ( !(policySetName.equals("tuscanyPolicySet_1") || policySetName.equals("tuscanyPolicySet_2")
+ || policySetName.equals("tuscanyPolicySet_3")
|| policySetName.equals("tuscanyPolicySet_4")) ) {
fail();
}
Modified: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationUtils.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationUtils.java?rev=636059&r1=636058&r2=636059&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationUtils.java (original)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationUtils.java Tue Mar 11 11:59:14 2008
@@ -19,35 +19,83 @@
package org.apache.tuscany.sca.policy.util;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentAttachPoint;
import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
/**
* @version $Rev$ $Date$
*/
public class PolicyValidationUtils {
- /*public static boolean isPolicySetApplicable(String scdlFragment,
- String xpath,
- IntentAttachPointType attachPointType) {
-
- //FIXME: For now do a simple check and later implement whatever is mentioned in the next comment
- if ( xpath != null && attachPointType != null && xpath.indexOf(attachPointType.getName().getLocalPart()) != -1) {
- return true;
- } else {
- return false;
- }
-
-
- //create a xml node out of the parent object.. i.e. write the parent object as scdl fragment
- //invoke PropertyUtil.evaluate(null, node, xpath)
- //verify the result Node's QName against the bindingType's name
-
- /*if (parent instanceof ComponentReference) {
- } else if (parent instanceof ComponentReference) {
- } else if (parent instanceof Component) {
- } else if (parent instanceof CompositeService) {
- } else if (parent instanceof CompositeReference) {
+ public static boolean isConstrained(QName constrained, IntentAttachPointType attachPointType) {
+ return (attachPointType != null && attachPointType.getName().getNamespaceURI()
+ .equals(constrained.getNamespaceURI()) && attachPointType.getName().getLocalPart()
+ .startsWith(constrained.getLocalPart()));
+ }
+
+ public static void validateIntents(IntentAttachPoint attachPoint,
+ IntentAttachPointType attachPointType)
+ throws PolicyValidationException {
+ boolean found = false;
+ if (attachPointType != null) {
+ // validate intents specified against the parent (binding /
+ // implementation)
+ found = false;
+ for (Intent intent : attachPoint.getRequiredIntents()) {
+ if (!intent.isUnresolved()) {
+ for (QName constrained : intent.getConstrains()) {
+ if (isConstrained(constrained, attachPointType)) {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
+ throw new PolicyValidationException("Policy Intent '" + intent.getName()
+ + "' does not constrain extension type "
+ + attachPointType.getName());
+ }
+ } else {
+ throw new PolicyValidationException("Policy Intent '" + intent.getName()
+ + "' is not defined in this domain ");
+ }
+ }
+ }
+ }
+
+ public static void validatePolicySets(PolicySetAttachPoint policySetAttachPoint)
+ throws PolicyValidationException {
+ validatePolicySets(policySetAttachPoint, policySetAttachPoint.getApplicablePolicySets());
+ }
+
+ public static void validatePolicySets(PolicySetAttachPoint policySetAttachPoint,
+ List<PolicySet> applicablePolicySets)
+ throws PolicyValidationException {
+ // Since the applicablePolicySets in a policySetAttachPoint will already
+ // have the list of policysets that might ever be applicable to this attachPoint,
+ // just check if the defined policysets feature in the list of applicable
+ // policysets
+ IntentAttachPointType attachPointType = policySetAttachPoint.getType();
+ for (PolicySet definedPolicySet : policySetAttachPoint.getPolicySets()) {
+ if (!definedPolicySet.isUnresolved()) {
+ if (!applicablePolicySets.contains(definedPolicySet)) {
+ throw new PolicyValidationException("Policy Set '" + definedPolicySet
+ .getName()
+ + "' does not apply to binding type "
+ + attachPointType.getName());
+ }
+ } else {
+ throw new PolicyValidationException("Policy Set '" + definedPolicySet.getName()
+ + "' is not defined in this domain ");
+
+ }
}
- return true;
- }*/
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org