Package org.apache.tuscany.sca.policy

Examples of org.apache.tuscany.sca.policy.IntentAttachPointType


       
        for (PolicySet policySet : referredPolicySets)
            extensionProcessor.resolve(policySet, resolver);       
       
        for (int count = 0, size = scaDefns.getBindingTypes().size(); count < size; count++) {
            IntentAttachPointType bindingType = scaDefns.getBindingTypes().get(count);
            extensionProcessor.resolve(bindingType, resolver);
        }
       
        for (int count = 0, size = scaDefns.getImplementationTypes().size(); count < size; count++) {
            IntentAttachPointType implType = scaDefns.getImplementationTypes().get(count);
            extensionProcessor.resolve(implType, resolver);
        }
    }
View Full Code Here


                                            composite.getExtensions().add(extension);
                                        }
                                    }
                                } else if (extension instanceof Binding) {
                                    if ( extension instanceof PolicySetAttachPoint ) {
                                        IntentAttachPointType bindingType = intentAttachPointTypeFactory.createBindingType();
                                        bindingType.setName(name);
                                        bindingType.setUnresolved(true);
                                        ((PolicySetAttachPoint)extension).setType(bindingType);
                                    }
                                    // <service><binding> and
                                    // <reference><binding>
                                    if (callback != null) {
                                        callback.getBindings().add((Binding)extension);
                                    } else {
                                        if (contract != null) {
                                            contract.getBindings().add((Binding)extension);
                                        } else {
                                            if (name.getNamespaceURI().equals(SCA10_NS)) {
                                              error("UnexpectedBindingElement", extension);
                                                //throw new ContributionReadException("Unexpected <binding> element found. It should appear inside a <service> or <reference> element");
                                            } else {
                                                composite.getExtensions().add(extension);
                                            }
                                        }
                                    }
   
                                } else if (extension instanceof Implementation) {
                                    if ( extension instanceof PolicySetAttachPoint ) {
                                        IntentAttachPointType implType = intentAttachPointTypeFactory.createImplementationType();
                                        implType.setName(name);
                                        implType.setUnresolved(true);
                                        ((PolicySetAttachPoint)extension).setType(implType);
                                    }
                                    // <component><implementation>
                                    if (component != null) {
                                        component.setImplementation((Implementation)extension);
View Full Code Here

    public IntentAttachPointType read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
        QName type = getQName(reader, TYPE);
       
        if ( type != null ) {
            if ( type.getLocalPart().startsWith(BINDING) ) {
                IntentAttachPointType bindingType = attachPointTypeFactory.createBindingType();
                bindingType.setName(type);
                bindingType.setUnresolved(true);
               
                readAlwaysProvidedIntents(bindingType, reader);
                readMayProvideIntents(bindingType, reader);
                return bindingType;
            } else if ( type.getLocalPart().startsWith(IMPLEMENTATION) ) {
                IntentAttachPointType implType = attachPointTypeFactory.createImplementationType();
                implType.setName(type);
                implType.setUnresolved(true);
               
                readAlwaysProvidedIntents(implType, reader);
                readMayProvideIntents(implType, reader);
                return implType;
            } else {
View Full Code Here

        return SCABinding.class;
    }

    public SCABinding read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
        SCABinding scaBinding = scaBindingFactory.createSCABinding();
        IntentAttachPointType bindingType = intentAttachPointTypeFactory.createBindingType();
        bindingType.setName(getArtifactType());
        bindingType.setUnresolved(true);
        ((PolicySetAttachPoint)scaBinding).setType(bindingType);

        // Read policies
        policyProcessor.readPolicies(scaBinding, reader);
View Full Code Here

    }
   
    private static 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
            PolicyComputationUtils.expandProfileIntents(confOp.getRequiredIntents());
View Full Code Here

                                                  PolicySetAttachPoint policySetAttachPoint)
                                                                        throws PolicyValidationException {
        //String appliesTo = null;
        //String scdlFragment = "";
        HashMap<QName, PolicySet> policySetTable = new HashMap<QName, PolicySet>();
        IntentAttachPointType attachPointType = policySetAttachPoint.getType();
       
        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)) {
                    if (!applicablePolicySets.contains(policySet)) {
                        throw new PolicyValidationException("Policy Set '" + policySet.getName()
                                + " specified for operation " + confOp.getName() 
                            + "' does not constrain extension type  "
                            + attachPointType.getName());
       
                    }
                } else {
                    throw new PolicyValidationException("Policy Set '" + policySet.getName()
                            + " specified for operation " + confOp.getName() 
View Full Code Here

    static void determineApplicableBindingPolicySets(Contract source, Contract target) throws PolicyConfigurationException {
        List<Intent> intentsCopy = null;
        for (Binding aBinding : source.getBindings()) {
            if (aBinding instanceof PolicySetAttachPoint) {
                PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)aBinding;
                IntentAttachPointType bindingType = policiedBinding.getType();
   
               
                intentsCopy = new ArrayList<Intent>(policiedBinding.getRequiredIntents());
                // add the target component's intents to the reference binding
                if (target != null) {
                    for (Intent intent : target.getRequiredIntents()) {
                        if (!policiedBinding.getRequiredIntents().contains(intent)) {
                            for (QName constrained : intent.getConstrains()) {
                                if (bindingType != null && bindingType.getName().getNamespaceURI()
                                    .equals(constrained.getNamespaceURI())
                                    && bindingType.getName().getLocalPart().startsWith(constrained
                                        .getLocalPart())) {
                                    policiedBinding.getRequiredIntents().add(intent);
                                    break;
                                }
                            }
View Full Code Here

                    if (binding instanceof IntentAttachPoint) {
                        IntentAttachPoint policiedBinding = (IntentAttachPoint)binding;

                        if ( policiedBinding.getType() != null && policiedBinding.getType().isUnresolved() ) {
                            IntentAttachPointType resolved =
                                resolver.resolveModel(IntentAttachPointType.class,
                                                      policiedBinding.getType());
                            policiedBinding.setType(resolved);
                        }

                        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, ((PolicySetAttachPoint)binding).getType());
                        }
                    }
                }

                // 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
                    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;

                            if ( policiedBinding.getType().isUnresolved() ) {
                                IntentAttachPointType resolved =
                                    resolver.resolveModel(IntentAttachPointType.class,
                                                          policiedBinding.getType());
                                policiedBinding.setType(resolved);
                            }
View Full Code Here

        for (Binding binding : bindings) {
            if (binding instanceof IntentAttachPoint) {
               
                IntentAttachPoint policiedBinding = (IntentAttachPoint)binding;
                IntentAttachPointType bindingType = policiedBinding.getType();

                //expand profile intents specified in the binding
                if ( policiedBinding.getRequiredIntents().size() > 0 ) {
                    expandedIntents = expandProfileIntents(policiedBinding.getRequiredIntents());
                    policiedBinding.getRequiredIntents().clear();
                    policiedBinding.getRequiredIntents().addAll(expandedIntents);
                }
               
                //validate intents specified for the binding
                for (Intent intent : policiedBinding.getRequiredIntents()) {
                    for (QName constrained : intent.getConstrains()) {
                        if (bindingType.getName().getNamespaceURI().equals(constrained
                            .getNamespaceURI()) && bindingType.getName().getLocalPart()
                            .startsWith(constrained.getLocalPart())) {
                            found = true;
                            break;
                        }
                    }

                    if (!found) {
                        warning("Policy Intent '" + intent.getName()
                            + "' does not constrain binding type  "
                            + bindingType, binding);
                    }
                }
               
                //expand profile intents in inherited intents
                expandedIntents = expandProfileIntents(inheritedIntents);
                inheritedIntents.clear();
                inheritedIntents.addAll(expandedIntents);

                //validate if inherited intent applies to the binding and
                //only add such intents to the binding
                for (Intent intent : inheritedIntents) {
                    for (QName constrained : intent.getConstrains()) {
                        if (bindingType.getName().getNamespaceURI().equals(constrained
                            .getNamespaceURI()) && bindingType.getName().getLocalPart()
                            .startsWith(constrained.getLocalPart())) {
                            policiedBinding.getRequiredIntents().add(intent);
                            break;
                        }
                    }
                }
               
                Map<QName, Intent> intentsTable = new HashMap<QName, Intent>();
                //remove duplicates
                for ( Intent intent : policiedBinding.getRequiredIntents() ) {
                    intentsTable.put(intent.getName(), 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());
                        }
                    }
                }
                policiedBinding.getRequiredIntents().clear();
                policiedBinding.getRequiredIntents().addAll(intentsTable.values());
               
                //exclude intents that are inherently supported by the binding type
                List<Intent> requiredIntents = new ArrayList<Intent>(policiedBinding.getRequiredIntents());
                for ( Intent intent : requiredIntents ) {
                    if ( bindingType.getAlwaysProvidedIntents() != null &&
                        bindingType.getAlwaysProvidedIntents().contains(intent) ) {
                        policiedBinding.getRequiredIntents().remove(intent);
                    }
                }
               
            }
View Full Code Here

        HashMap<QName, PolicySet> policySetTable = new HashMap<QName, PolicySet>();
       
        for (Binding binding : bindings) {
            if (binding instanceof PolicySetAttachPoint) {
                PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)binding;
                IntentAttachPointType bindingType = policiedBinding.getType();

                //validate policysets specified for the binding
                for (PolicySet policySet : policiedBinding.getPolicySets()) {
                    appliesTo = policySet.getAppliesTo();
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.policy.IntentAttachPointType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.