Hi Raymond, Thanks for the review comments. The 'contractName' property has been necessitated because of the following in the PolicyFwk specs.
984 <component name="xs:NCName"> 985 <implementation.* policySets="listOfQNames" 986 requires="list of intent xs:QNames"> 987 … 988 <operation name="xs:string" *service="xs:string"?* 989 policySets="listOfQNames"? 990 requires="listOfQNames"?/>* 991 … 992 </implementation> 993 … 994 </component> This information needs to be held into some object until we resolve the operation and the service. As for storing 'Operation' instances in Intents, I've been a bit uncomfortable with this for the following reasons.... - all along we only have AttachPoints that refer to intents and policysets. Having Operations inside Intents is going to be a relationship the other way. - as of now we load Intents and PolicySets from the definitions.xml and all attach points only 'refer' to these Intent and PolicySet objects i.e. there could be a service binding and an implementation that could both refer to the same Intent or PolicySet instance (i.e. share a single instance). This sharing has been ok upto now since after loading the Intents and PolicySets are immutable. Storing 'Operations' into Intents and PolicySets could break this. - Even if we stored operations into Intents and PolicySets, we need to resolve them and from what I have seen I don't think Operation model instances are stored in the ModelResolvers. Despite all this, I have decided to give this option a try so that we will have something concrete to discuss about further. I should get something in by today. Thanks - Venkat On Dec 11, 2007 4:14 AM, Raymond Feng <[EMAIL PROTECTED]> wrote: > Hi, > > I see a few issues here: > > 1) The operation-level intents/policySets can be configured under the > service, reference, binding and implementation elements. The contractName > property of ConfiguredOperation interface is not good fit. > > 2) Using name to reference the attach point is not consistent with our > model > because it requires lookup. > > 3) In > org.apache.tuscany.sca.assembly.xml.ConfiguredOperationProcessor.read(), > the > following line won't work because there is no "service" attribute on the > operation element. > configuredOp.setContractName(reader.getAttributeValue(null, SERVICE); > > The model should be designed in such a way so that runtime can easily > calculate the effective policySets for a given context represented as > (component, service/reference, binding, operation) or > (component/implementation, operation). Would it be simpler if we hold the > intents/policySets at the binding (for interaction policies) and component > (for implementation policies)? The intent/policySet could have a pointer > to > the attachpoint & operation. > > Thanks, > Raymond > > ----- Original Message ----- > From: <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Monday, December 10, 2007 12:09 AM > Subject: svn commit: r602804 - 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/ > assembly/src/main/java/org/apache/tuscany/sca/assembly/im... > > > > Author: svkrish > > Date: Mon Dec 10 00:08:47 2007 > > New Revision: 602804 > > > > URL: http://svn.apache.org/viewvc?rev=602804&view=rev > > Log: > > fixing support for policies on operations, removing hack from > > ComponentImpl > > > > Modified: > > > > > 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/CompositeWireBuilderImpl.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/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java > > > > > incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java > > > > > incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaPolicyHandlingRuntimeWireProcessor.java > > > > > incubator/tuscany/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/sca/implementation/java/xml/ReadTestCase.java > > > > 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=602804&r1=602803&r2=602804&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 > > Mon Dec 10 00:08:47 2007 > > @@ -794,21 +794,21 @@ > > //reused and its likely that this implementation > > instance will not hold after its resolution > > > > component.getRequiredIntents > ().addAll(((PolicySetAttachPoint)implementation).getRequiredIntents()); > > > > component.getPolicySets > ().addAll(((PolicySetAttachPoint)implementation).getPolicySets()); > > + if ( implementation instanceof > > OperationsConfigurator ) { > > + > > ((OperationsConfigurator)component).getConfiguredOperations(). > > + > > > addAll(((OperationsConfigurator)implementation).getConfiguredOperations()); > > + > > + for ( ConfiguredOperation op : > > ((OperationsConfigurator)component). > > + > > getConfiguredOperations() ) { > > + resolveIntents(op.getRequiredIntents(), > > resolver); > > + resolvePolicySets(op.getPolicySets(), > > resolver); > > + } > > + > > + } > > } > > > > implementation = resolveImplementation(implementation, > > resolver); > > component.setImplementation(implementation); > > - > > - //need to do this so that component can set the > > configured > > - //operations to the implementation instance > > - implementation = component.getImplementation(); > > - if ( implementation instanceof OperationsConfigurator ) > { > > - OperationsConfigurator opConfigurator = > > (OperationsConfigurator)implementation; > > - for ( ConfiguredOperation op : > > opConfigurator.getConfiguredOperations() ) { > > - resolveIntents(op.getRequiredIntents(), > > resolver); > > - resolvePolicySets(op.getPolicySets(), > resolver); > > - } > > - } > > } > > } > > } > > > > 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=602804&r1=602803&r2=602804&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 > > Mon Dec 10 00:08:47 2007 > > @@ -19,7 +19,6 @@ > > > > package org.apache.tuscany.sca.assembly.builder.impl; > > > > -import java.util.ArrayList; > > import java.util.List; > > > > import javax.xml.namespace.QName; > > > > Modified: > > > incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeWireBuilderImpl.java > > URL: > > > http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeWireBuilderImpl.java?rev=602804&r1=602803&r2=602804&view=diff > > > ============================================================================== > > --- > > > incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeWireBuilderImpl.java > > (original) > > +++ > > > incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeWireBuilderImpl.java > > Mon Dec 10 00:08:47 2007 > > @@ -836,7 +836,7 @@ > > > > bindingPolicyComputer.computeBindingIntentsAndPolicySets(service); > > > > bindingPolicyComputer.determineApplicableBindingPolicySets(service, > null); > > } catch ( Exception e ) { > > - warning("Theres been an exception relation to > policies... > > " + e, e); > > + warning("Theres been an exception related to > policies... > > " + e, e); > > //throw new RuntimeException(e); > > } > > > > @@ -861,7 +861,7 @@ > > > > bindingPolicyComputer.computeBindingIntentsAndPolicySets(reference); > > > > bindingPolicyComputer.determineApplicableBindingPolicySets(reference, > > null); > > } catch ( Exception e ) { > > - warning("Theres been an exception relation to > policies... > > " + e, e); > > + warning("Theres been an exception related to > policies... > > " + e, e); > > //throw new RuntimeException(e); > > } > > } > > @@ -871,7 +871,7 @@ > > try { > > > > implPolicyComputer.computeImplementationIntentsAndPolicySets > (implemenation, > > component); > > } catch ( Exception e ) { > > - warning("Theres been an exception relation to > policies... > > " + e, e); > > + warning("Theres been an exception related to > policies... > > " + e, e); > > //throw new RuntimeException(e); > > } > > > > @@ -907,7 +907,7 @@ > > false); > > } > > } catch ( Exception e ) { > > - warning("Theres been an exception relation to > > policies... " + e, e); > > + warning("Theres been an exception related to > > policies... " + e, e); > > //throw new RuntimeException(e); > > } > > } > > @@ -945,7 +945,7 @@ > > false); > > } > > } catch ( Exception e ) { > > - warning("Theres been an exception relation to > > policies... " + e, e); > > + warning("Theres been an exception related to > > policies... " + e, e); > > //throw new RuntimeException(e); > > } > > } > > > > 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=602804&r1=602803&r2=602804&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 > > Mon Dec 10 00:08:47 2007 > > @@ -54,7 +54,9 @@ > > > > trimInherentlyProvidedIntents(policiedImplementation.getType(), > > parent.getRequiredIntents()); > > > > - > > computeIntentsForOperations((IntentAttachPoint)implementation, > > parent.getRequiredIntents()); > > + computeIntentsForOperations((OperationsConfigurator)parent, > > + > > (IntentAttachPoint)implementation, > > + parent.getRequiredIntents()); > > > > > > List<PolicySet> prunedPolicySets = > > computeInheritablePolicySets(parent, > > @@ -63,7 +65,9 @@ > > parent.getPolicySets().clear(); > > parent.getPolicySets().addAll(prunedPolicySets); > > computePolicySets(parent); > > - computePolicySetsForOperations(parent, > > (PolicySetAttachPoint)implementation); > > + computePolicySetsForOperations(parent, > > + > > (OperationsConfigurator)parent, > > + > > (PolicySetAttachPoint)implementation); > > > > determineApplicableImplementationPolicySets(parent); > > } > > @@ -75,8 +79,8 @@ > > > > //trim intents specified in operations. First check for > > policysets specified on the operation > > //and then in the parent implementation > > - if ( component.getImplementation() instanceof > > OperationsConfigurator ) { > > - OperationsConfigurator opConfigurator = > > (OperationsConfigurator)component.getImplementation(); > > + if ( component instanceof OperationsConfigurator ) { > > + OperationsConfigurator opConfigurator = > > (OperationsConfigurator)component; > > > > for ( ConfiguredOperation confOp : > > opConfigurator.getConfiguredOperations() ) { > > trimProvidedIntents(confOp.getRequiredIntents(), > > confOp.getPolicySets()); > > > > 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=602804&r1=602803&r2=602804&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 > > Mon Dec 10 00:08:47 2007 > > @@ -28,7 +28,6 @@ > > > > import org.apache.tuscany.sca.assembly.Base; > > import org.apache.tuscany.sca.assembly.ConfiguredOperation; > > -import org.apache.tuscany.sca.assembly.Implementation; > > import org.apache.tuscany.sca.assembly.OperationsConfigurator; > > import org.apache.tuscany.sca.policy.Intent; > > import org.apache.tuscany.sca.policy.IntentAttachPoint; > > @@ -52,21 +51,17 @@ > > > > protected List<Intent> > computeInheritableIntents(IntentAttachPointType > > attachPointType, > > List<Intent> > > inheritableIntents) throws PolicyValidationException { > > - //expand profile intents in inherited intents > > List<Intent> validInheritableIntents = new ArrayList<Intent>(); > > - List<Intent> expandedIntents = null; > > - expandedIntents = expandProfileIntents(inheritableIntents); > > - inheritableIntents.clear(); > > - inheritableIntents.addAll(expandedIntents); > > + > > + //expand profile intents in inherited intents > > + expandProfileIntents(inheritableIntents); > > > > //validate if inherited intent applies to the attachpoint > (binding > > / implementation) and > > //only add such intents to the attachpoint (binding / > > implementation) > > for (Intent intent : inheritableIntents) { > > if ( !intent.isUnresolved() ) { > > for (QName constrained : intent.getConstrains()) { > > - if (attachPointType != null && > > attachPointType.getName().getNamespaceURI().equals(constrained > > - .getNamespaceURI()) && > > attachPointType.getName().getLocalPart() > > - .startsWith(constrained.getLocalPart())) { > > + if ( isConstrained(constrained, attachPointType)) { > > validInheritableIntents.add(intent); > > break; > > } > > @@ -79,49 +74,22 @@ > > return validInheritableIntents; > > } > > > > - protected List<Intent> expandProfileIntents(List<Intent> intents) { > > - List<Intent> expandedIntents = new ArrayList<Intent>(); > > - for ( Intent intent : intents ) { > > - if ( intent instanceof ProfileIntent ) { > > - ProfileIntent profileIntent = (ProfileIntent)intent; > > - List<Intent> requiredIntents = > > profileIntent.getRequiredIntents(); > > - > > expandedIntents.addAll(expandProfileIntents(requiredIntents)); > > - } else { > > - expandedIntents.add(intent); > > - } > > + protected void expandProfileIntents(List<Intent> intents) { > > + List<Intent> expandedIntents = null; > > + if ( intents.size() > 0 ) { > > + expandedIntents = findAndExpandProfileIntents(intents); > > + intents.clear(); > > + intents.addAll(expandedIntents); > > } > > - return expandedIntents; > > } > > > > protected void computeIntents(IntentAttachPoint intentAttachPoint) { > > - List<Intent> expandedIntents = null; > > - > > //expand profile intents specified in the attachpoint (binding / > > implementation) > > - if ( intentAttachPoint.getRequiredIntents().size() > 0 ) { > > - expandedIntents = > > expandProfileIntents(intentAttachPoint.getRequiredIntents()); > > - intentAttachPoint.getRequiredIntents().clear(); > > - > > intentAttachPoint.getRequiredIntents().addAll(expandedIntents); > > - } > > - > > - //remove duplicates > > - Map<QName, Intent> intentsTable = new HashMap<QName, Intent>(); > > - for ( Intent intent : intentAttachPoint.getRequiredIntents() ) > { > > - intentsTable.put(intent.getName(), intent); > > - } > > + expandProfileIntents(intentAttachPoint.getRequiredIntents()); > > > > + //remove duplicates and ... > > //where qualified form of intent exists retain it and remove the > > qualifiable intent > > - Map<QName, Intent> intentsTableCopy = new HashMap<QName, > > Intent>(intentsTable); > > - //if qualified form of intent exists remove the unqualified > form > > - for ( Intent intent : intentsTableCopy.values() ) { > > - if ( intent instanceof QualifiedIntent ) { > > - QualifiedIntent qualifiedIntent = > > (QualifiedIntent)intent; > > - if ( > > intentsTable.get(qualifiedIntent.getQualifiableIntent().getName()) != > > null ) { > > - > > intentsTable.remove(qualifiedIntent.getQualifiableIntent().getName()); > > - } > > - } > > - } > > - intentAttachPoint.getRequiredIntents().clear(); > > - > > intentAttachPoint.getRequiredIntents().addAll(intentsTable.values()); > > + filterDuplicatesAndQualifiableIntents(intentAttachPoint); > > } > > > > protected void trimInherentlyProvidedIntents(IntentAttachPointType > > attachPointType, List<Intent>intents) { > > @@ -135,117 +103,64 @@ > > } > > } > > > > - protected boolean isProvidedInherently(IntentAttachPointType > > attachPointType, Intent intent) { > > - return ( attachPointType != null && > > - (( attachPointType.getAlwaysProvidedIntents() != null > && > > - > > attachPointType.getAlwaysProvidedIntents().contains(intent) ) || > > - ( attachPointType.getMayProvideIntents() != null && > > - > > attachPointType.getMayProvideIntents().contains(intent) ) > > - ) ); > > - } > > > > protected void computeIntentsForOperations(IntentAttachPoint > > intentAttachPoint) throws PolicyValidationException { > > - computeIntentsForOperations(intentAttachPoint, > > intentAttachPoint.getRequiredIntents()); > > + if ( intentAttachPoint instanceof OperationsConfigurator ) { > > + > > computeIntentsForOperations((OperationsConfigurator)intentAttachPoint, > > + intentAttachPoint, > > + > > intentAttachPoint.getRequiredIntents()); > > + } > > } > > > > - protected void computeIntentsForOperations(IntentAttachPoint > > intentAttachPoint, List<Intent> parentIntents) throws > > PolicyValidationException { > > - if ( intentAttachPoint instanceof OperationsConfigurator ) { > > - IntentAttachPointType attachPointType = > > intentAttachPoint.getType(); > > + protected void computeIntentsForOperations(OperationsConfigurator > > opConfigurator, > > + IntentAttachPoint > > intentAttachPoint, > > + List<Intent> > > parentIntents) throws PolicyValidationException { > > + IntentAttachPointType attachPointType = > > intentAttachPoint.getType(); > > + > > + boolean found = false; > > + for ( ConfiguredOperation confOp : > > opConfigurator.getConfiguredOperations() ) { > > + //expand profile intents specified on operations > > + expandProfileIntents(confOp.getRequiredIntents()); > > > > - boolean found = false; > > + //validateIntents(confOp, attachPointType); > > > > - OperationsConfigurator opConfigurator = > > (OperationsConfigurator)intentAttachPoint; > > - List<Intent> expandedIntents = null; > > - for ( ConfiguredOperation confOp : > > opConfigurator.getConfiguredOperations() ) { > > - //expand profile intents specified on operations > > - if ( confOp.getRequiredIntents().size() > 0 ) { > > - expandedIntents = > > expandProfileIntents(confOp.getRequiredIntents()); > > - confOp.getRequiredIntents().clear(); > > - confOp.getRequiredIntents > ().addAll(expandedIntents); > > - } > > - > > - if ( attachPointType != null ) { > > - //validate intents specified against the parent > > (binding / implementation) > > - found = false; > > - for (Intent intent : confOp.getRequiredIntents()) { > > - if ( !intent.isUnresolved() ) { > > - for (QName constrained : > > intent.getConstrains()) { > > - if (attachPointType != null && > > attachPointType.getName().getNamespaceURI().equals(constrained > > - .getNamespaceURI()) && > > attachPointType.getName().getLocalPart() > > - > > .startsWith(constrained.getLocalPart())) { > > - found = true; > > - break; > > - } > > - } > > + //add intents specified for parent intent attach point > > (binding / implementation) > > + //wherever its not overriden in the operation > > + Intent tempIntent = null; > > + List<Intent> attachPointOpIntents = new > ArrayList<Intent>(); > > + for (Intent anIntent : parentIntents) { > > + found = false; > > > > - if (!found) { > > - throw new > > PolicyValidationException("Policy Intent '" + intent.getName() > > - + " specified for operation " + > > confOp.getName() > > - + "' does not constrain extension > > type " > > - + attachPointType.getName()); > > - } > > - } else { > > - throw new PolicyValidationException("Policy > > Intent '" + intent.getName() > > - + " specified for operation " + > > confOp.getName() > > - + "' is not defined in this domain "); > > - } > > - } > > + tempIntent = anIntent; > > + while ( tempIntent instanceof QualifiedIntent ) { > > + tempIntent = > > ((QualifiedIntent)tempIntent).getQualifiableIntent(); > > } > > > > - //add intents specified for parent intent attach point > > (binding / implementation) > > - //wherever its not overriden in the operation > > - Intent tempIntent = null; > > - List<Intent> attachPointOpIntents = new > > ArrayList<Intent>(); > > - for (Intent anIntent : parentIntents) { > > - found = false; > > - > > - tempIntent = anIntent; > > - while ( tempIntent instanceof QualifiedIntent ) { > > - tempIntent = > > ((QualifiedIntent)tempIntent).getQualifiableIntent(); > > - } > > - > > - for ( Intent opIntent : confOp.getRequiredIntents() > ) > > { > > - if ( > > opIntent.getName().getLocalPart().startsWith(tempIntent.getName > ().getLocalPart())) > > { > > - found = true; > > - break; > > - } > > - } > > - > > - if ( !found ) { > > - attachPointOpIntents.add(anIntent); > > + for ( Intent opIntent : confOp.getRequiredIntents() ) { > > + if ( > > opIntent.getName().getLocalPart().startsWith(tempIntent.getName > ().getLocalPart())) > > { > > + found = true; > > + break; > > } > > } > > > > - confOp.getRequiredIntents > ().addAll(attachPointOpIntents); > > - > > - //remove duplicates > > - Map<QName, Intent> intentsTable = new HashMap<QName, > > Intent>(); > > - for ( Intent intent : confOp.getRequiredIntents() ) { > > - intentsTable.put(intent.getName(), intent); > > + if ( !found ) { > > + attachPointOpIntents.add(anIntent); > > } > > - > > - //where qualified form of intent exists retain it and > > remove the qualifiable intent > > - Map<QName, Intent> intentsTableCopy = new > HashMap<QName, > > Intent>(intentsTable); > > - //if qualified form of intent exists remove the > > unqualified form > > - for ( Intent intent : intentsTableCopy.values() ) { > > - if ( intent instanceof QualifiedIntent ) { > > - QualifiedIntent qualifiedIntent = > > (QualifiedIntent)intent; > > - if ( > > intentsTable.get(qualifiedIntent.getQualifiableIntent().getName()) != > > null ) { > > - > > intentsTable.remove(qualifiedIntent.getQualifiableIntent().getName()); > > - } > > - } > > - } > > - confOp.getRequiredIntents().clear(); > > - > > confOp.getRequiredIntents().addAll(intentsTable.values()); > > - > > - //exclude intents that are inherently supported by the > > parent > > - //attachpoint-type (binding-type / > implementation-type) > > - if ( attachPointType != null ) { > > - List<Intent> requiredIntents = new > > ArrayList<Intent>(confOp.getRequiredIntents()); > > - for ( Intent intent : requiredIntents ) { > > - if ( isProvidedInherently(attachPointType, > > intent) ) { > > - confOp.getRequiredIntents().remove(intent); > > - } > > + } > > + > > + confOp.getRequiredIntents().addAll(attachPointOpIntents); > > + > > + //remove duplicates and ... > > + //where qualified form of intent exists retain it and > remove > > the qualifiable intent > > + filterDuplicatesAndQualifiableIntents(confOp); > > + > > + //exclude intents that are inherently supported by the > parent > > + //attachpoint-type (binding-type / implementation-type) > > + if ( attachPointType != null ) { > > + List<Intent> requiredIntents = new > > ArrayList<Intent>(confOp.getRequiredIntents()); > > + for ( Intent intent : requiredIntents ) { > > + if ( isProvidedInherently(attachPointType, intent) > ) > > { > > + confOp.getRequiredIntents().remove(intent); > > } > > } > > } > > @@ -286,78 +201,67 @@ > > > > policySetAttachPoint.getPolicySets().addAll(policySetTable.values()); > > > > //expand profile intents > > - List<Intent> expandedIntents = null; > > for ( PolicySet policySet : policySetAttachPoint.getPolicySets() > ) > > { > > - expandedIntents = > > expandProfileIntents(policySet.getProvidedIntents()); > > - policySet.getProvidedIntents().clear(); > > - policySet.getProvidedIntents().addAll(expandedIntents); > > + expandProfileIntents(policySet.getProvidedIntents()); > > } > > } > > > > protected void computePolicySetsForOperations(Base parent, > > PolicySetAttachPoint > > policySetAttachPoint) > > > > throws PolicyValidationException { > > + if ( policySetAttachPoint instanceof OperationsConfigurator ) { > > + computePolicySetsForOperations(parent, > > + > > (OperationsConfigurator)policySetAttachPoint, > > + policySetAttachPoint); > > + } > > + > > + } > > + > > + protected void computePolicySetsForOperations(Base parent, > > + > OperationsConfigurator > > opConfigurator, > > + PolicySetAttachPoint > > policySetAttachPoint) > > + > > throws PolicyValidationException { > > String appliesTo = null; > > String scdlFragment = ""; > > HashMap<QName, PolicySet> policySetTable = new HashMap<QName, > > PolicySet>(); > > IntentAttachPointType attachPointType = > > policySetAttachPoint.getType(); > > > > - if ( policySetAttachPoint instanceof OperationsConfigurator ) { > > - OperationsConfigurator opConfigurator = > > (OperationsConfigurator)policySetAttachPoint; > > - > > - for ( ConfiguredOperation confOp : > > opConfigurator.getConfiguredOperations() ) { > > - //validate policysets specified for the attachPoint > > - for (PolicySet policySet : confOp.getPolicySets()) { > > - if ( !policySet.isUnresolved() ) { > > - appliesTo = policySet.getAppliesTo(); > > - > > - if > > (!PolicyValidationUtils.isPolicySetApplicable(scdlFragment, appliesTo, > > attachPointType)) { > > - throw new PolicyValidationException("Policy > > Set '" + policySet.getName() > > - + " specified for operation " + > > confOp.getName() > > - + "' does not constrain extension type > " > > - + attachPointType.getName()); > > - > > - } > > - } else { > > + for ( ConfiguredOperation confOp : > > opConfigurator.getConfiguredOperations() ) { > > + //validate policysets specified for the attachPoint > > + for (PolicySet policySet : confOp.getPolicySets()) { > > + if ( !policySet.isUnresolved() ) { > > + appliesTo = policySet.getAppliesTo(); > > + > > + if > > (!PolicyValidationUtils.isPolicySetApplicable(scdlFragment, appliesTo, > > attachPointType)) { > > throw new PolicyValidationException("Policy Set > '" > > + policySet.getName() > > + " specified for operation " + > > confOp.getName() > > - + "' is not defined in this domain "); > > + + "' does not constrain extension type " > > + + attachPointType.getName()); > > + > > } > > + } else { > > + throw new PolicyValidationException("Policy Set '" > + > > policySet.getName() > > + + " specified for operation " + > > confOp.getName() > > + + "' is not defined in this domain "); > > } > > - > > - //get rid of duplicate entries > > - for ( PolicySet policySet : confOp.getPolicySets() ) { > > - policySetTable.put(policySet.getName(), policySet); > > - } > > + } > > > > - confOp.getPolicySets().clear(); > > - confOp.getPolicySets().addAll(policySetTable.values()); > > - > > - //expand profile intents > > - List<Intent> expandedIntents = null; > > - for ( PolicySet policySet : confOp.getPolicySets() ) { > > - expandedIntents = > > expandProfileIntents(policySet.getProvidedIntents()); > > - policySet.getProvidedIntents().clear(); > > - > > policySet.getProvidedIntents().addAll(expandedIntents); > > - } > > + //get rid of duplicate entries > > + for ( PolicySet policySet : confOp.getPolicySets() ) { > > + policySetTable.put(policySet.getName(), policySet); > > } > > - } > > - } > > - > > - protected void trimProvidedIntents(List<Intent> requiredIntents, > > PolicySet policySet) { > > - for ( Intent providedIntent : policySet.getProvidedIntents() ) > { > > - if ( requiredIntents.contains(providedIntent) ) { > > - requiredIntents.remove(providedIntent); > > - } > > - } > > > > - for ( Intent mappedIntent : > > policySet.getMappedPolicies().keySet() ) { > > - if ( requiredIntents.contains(mappedIntent) ) { > > - requiredIntents.remove(mappedIntent); > > - } > > + confOp.getPolicySets().clear(); > > + confOp.getPolicySets().addAll(policySetTable.values()); > > + > > + //expand profile intents > > + for ( PolicySet policySet : confOp.getPolicySets() ) { > > + expandProfileIntents(policySet.getProvidedIntents()); > > + } > > } > > } > > > > + > > protected void trimProvidedIntents(List<Intent> requiredIntents, > > List<PolicySet> policySets) { > > for ( PolicySet policySet : policySets ) { > > trimProvidedIntents(requiredIntents, policySet); > > @@ -378,6 +282,100 @@ > > if (prevSize != > > policySetAttachPoint.getRequiredIntents().size()) { > > > > policySetAttachPoint.getPolicySets().add(policySet); > > } > > + } > > + } > > + } > > + } > > + > > + private List<Intent> findAndExpandProfileIntents(List<Intent> > > intents) { > > + List<Intent> expandedIntents = new ArrayList<Intent>(); > > + for ( Intent intent : intents ) { > > + if ( intent instanceof ProfileIntent ) { > > + ProfileIntent profileIntent = (ProfileIntent)intent; > > + List<Intent> requiredIntents = > > profileIntent.getRequiredIntents(); > > + > > expandedIntents.addAll(findAndExpandProfileIntents(requiredIntents)); > > + } else { > > + expandedIntents.add(intent); > > + } > > + } > > + return expandedIntents; > > + } > > + > > + private boolean isProvidedInherently(IntentAttachPointType > > attachPointType, Intent intent) { > > + return ( attachPointType != null && > > + (( attachPointType.getAlwaysProvidedIntents() != null > && > > + > > attachPointType.getAlwaysProvidedIntents().contains(intent) ) || > > + ( attachPointType.getMayProvideIntents() != null && > > + > > attachPointType.getMayProvideIntents().contains(intent) ) > > + ) ); > > + } > > + > > + private void trimProvidedIntents(List<Intent> requiredIntents, > > PolicySet policySet) { > > + for ( Intent providedIntent : policySet.getProvidedIntents() ) > { > > + if ( requiredIntents.contains(providedIntent) ) { > > + requiredIntents.remove(providedIntent); > > + } > > + } > > + > > + for ( Intent mappedIntent : > > policySet.getMappedPolicies().keySet() ) { > > + if ( requiredIntents.contains(mappedIntent) ) { > > + requiredIntents.remove(mappedIntent); > > + } > > + } > > + } > > + > > + 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>(); > > + for ( Intent intent : intentAttachPoint.getRequiredIntents() ) > { > > + intentsTable.put(intent.getName(), intent); > > + } > > + > > + //where qualified form of intent exists retain it and remove > the > > qualifiable intent > > + Map<QName, Intent> intentsTableCopy = new HashMap<QName, > > Intent>(intentsTable); > > + //if qualified form of intent exists remove the unqualified > form > > + for ( Intent intent : intentsTableCopy.values() ) { > > + if ( intent instanceof QualifiedIntent ) { > > + QualifiedIntent qualifiedIntent = > > (QualifiedIntent)intent; > > + if ( > > intentsTable.get(qualifiedIntent.getQualifiableIntent().getName()) != > > null ) { > > + > > intentsTable.remove(qualifiedIntent.getQualifiableIntent().getName()); > > + } > > + } > > + } > > + intentAttachPoint.getRequiredIntents().clear(); > > + > > intentAttachPoint.getRequiredIntents().addAll(intentsTable.values()); > > + } > > + > > + private void validateIntents(ConfiguredOperation confOp, > > IntentAttachPointType attachPointType) throws PolicyValidationException > { > > + boolean found = false; > > + if ( attachPointType != null ) { > > + //validate intents specified against the parent (binding / > > implementation) > > + found = false; > > + for (Intent intent : confOp.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() > > + + " specified for operation " + > > confOp.getName() > > + + "' does not constrain extension type " > > + + attachPointType.getName()); > > + } > > + } else { > > + throw new PolicyValidationException("Policy Intent > '" > > + intent.getName() > > + + " specified for operation " + > > confOp.getName() > > + + "' is not defined in this domain "); > > } > > } > > } > > > > Modified: > > > incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java > > URL: > > > http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java?rev=602804&r1=602803&r2=602804&view=diff > > > ============================================================================== > > --- > > > incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java > > (original) > > +++ > > > incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java > > Mon Dec 10 00:08:47 2007 > > @@ -39,7 +39,7 @@ > > * > > * @version $Rev$ $Date$ > > */ > > -public class ComponentImpl extends ExtensibleImpl implements Component, > > Cloneable { > > +public class ComponentImpl extends ExtensibleImpl implements Component, > > Cloneable, OperationsConfigurator { > > private ConstrainingType constrainingType; > > private Implementation implementation; > > private String name; > > @@ -51,13 +51,7 @@ > > private List<PolicySet> policySets = new ArrayList<PolicySet>(); > > private Boolean autowire; > > private IntentAttachPointType type; > > - > > - private PolicySetAttachPoint implPolicyConf = new > > PolicySetAttachPointImpl(); > > - private List<ConfiguredOperation> configuredImplOps = new > > ArrayList<ConfiguredOperation>(); > > - //private PolicyContext policyContext = new PolicyContextImpl(); > > - //private Map<String, Object> policyContext = new Hashtable<String, > > Object>(); > > - //String IMPL_POLICY_CONTEXT = "IMPL_POLICY_CONTEXT"; > > - //String IMPL_OPERATIONS_POLICY_CONTEXT = > > "IMPL_OPERATIONS_POLICY_CONTEXT"; > > + private List<ConfiguredOperation> configuredImplOperations = new > > ArrayList<ConfiguredOperation>(); > > > > /** > > * Constructs a new component. > > @@ -97,16 +91,6 @@ > > } > > > > public Implementation getImplementation() { > > - if ( implementation instanceof PolicySetAttachPoint ) { > > - PolicySetAttachPoint policiedImpl = > > (PolicySetAttachPoint)implementation; > > - > > - > > /*policiedImpl.setRequiredIntents(implPolicyConf.getRequiredIntents()); > > - policiedImpl.setPolicySets(implPolicyConf.getPolicySets > ());*/ > > - > > - if ( implementation instanceof OperationsConfigurator ) { > > - > > > ((OperationsConfigurator)implementation).setConfiguredOperations(configuredImplOps); > > - } > > - } > > return implementation; > > } > > > > @@ -132,21 +116,6 @@ > > > > public void setImplementation(Implementation implementation) { > > this.implementation = implementation; > > - if ( implementation instanceof PolicySetAttachPoint > > - && implementation.isUnresolved() ) { > > - /*PolicySetAttachPoint policiedImpl = > > (PolicySetAttachPoint)implementation; > > - > > implPolicyConf.getRequiredIntents().addAll( > policiedImpl.getRequiredIntents()); > > - > > implPolicyConf.getPolicySets().addAll(policiedImpl.getPolicySets()); > > - */ > > - if ( implementation instanceof OperationsConfigurator ) { > > - OperationsConfigurator operationConfig = > > (OperationsConfigurator)implementation; > > - > > - if ( operationConfig.getConfiguredOperations() != null > && > > - > > !operationConfig.getConfiguredOperations().isEmpty() ) { > > - > > configuredImplOps.addAll(operationConfig.getConfiguredOperations()); > > - } > > - } > > - } > > } > > > > public void setName(String name) { > > @@ -190,6 +159,15 @@ > > this.requiredIntents = intents; > > > > } > > + > > + public List<ConfiguredOperation> getConfiguredOperations() { > > + return configuredImplOperations; > > + } > > + > > + public void setConfiguredOperations(List<ConfiguredOperation> > > configuredOperations) { > > + this.configuredImplOperations = configuredOperations; > > + } > > + > > > > private class PolicySetAttachPointImpl implements > PolicySetAttachPoint > > { > > private List<Intent> requiredIntents = new ArrayList<Intent>(); > > > > Modified: > > > incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java > > URL: > > > http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java?rev=602804&r1=602803&r2=602804&view=diff > > > ============================================================================== > > --- > > > incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java > > (original) > > +++ > > > incubator/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java > > Mon Dec 10 00:08:47 2007 > > @@ -126,14 +126,6 @@ > > this.requiredIntents = intents; > > } > > > > - public List<ConfiguredOperation> getConfiguredOperations() { > > - return configuredOperations; > > - } > > - > > - public void setConfiguredOperations(List<ConfiguredOperation> > > configuredOperations) { > > - this.configuredOperations = configuredOperations; > > - } > > - > > @Override > > public int hashCode() { > > return String.valueOf(getURI()).hashCode(); > > @@ -154,5 +146,13 @@ > > return false; > > } > > } > > + } > > + > > + public List<ConfiguredOperation> getConfiguredOperations() { > > + return configuredOperations; > > + } > > + > > + public void setConfiguredOperations(List<ConfiguredOperation> > > configuredOperations) { > > + this.configuredOperations = configuredOperations; > > } > > } > > > > Modified: > > > incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaPolicyHandlingRuntimeWireProcessor.java > > URL: > > > http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaPolicyHandlingRuntimeWireProcessor.java?rev=602804&r1=602803&r2=602804&view=diff > > > ============================================================================== > > --- > > > incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaPolicyHandlingRuntimeWireProcessor.java > > (original) > > +++ > > > incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaPolicyHandlingRuntimeWireProcessor.java > > Mon Dec 10 00:08:47 2007 > > @@ -80,7 +80,7 @@ > > applicablePolicyHandlers = new > > ArrayList<PolicyHandler>(); > > if ( javaImpl instanceof OperationsConfigurator > ) > > { > > String operationName = > > chain.getTargetOperation().getName(); > > - OperationsConfigurator opConfigurator = > > (OperationsConfigurator)javaImpl; > > + OperationsConfigurator opConfigurator = > > (OperationsConfigurator)component; > > for ( ConfiguredOperation confOp : > > opConfigurator.getConfiguredOperations() ) { > > if ( > > confOp.getName().equals(operationName)) { > > for ( PolicySet policySet : > > confOp.getPolicySets() ) { > > > > 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=602804&r1=602803&r2=602804&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 > > Mon Dec 10 00:08:47 2007 > > @@ -170,7 +170,7 @@ > > } > > > > //test for proper aggregation of policy intents and policysets > on > > operations of implementation > > - OperationsConfigurator opConf = > > > (OperationsConfigurator)composite.getComponents().get(5).getImplementation(); > > + OperationsConfigurator opConf = > > (OperationsConfigurator)composite.getComponents().get(5); > > > > assertEquals(opConf.getConfiguredOperations > ().get(0).getRequiredIntents().size(), > > 4); > > for ( Intent intent : > > opConf.getConfiguredOperations().get(0).getRequiredIntents()) { > > String intentName = intent.getName().getLocalPart(); > > @@ -180,7 +180,7 @@ > > } > > } > > > > - opConf = > > > (OperationsConfigurator)composite.getComponents().get(6).getImplementation(); > > + opConf = > > (OperationsConfigurator)composite.getComponents().get(6); > > > > assertEquals(opConf.getConfiguredOperations > ().get(0).getRequiredIntents().size(), > > 3); > > for ( Intent intent : > > opConf.getConfiguredOperations().get(0).getRequiredIntents()) { > > String intentName = intent.getName().getLocalPart(); > > @@ -238,7 +238,7 @@ > > } > > > > //test for computation of policysets on operations of > > implementation > > - OperationsConfigurator opConf = > > > (OperationsConfigurator)composite.getComponents().get(5).getImplementation(); > > + OperationsConfigurator opConf = > > (OperationsConfigurator)composite.getComponents().get(5); > > > > assertEquals(opConf.getConfiguredOperations > ().get(0).getPolicySets().size(), > > 3); > > for ( PolicySet policySet : > > opConf.getConfiguredOperations().get(0).getPolicySets() ) { > > String policySetName = policySet.getName().getLocalPart(); > > @@ -248,7 +248,7 @@ > > } > > } > > > > - opConf = > > > (OperationsConfigurator)composite.getComponents().get(6).getImplementation(); > > + opConf = > > (OperationsConfigurator)composite.getComponents().get(6); > > > > assertEquals(opConf.getConfiguredOperations > ().get(0).getPolicySets().size(), > > 3); > > for ( PolicySet policySet : > > opConf.getConfiguredOperations().get(0).getPolicySets() ) { > > String policySetName = policySet.getName().getLocalPart(); > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
