You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Simon Laws <si...@googlemail.com> on 2010/07/15 18:35:46 UTC
Re: svn commit: r964064 - in /tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl:
ComponentPolicyBuilderImpl.java CompositePolicyBuilderImpl.java
On Wed, Jul 14, 2010 at 3:42 PM, <bd...@apache.org> wrote:
> Author: bdaniel
> Date: Wed Jul 14 14:42:16 2010
> New Revision: 964064
>
> URL: http://svn.apache.org/viewvc?rev=964064&view=rev
> Log:
> Ignore direct policy sets when external policy sets are attached
>
> Modified:
> tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java
> tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java
>
> Modified: tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java
> URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java?rev=964064&r1=964063&r2=964064&view=diff
> ==============================================================================
> --- tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java (original)
> +++ tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java Wed Jul 14 14:42:16 2010
> @@ -381,6 +381,18 @@ public class ComponentPolicyBuilderImpl
> return null;
> }
>
> + // Replace qualifiable intents with their default qualifier. This can't be done until
> + // after inheritance.
> + protected void expandDefaultIntents(PolicySubject subject, BuilderContext context) {
> +
> + Set<Intent> copy = new HashSet<Intent>(subject.getRequiredIntents());
> + for (Intent i : copy) {
> + if (i.getDefaultQualifiedIntent() != null) {
> + subject.getRequiredIntents().remove(i);
> + subject.getRequiredIntents().add(i.getDefaultQualifiedIntent());
> + }
> + }
> + }
> protected void resolveAndNormalize(PolicySubject subject, BuilderContext context) {
> Definitions definitions = context.getDefinitions();
> Set<Intent> intents = new HashSet<Intent>();
> @@ -422,14 +434,6 @@ public class ComponentPolicyBuilderImpl
>
> }
>
> - // Replace qualifiable intents with the default qualified intent
> - copy = new HashSet<Intent>(intents);
> - for (Intent i : copy) {
> - if (i.getDefaultQualifiedIntent() != null) {
> - intents.remove(i);
> - intents.add(i.getDefaultQualifiedIntent());
> - }
> - }
>
> subject.getRequiredIntents().clear();
> subject.getRequiredIntents().addAll(intents);
> @@ -524,7 +528,9 @@ public class ComponentPolicyBuilderImpl
> // TODO - this could be because the intent is provided by and extension
> // and hence there is no explicit policy set. Need and extra piece
> // of processing to walk through the extension models.
> - warning(context.getMonitor(), "IntentNotSatisfiedAtBuild", subject, intent.getName(), subject.toString());
> +
> + // warning(context.getMonitor(), "IntentNotSatisfiedAtBuild", subject, intent.getName(), subject.toString());
> + error(context.getMonitor(), "IntentNotSatisfiedAtBuild", subject, intent.getName(), subject.toString());
> }
> }
> }
>
> Modified: tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java
> URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java?rev=964064&r1=964063&r2=964064&view=diff
> ==============================================================================
> --- tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java (original)
> +++ tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java Wed Jul 14 14:42:16 2010
> @@ -19,6 +19,8 @@
>
> package org.apache.tuscany.sca.builder.impl;
>
> +import java.util.ArrayList;
> +import java.util.List;
> import java.util.Set;
>
> import javax.xml.namespace.QName;
> @@ -37,6 +39,8 @@ import org.apache.tuscany.sca.assembly.b
> import org.apache.tuscany.sca.core.ExtensionPointRegistry;
> import org.apache.tuscany.sca.monitor.Monitor;
> import org.apache.tuscany.sca.policy.Intent;
> +import org.apache.tuscany.sca.policy.PolicySet;
> +import org.apache.tuscany.sca.policy.PolicySubject;
>
> /**
> * A composite builder that computes policy sets based on attached intents and policy sets.
> @@ -113,9 +117,15 @@ public class CompositePolicyBuilderImpl
> // Replace qualifiable intents with the default qualied intent
> resolveAndNormalize(ep, context);
>
> + // Replace qualifiable intents with their default qualifier
> + expandDefaultIntents(ep, context);
> +
> // Remove the intents whose @contraints do not include the current element
> removeConstrainedIntents(ep, context);
>
> + // Remove any direct policy sets if an external one has been applied
> + removeDirectPolicySetsIfExternalExists(ep, context);
> +
> // check that all intents are resolved
> checkIntentsResolved(ep, context);
>
> @@ -157,9 +167,14 @@ public class CompositePolicyBuilderImpl
> // Replace qualifiable intents with the default qualified intent
> resolveAndNormalize(epr, context);
>
> + // Replace qualifiable intents with their default qualifier
> + expandDefaultIntents(epr, context);
> +
> // Remove the intents whose @contraints do not include the current element
> removeConstrainedIntents(epr, context);
>
> + removeDirectPolicySetsIfExternalExists(epr, context);
> +
> // check that all intents are resolved
> checkIntentsResolved(epr, context);
>
> @@ -183,6 +198,8 @@ public class CompositePolicyBuilderImpl
> // Remove the intents whose @contraints do not include the current element
> removeConstrainedIntents(implementation, context);
>
> + removeDirectPolicySetsIfExternalExists(implementation, context);
> +
> // check that all intents are resolved
> checkIntentsResolved(implementation, context);
> }
> @@ -196,7 +213,26 @@ public class CompositePolicyBuilderImpl
> }
> }
>
> - /**
> + private void removeDirectPolicySetsIfExternalExists(PolicySubject subject,
> + BuilderContext context) {
> + boolean foundExternalPolicySet = false;
> + for (PolicySet ps : subject.getPolicySets() ) {
> + if ( ps.getAttachTo() != null )
> + foundExternalPolicySet = true;
> + }
> +
> + if ( foundExternalPolicySet ) {
> + List<PolicySet> copy = new ArrayList<PolicySet>(subject.getPolicySets());
> + for ( PolicySet ps : copy ) {
> + if ( ps.getAttachTo() == null ) {
> + subject.getPolicySets().remove(ps);
> + }
> + }
> + }
> +
> + }
> +
> + /**
> * This is mainly about removing policies that don't "applyTo" the element where
> * they have ended up after all the attachment and inheritance processing
> *
>
>
>
In the change above which changes the intent warning into and error...
- warning(context.getMonitor(),
"IntentNotSatisfiedAtBuild", subject, intent.getName(),
subject.toString());
+
+ // warning(context.getMonitor(),
"IntentNotSatisfiedAtBuild", subject, intent.getName(),
subject.toString());
+ error(context.getMonitor(),
"IntentNotSatisfiedAtBuild", subject, intent.getName(),
subject.toString());
It looks like we do need to add the code to check the extension to see
if it "provides" the intent before raising the error. I just ran
across this in the async sample that Kelvin's been bringing up where
it fails with this error even though binding.ws does always provide
asyncInvocation.
Simon
--
Apache Tuscany committer: tuscany.apache.org
Co-author of a book about Tuscany and SCA: tuscanyinaction.com
Re: svn commit: r964064 - in /tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl:
ComponentPolicyBuilderImpl.java CompositePolicyBuilderImpl.java
Posted by Brent Daniel <br...@gmail.com>.
This should be resolved now.
Brent
On Thu, Jul 15, 2010 at 9:55 AM, Brent Daniel <br...@gmail.com> wrote:
> On Thu, Jul 15, 2010 at 9:35 AM, Simon Laws <si...@googlemail.com> wrote:
>
>>
>> It looks like we do need to add the code to check the extension to see
>> if it "provides" the intent before raising the error. I just ran
>> across this in the async sample that Kelvin's been bringing up where
>> it fails with this error even though binding.ws does always provide
>> asyncInvocation.
>
>
> I added that piece in 964438, but I think there's still more work to
> do. The extensionType that is present at build time seems to be a
> default one added by CompositeProcessor.read. Only the binding name is
> set. I'm looking into this now, but if we need to revert back to
> issuing a warning for the time being, that's fine.
>
> Brent
>
Re: svn commit: r964064 - in /tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl:
ComponentPolicyBuilderImpl.java CompositePolicyBuilderImpl.java
Posted by Brent Daniel <br...@gmail.com>.
On Thu, Jul 15, 2010 at 9:35 AM, Simon Laws <si...@googlemail.com> wrote:
>
> It looks like we do need to add the code to check the extension to see
> if it "provides" the intent before raising the error. I just ran
> across this in the async sample that Kelvin's been bringing up where
> it fails with this error even though binding.ws does always provide
> asyncInvocation.
I added that piece in 964438, but I think there's still more work to
do. The extensionType that is present at build time seems to be a
default one added by CompositeProcessor.read. Only the binding name is
set. I'm looking into this now, but if we need to revert back to
issuing a warning for the time being, that's fine.
Brent