diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca')
3 files changed, 160 insertions, 549 deletions
diff --git a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java index a69955e113..46ff781847 100644 --- a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java +++ b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java @@ -153,14 +153,8 @@ public class ComponentBuilderImpl { // configure services based on the calculated component type configureReferences(component, context); - // Inherit the intents and policySets from the componentType // NOTE: configureServices/configureReferences may add callback references and services - for(ComponentReference componentReference: component.getReferences()) { - policyBuilder.configure(componentReference, context); - } - for(ComponentService componentService: component.getServices()) { - policyBuilder.configure(componentService, context); - } + policyBuilder.configure(component, context); } finally { monitor.popContext(); diff --git a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java index afe694ad75..5e89240965 100644 --- a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java +++ b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java @@ -20,24 +20,29 @@ package org.apache.tuscany.sca.builder.impl; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; import javax.xml.namespace.QName; +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.CompositeReference; import org.apache.tuscany.sca.assembly.CompositeService; +import org.apache.tuscany.sca.assembly.Contract; +import org.apache.tuscany.sca.assembly.Reference; +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.core.ExtensionPointRegistry; import org.apache.tuscany.sca.definitions.Definitions; import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.monitor.Problem.Severity; import org.apache.tuscany.sca.policy.Intent; import org.apache.tuscany.sca.policy.IntentMap; import org.apache.tuscany.sca.policy.PolicyExpression; @@ -69,16 +74,7 @@ public class ComponentPolicyBuilderImpl { * @param model */ protected void warning(Monitor monitor, String message, Object model, Object... messageParameters) { - if (monitor != null) { - Problem problem = - monitor.createProblem(this.getClass().getName(), - Messages.ASSEMBLY_VALIDATION, - Severity.WARNING, - model, - message, - messageParameters); - monitor.problem(problem); - } + Monitor.warning(monitor, this, Messages.ASSEMBLY_VALIDATION, message, messageParameters); } /** @@ -90,30 +86,39 @@ public class ComponentPolicyBuilderImpl { * @param model */ protected void error(Monitor monitor, String message, Object model, Object... messageParameters) { - if (monitor != null) { - Problem problem = - monitor.createProblem(this.getClass().getName(), - Messages.ASSEMBLY_VALIDATION, - Severity.ERROR, - model, - message, - messageParameters); - monitor.problem(problem); - } + Monitor.error(monitor, this, Messages.ASSEMBLY_VALIDATION, message, messageParameters); } /** * Inherit the intents and policySets from the list of models + * @param ignoreExclusiveIntents TODO + * @param models * @param intents * @param policySets - * @param models */ - protected void inherit(PolicySubject policySubject, Object... models) { + protected void inherit(PolicySubject policySubject, boolean ignoreExclusiveIntents, Object... models) { for (Object model : models) { if (model instanceof PolicySubject) { PolicySubject subject = (PolicySubject)model; - // FIXME: We should ignore the mutually exclusive intents from different levels - policySubject.getRequiredIntents().addAll(subject.getRequiredIntents()); + + if (ignoreExclusiveIntents) { + policySubject.getRequiredIntents().addAll(subject.getRequiredIntents()); + } else { + Set<Intent> intents = new HashSet<Intent>(); + for (Intent i1 : subject.getRequiredIntents()) { + boolean exclusive = false; + for (Intent i2 : policySubject.getRequiredIntents()) { + if (i1.getExcludedIntents().contains(i2) || i2.getExcludedIntents().contains(i1)) { + exclusive = true; + break; + } + } + if (!exclusive) { + intents.add(i1); + } + } + policySubject.getRequiredIntents().addAll(intents); + } policySubject.getPolicySets().addAll(subject.getPolicySets()); } } @@ -126,16 +131,40 @@ public class ComponentPolicyBuilderImpl { if (subject2 != null) { resolveAndCheck(subject2, context); } - inherit(subject1, subject2); + inherit(subject1, false, subject2); checkMutualExclusion(subject1, context); } protected void configure(ComponentService componentService, BuilderContext context) { - configure(componentService, componentService.getService(), context); + Service service = componentService.getService(); + if (service != null) { + configure(componentService, service, context); + configureBindings(componentService, service, context); + } + } + + private void configureBindings(Contract componentContract, Contract componentTypeContract, BuilderContext context) { + if (componentTypeContract == null) { + return; + } + Map<String, Binding> componentTypeContractBindings = new HashMap<String, Binding>(); + for (Binding binding : componentTypeContract.getBindings()) { + componentTypeContractBindings.put(binding.getName(), binding); + } + for (Binding binding : componentContract.getBindings()) { + Binding componentTypeBinding = componentTypeContractBindings.get(binding.getName()); + if (binding instanceof PolicySubject) { + inherit((PolicySubject)binding, false, componentTypeBinding, context); + } + } } protected void configure(ComponentReference componentReference, BuilderContext context) { - configure(componentReference, componentReference.getReference(), context); + Reference reference = componentReference.getReference(); + if (reference != null) { + configure(componentReference, reference, context); + configureBindings(componentReference, reference, context); + } } protected void configure(CompositeService compositeService, BuilderContext context) { @@ -148,6 +177,18 @@ public class ComponentPolicyBuilderImpl { } } + public void configure(Component component, BuilderContext context) { + // Inherit the intents and policySets from the componentType + configure(component, component.getImplementation(), context); + // Inherit the intents and policySets from the componentType + for (ComponentReference componentReference : component.getReferences()) { + configure(componentReference, context); + } + for (ComponentService componentService : component.getServices()) { + configure(componentService, context); + } + } + /** * Check if a single policy subject requires multually exclusive intents * @param subject1 - the policy subject to check @@ -229,7 +270,7 @@ public class ComponentPolicyBuilderImpl { } } - protected Intent resolve(Definitions definitions, Intent proxy) { + protected static Intent resolve(Definitions definitions, Intent proxy) { for (Intent i : definitions.getIntents()) { if (i.equals(proxy)) { return i; diff --git a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java index 1956d25d1d..41afd8c3cf 100644 --- a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java +++ b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java @@ -19,42 +19,21 @@ package org.apache.tuscany.sca.builder.impl; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - import javax.xml.namespace.QName; -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.Endpoint; import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.assembly.Reference; -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.CompositeBuilder; import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; -import org.apache.tuscany.sca.assembly.builder.Messages; import org.apache.tuscany.sca.assembly.builder.PolicyBuilder; import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.definitions.Definitions; import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.monitor.Problem.Severity; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.IntentMap; -import org.apache.tuscany.sca.policy.PolicyExpression; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySubject; -import org.apache.tuscany.sca.policy.Qualifier; /** * A composite builder that computes policy sets based on attached intents and policy sets. @@ -63,56 +42,12 @@ import org.apache.tuscany.sca.policy.Qualifier; * * @version $Rev$ $Date$ */ -public class CompositePolicyBuilderImpl implements CompositeBuilder { - - protected BuilderExtensionPoint builders; - - public CompositePolicyBuilderImpl(ExtensionPointRegistry registry) { - this.builders = registry.getExtensionPoint(BuilderExtensionPoint.class); - } +public class CompositePolicyBuilderImpl extends ComponentPolicyBuilderImpl implements CompositeBuilder { - /** - * Report a warning. - * - * @param monitor - * @param problems - * @param message - * @param model - */ - protected void warning(Monitor monitor, String message, Object model, Object... messageParameters) { - if (monitor != null) { - Problem problem = - monitor.createProblem(this.getClass().getName(), - Messages.ASSEMBLY_VALIDATION, - Severity.WARNING, - model, - message, - messageParameters); - monitor.problem(problem); - } + public CompositePolicyBuilderImpl(ExtensionPointRegistry registry) { + super(registry); } - /** - * Report a error. - * - * @param monitor - * @param problems - * @param message - * @param model - */ - private void error(Monitor monitor, String message, Object model, Object... messageParameters) { - if (monitor != null) { - Problem problem = - monitor.createProblem(this.getClass().getName(), - Messages.ASSEMBLY_VALIDATION, - Severity.ERROR, - model, - message, - messageParameters); - monitor.problem(problem); - } - } - public String getID() { return "org.apache.tuscany.sca.assembly.builder.CompositePolicyBuilder"; } @@ -123,469 +58,110 @@ public class CompositePolicyBuilderImpl implements CompositeBuilder { return composite; } - /** - * Inherit the intents and policySets from the list of models - * @param intents - * @param policySets - * @param models - */ - private void inherit(PolicySubject policySubject, Object... models) { - for (Object model : models) { - if (model instanceof PolicySubject) { - PolicySubject subject = (PolicySubject)model; - // FIXME: We should ignore the mutually exclusive intents from different levels - policySubject.getRequiredIntents().addAll(subject.getRequiredIntents()); - policySubject.getPolicySets().addAll(subject.getPolicySets()); - } - } - } + protected void computePolicies(Composite composite, BuilderContext context) { + Monitor monitor = context.getMonitor(); + monitor.pushContext("Composite: " + composite.getName().toString()); - /** - * Check if a single policy subject requires multually exclusive intents - * @param subject1 - the policy subject to check - * @param context - context containing useful things like the monitor instance - * @return true if the policy subject contains mutually exclusive intents - */ - private boolean checkMutualExclusion(PolicySubject subject1, BuilderContext context) { - if (subject1 == null) { - return false; - } - for (Intent i1 : subject1.getRequiredIntents()) { - for (Intent i2 : subject1.getRequiredIntents()) { - if ((i1 != i2) && - (i1.getExcludedIntents().contains(i2) || i2.getExcludedIntents().contains(i1))) { - error(context.getMonitor(), "MutuallyExclusiveIntents", new Object[] {subject1}, i1, i2); - return true; - } - } - } - return false; - } - - /** - * Check if two policy subjects requires multually exclusive intents - * @param subject1 - * @param subject2 - * @param monitor - * @return - */ - private boolean checkMutualExclusion(PolicySubject subject1, PolicySubject subject2, BuilderContext context) { - if (subject1 == subject2 || subject1 == null || subject2 == null) { - return false; - } - for (Intent i1 : subject1.getRequiredIntents()) { - for (Intent i2 : subject2.getRequiredIntents()) { - if (i1.getExcludedIntents().contains(i2) || i2.getExcludedIntents().contains(i1)) { - error(context.getMonitor(), "MutuallyExclusiveIntents", new Object[] {subject1, subject2}, i1, i2); - return true; - } - } - } - return false; - } + try { + resolveAndCheck(composite, context); - private boolean resolveAndCheck(PolicySubject subject, BuilderContext context) { - if (subject == null) { - return false; - } - // FIXME: [rfeng] Should we resolve the intents during the "build" phase? - resolveAndNormalize(subject, context); - List<Intent> intents = subject.getRequiredIntents(); - int size = intents.size(); - for (int i = 0; i < size; i++) { - for (int j = i + 1; j < size; j++) { - Intent i1 = intents.get(i); - Intent i2 = intents.get(j); - if (i1 != i2 && i1.getExcludedIntents().contains(i2) || i2.getExcludedIntents().contains(i1)) { - error(context.getMonitor(), "MutuallyExclusiveIntents", subject, i1, i2); - return true; - } - } - } - return false; - } + // compute policies recursively + for (Component component : composite.getComponents()) { + monitor.pushContext("Component: " + component.getName()); - /** - * Inherit the policySets and intents from the implementation hierarchy - * @param subject - * @param composite - * @param component - * @param service - */ - private void inheritFromService(PolicySubject subject, Composite composite, Component component, Service service) { - if (service == null) { - return; - } - if (service instanceof ComponentService) { - // component!=null - if (component.getImplementation() instanceof Composite) { - composite = (Composite)component.getImplementation(); - } - inheritFromService(subject, composite, component, ((ComponentService)service).getService()); - // Component service also inherits the intents/policySets from composite/component - inherit(subject, composite, component); - } else if (service instanceof CompositeService) { - // composite!=null, component is not used - CompositeService compositeService = (CompositeService)service; - // Handle the promoted component service - inheritFromService(subject, composite, compositeService.getPromotedComponent(), compositeService - .getPromotedService()); - } - // For atomic service, the composite is not used - inherit(subject, component.getImplementation(), service); - } + try { + Implementation implementation = component.getImplementation(); - /** - * Inherit the policySets and intents from the implementation hierarchy - * @param subject - * @param composite - * @param component - * @param reference - */ - private void inheritFromReference(PolicySubject subject, - Composite composite, - Component component, - Reference reference) { - if (reference == null) { - return; - } - if (reference instanceof ComponentReference) { - // component!=null - if (component.getImplementation() instanceof Composite) { - composite = (Composite)component.getImplementation(); - } - inheritFromReference(subject, composite, component, ((ComponentReference)reference).getReference()); - } else if (reference instanceof CompositeReference) { - CompositeReference compositeReference = (CompositeReference)reference; - for (int i = 0, n = compositeReference.getPromotedReferences().size(); i < n; i++) { - inheritFromReference(subject, - composite, - compositeReference.getPromotedComponents().get(i), - compositeReference.getPromotedReferences().get(i)); - } - } - // Inherit from the componentType/reference - inherit(subject, component.getImplementation(), reference); - } + for (ComponentService componentService : component.getServices()) { + monitor.pushContext("Service: " + componentService.getName()); - /** - * Check if two names are equal - * @param name1 - * @param name2 - * @return - */ - private boolean isEqual(String name1, String name2) { - if (name1 == name2) { - return true; - } - if (name1 != null) { - return name1.equals(name2); - } else { - return name2.equals(name1); - } - } + try { + resolveAndCheck(componentService, context); - private Intent resolve(Definitions definitions, Intent proxy) { - for (Intent i : definitions.getIntents()) { - if (i.equals(proxy)) { - return i; - } - for (Intent qi : i.getQualifiedIntents()) { - if (qi.equals(proxy)) { - return qi; - } - } - } - return null; - } + if (componentService.getInterfaceContract() != null) { + resolveAndCheck(componentService.getInterfaceContract().getInterface(), context); - private void resolveAndNormalize(PolicySubject subject, BuilderContext context) { - Definitions definitions = context.getDefinitions(); - Set<Intent> intents = new HashSet<Intent>(); - if (definitions != null) { - for (Intent i : subject.getRequiredIntents()) { - Intent resolved = resolve(definitions, i); - if (resolved != null) { - intents.add(resolved); - } else { - warning(context.getMonitor(), "IntentNotFound", subject, i); - // Intent cannot be resolved - } - } - } + resolveAndCheck(componentService.getInterfaceContract().getCallbackInterface(), context); - // Replace profile intents with their required intents - while (!intents.isEmpty()) { - boolean profileIntentsFound = false; - Set<Intent> copy = new HashSet<Intent>(intents); - for (Intent i : copy) { - if (!i.getRequiredIntents().isEmpty()) { - intents.remove(i); - intents.addAll(i.getRequiredIntents()); - profileIntentsFound = true; - } - } - if (!profileIntentsFound) { - // No more profileIntents - break; - } - } - - // Remove the intents whose @contraints do not include the current element - // Replace unqualified intents if there is a qualified intent in the list - Set<Intent> copy = new HashSet<Intent>(intents); - for (Intent i : copy) { - if (i.getQualifiableIntent() != null) { - intents.remove(i.getQualifiableIntent()); - } - } + } - // 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()); - } - } + for (Endpoint ep : componentService.getEndpoints()) { + if (componentService.getInterfaceContract() != null) { + // Inherit from the component.service.interface + inherit(ep, true, componentService.getInterfaceContract().getInterface()); + } + // Inherit from composite/component/service + inherit(ep, true, composite, ep.getComponent(), ep.getService()); + // Inherit from binding + inherit(ep, true, ep.getBinding()); - subject.getRequiredIntents().clear(); - subject.getRequiredIntents().addAll(intents); - - Set<PolicySet> policySets = new HashSet<PolicySet>(); - if (definitions != null) { - for (PolicySet policySet : subject.getPolicySets()) { - int index = definitions.getPolicySets().indexOf(policySet); - if (index != -1) { - policySets.add(definitions.getPolicySets().get(index)); - } else { - // PolicySet cannot be resolved - warning(context.getMonitor(), "PolicySetNotFound", subject, policySet); - } - } - } + // Replace profile intents with their required intents + // Remove the intents whose @contraints do not include the current element + // Replace unqualified intents if there is a qualified intent in the list + // Replace qualifiable intents with the default qualied intent + resolveAndNormalize(ep, context); - for (Intent intent : subject.getRequiredIntents()) { - loop: for (PolicySet ps : definitions.getPolicySets()) { - // FIXME: We will have to check the policy references and intentMap too - // as well as the appliesTo - if (ps.getProvidedIntents().contains(intent)) { - policySets.add(ps); - break; - } - for (IntentMap map : ps.getIntentMaps()) { - for (Qualifier q : map.getQualifiers()) { - if (intent.equals(q.getIntent())) { - policySets.add(ps); - break loop; + // check that the resulting endpoint has no mutually exclusive intents + checkMutualExclusion(ep, context); + } + } finally { + monitor.popContext(); } } - } - } - } - subject.getPolicySets().clear(); - subject.getPolicySets().addAll(policySets); + for (ComponentReference componentReference : component.getReferences()) { + monitor.pushContext("Reference: " + componentReference.getName().toString()); - } + try { - protected void computePolicies(Composite composite, BuilderContext context) { - Monitor monitor = context.getMonitor(); - monitor.pushContext("Composite: " + composite.getName().toString()); - - try { - resolveAndCheck(composite, context); - - for (Service service : composite.getServices()) { - CompositeService compositeService = (CompositeService)service; - checkMutualExclusion(compositeService, compositeService.getPromotedService(), context); - } - - for (Reference reference : composite.getReferences()) { - CompositeReference compositeReference = (CompositeReference)reference; - for (Reference promoted : compositeReference.getPromotedReferences()) { - checkMutualExclusion(compositeReference, promoted, context); - } - } - - // compute policies recursively - for (Component component : composite.getComponents()) { - monitor.pushContext("Component: " + component.getName().toString()); - - try { - Implementation implementation = component.getImplementation(); - resolveAndCheck(component, context); - - // Check component against implementation - checkMutualExclusion(component, component.getImplementation(), context); - - for (ComponentService componentService : component.getServices()) { - monitor.pushContext("Service: " + componentService.getName().toString()); - - try { - resolveAndCheck(componentService, context); - resolveAndCheck(componentService.getService(), context); - - // Check component/service against componentType/service - checkMutualExclusion(componentService, componentService.getService(), context); - - if (componentService.getInterfaceContract() != null && componentService.getService() != null) { - resolveAndCheck(componentService.getInterfaceContract().getInterface(), context); - resolveAndCheck(componentService.getService().getInterfaceContract().getInterface(), context); - - checkMutualExclusion(componentService.getInterfaceContract().getInterface(), componentService - .getService().getInterfaceContract().getInterface(), context); - - resolveAndCheck(componentService.getInterfaceContract().getCallbackInterface(), context); - resolveAndCheck(componentService.getService().getInterfaceContract().getCallbackInterface(), - context); - - checkMutualExclusion(componentService.getInterfaceContract().getCallbackInterface(), - componentService.getService().getInterfaceContract().getCallbackInterface(), - context); - } - - for (Endpoint ep : componentService.getEndpoints()) { - // Inherit from the componentType.service.interface - if (componentService.getService() != null && componentService.getService().getInterfaceContract() != null) { - inherit(ep, componentService.getService().getInterfaceContract().getInterface()); - } - if (componentService.getInterfaceContract() != null) { - // Inherit from the component.service.interface - inherit(ep, componentService.getInterfaceContract().getInterface()); - } - // Inherit from the componentType/service - inheritFromService(ep, composite, component, componentService.getService()); - // Find the corresponding binding in the componentType and inherit the intents/policySets - if (componentService.getService() != null) { - for (Binding binding : componentService.getService().getBindings()) { - resolveAndCheck((PolicySubject)binding, context); - if (isEqual(ep.getBinding().getName(), binding.getName()) && (binding instanceof PolicySubject)) { - checkMutualExclusion((PolicySubject)ep.getBinding(), (PolicySubject)binding, context); - // Inherit from componentType.service.binding - inherit(ep, binding); - break; - } - } - } - // Inherit from composite/component/service - inheritFromService(ep, composite, ep.getComponent(), ep.getService()); - // Inherit from binding - inherit(ep, ep.getBinding()); - - // Replace profile intents with their required intents - // Remove the intents whose @contraints do not include the current element - // Replace unqualified intents if there is a qualified intent in the list - // Replace qualifiable intents with the default qualied intent - resolveAndNormalize(ep, context); - - // check that the resulting endpoint has no mutually exclusive intents - checkMutualExclusion(ep, context); - } - } finally { - monitor.popContext(); - } - } - - for (ComponentReference componentReference : component.getReferences()) { - monitor.pushContext("Reference: " + componentReference.getName().toString()); - - try { - resolveAndCheck(componentReference, context); - resolveAndCheck(componentReference.getReference(), context); - - // Check component/reference against componentType/reference - checkMutualExclusion(componentReference, componentReference.getReference(), context); - - if (componentReference.getInterfaceContract() != null && componentReference.getReference() != null) { - resolveAndCheck(componentReference.getInterfaceContract().getInterface(), context); - resolveAndCheck(componentReference.getReference().getInterfaceContract().getInterface(), context); - - checkMutualExclusion(componentReference.getInterfaceContract().getInterface(), componentReference - .getReference().getInterfaceContract().getInterface(), context); - - resolveAndCheck(componentReference.getInterfaceContract().getCallbackInterface(), context); - resolveAndCheck(componentReference.getReference().getInterfaceContract().getCallbackInterface(), - context); - - checkMutualExclusion(componentReference.getInterfaceContract().getCallbackInterface(), - componentReference.getReference().getInterfaceContract() - .getCallbackInterface(), - context); - } - - for (EndpointReference epr : componentReference.getEndpointReferences()) { - // Inherit from the componentType.reference.interface - if (componentReference.getReference() != null && componentReference.getReference() - .getInterfaceContract() != null) { - inherit(epr, componentReference.getReference().getInterfaceContract().getInterface()); - } - // Inherit from the component.reference.interface - if (componentReference.getInterfaceContract() != null) { - inherit(epr, componentReference.getInterfaceContract().getInterface()); - } - // Inherit from the componentType/reference - inheritFromReference(epr, composite, component, componentReference.getReference()); - // Find the corresponding binding in the componentType and inherit the intents/policySets - if (componentReference.getReference() != null) { - for (Binding binding : componentReference.getReference().getBindings()) { - if (epr.getBinding() != null && isEqual(epr.getBinding().getName(), binding.getName()) - && (binding instanceof PolicySubject)) { - resolveAndCheck((PolicySubject)binding, context); - checkMutualExclusion((PolicySubject)epr.getBinding(), (PolicySubject)binding, context); - // Inherit from componentType.reference.binding - inherit(epr, binding); - break; - } - } - } - // Inherit from composite/component/reference/binding - inheritFromReference(epr, composite, epr.getComponent(), epr.getReference()); - inherit(epr, epr.getBinding()); - - // Replace profile intents with their required intents - // Remove the intents whose @contraints do not include the current element - // Replace unqualified intents if there is a qualified intent in the list - // Replace qualifiable intents with the default qualied intent - resolveAndNormalize(epr, context); - - // check that the resulting endpoint reference has no mutually exclusive intents - checkMutualExclusion(epr, context); - } - } finally { - monitor.popContext(); - } - } - - if (implementation instanceof Composite) { - inherit(implementation, component, composite); - computePolicies((Composite)implementation, context); - } else { - resolveAndCheck(implementation, context); - if (implementation != null) { - inherit(implementation, component, composite); - } - } - } finally { - monitor.popContext(); - } - } - } finally { - monitor.popContext(); - } - } + if (componentReference.getInterfaceContract() != null) { + resolveAndCheck(componentReference.getInterfaceContract().getInterface(), context); - private Set<QName> getPolicyNames(PolicySubject subject) { - if (subject == null) { - return Collections.emptySet(); - } - Set<QName> names = new HashSet<QName>(); - for (PolicySet ps : subject.getPolicySets()) { - for (PolicyExpression exp : ps.getPolicies()) { - names.add(exp.getName()); + resolveAndCheck(componentReference.getInterfaceContract().getCallbackInterface(), + context); + } + + for (EndpointReference epr : componentReference.getEndpointReferences()) { + + // Inherit from the component.reference.interface + if (componentReference.getInterfaceContract() != null) { + inherit(epr, true, componentReference.getInterfaceContract().getInterface()); + } + + // Inherit from composite/component/reference/binding + inherit(epr, true, composite, epr.getComponent(), epr.getReference()); + inherit(epr, true, epr.getBinding()); + + // Replace profile intents with their required intents + // Remove the intents whose @contraints do not include the current element + // Replace unqualified intents if there is a qualified intent in the list + // Replace qualifiable intents with the default qualied intent + resolveAndNormalize(epr, context); + + // check that the resulting endpoint reference has no mutually exclusive intents + checkMutualExclusion(epr, context); + } + } finally { + monitor.popContext(); + } + } + + if (implementation instanceof Composite) { + inherit(implementation, true, component, composite); + computePolicies((Composite)implementation, context); + } else { + resolveAndCheck(implementation, context); + if (implementation != null) { + inherit(implementation, true, component, composite); + } + } + } finally { + monitor.popContext(); + } } + } finally { + monitor.popContext(); } - return names; } protected void buildPolicies(Composite composite, BuilderContext context) { |