Package org.apache.tuscany.sca.policy

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


            // Resolve bindings
            for (int i = 0, n = contract.getBindings().size(); i < n; i++) {
                Binding binding = contract.getBindings().get(i);
                extensionProcessor.resolve(binding, resolver);
                if (binding instanceof IntentAttachPoint) {
                    IntentAttachPoint policiedBinding = (IntentAttachPoint)binding;
                    resolveIntents(policiedBinding.getRequiredIntents(), resolver);
                }
                if (binding instanceof PolicySetAttachPoint) {
                    PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)binding;
                    resolvePolicySets(policiedBinding.getPolicySets(), resolver);
                    //validate if attached policysets apply to the binding
                    validatePolicySets(contract, policiedBinding);
                }
                if (binding instanceof OperationsConfigurator) {
                    OperationsConfigurator opConfigurator = (OperationsConfigurator)binding;
                    for (ConfiguredOperation confOp : opConfigurator.getConfiguredOperations()) {
                        resolveIntents(confOp.getRequiredIntents(), resolver);
                        resolvePolicySets(confOp.getPolicySets(), resolver);
                    }
                }
            }

            // Resolve callback bindings
            if (contract.getCallback() != null) {
                resolveIntents(contract.getCallback().getRequiredIntents(), resolver);
                resolvePolicySets(contract.getCallback().getPolicySets(), resolver);
                //inherit the contract's policy intents and policysets
                addInheritedIntents(contract.getRequiredIntents(), contract.getCallback().getRequiredIntents());
                addInheritedPolicySets(contract.getPolicySets(), contract.getCallback().getPolicySets());
               
                for (int i = 0, n = contract.getCallback().getBindings().size(); i < n; i++) {
                    Binding binding = contract.getCallback().getBindings().get(i);
                    extensionProcessor.resolve(binding, resolver);

                    if (binding instanceof IntentAttachPoint) {
                        IntentAttachPoint policiedBinding = (IntentAttachPoint)binding;
                        resolveIntents(policiedBinding.getRequiredIntents(), resolver);
                    }
                    if (binding instanceof PolicySetAttachPoint) {
                        PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)binding;
                        resolvePolicySets(policiedBinding.getPolicySets(), resolver);
                        validatePolicySets(contract.getCallback(), policiedBinding);
                    }
                    if (binding instanceof OperationsConfigurator) {
                        OperationsConfigurator opConfigurator = (OperationsConfigurator)binding;
                        for (ConfiguredOperation confOp : opConfigurator.getConfiguredOperations()) {
View Full Code Here


                for (int i = 0, n = contract.getBindings().size(); i < n; i++) {
                    Binding binding = contract.getBindings().get(i);
                    extensionProcessor.resolve(binding, resolver);
                   
                    if (binding instanceof IntentAttachPoint) {
                        IntentAttachPoint policiedBinding = (IntentAttachPoint)binding;
                       
                        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);
                            }
                           
                            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;
View Full Code Here

     * @param reader
     */
    private void readIntents(Object attachPoint, Operation operation, XMLStreamReader reader) {
        if (!(attachPoint instanceof IntentAttachPoint))
            return;
        IntentAttachPoint intentAttachPoint = (IntentAttachPoint)attachPoint;
        String value = reader.getAttributeValue(null, REQUIRES);
        if (value != null) {
            List<Intent> requiredIntents = intentAttachPoint.getRequiredIntents();
            for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
                QName qname = getQNameValue(reader, tokens.nextToken());
                Intent intent = policyFactory.createIntent();
                intent.setName(qname);
                if (operation != null) {
View Full Code Here

     */
    private XAttr writeIntents(Object attachPoint, Operation operation) {
        if (!(attachPoint instanceof IntentAttachPoint)) {
            return null;
        }
        IntentAttachPoint intentAttachPoint = (IntentAttachPoint)attachPoint;
        List<QName> qnames = new ArrayList<QName>();
        for (Intent intent: intentAttachPoint.getRequiredIntents()) {
            qnames.add(intent.getName());
        }
        return new XAttr(Constants.REQUIRES, qnames);
    }
View Full Code Here

                for (int i = 0, n = contract.getBindings().size(); i < n; i++) {
                    Binding binding = contract.getBindings().get(i);
                    extensionProcessor.resolve(binding, resolver);
                   
                    if (binding instanceof IntentAttachPoint) {
                        IntentAttachPoint policiedBinding = (IntentAttachPoint)binding;
                        resolveIntents(policiedBinding.getRequiredIntents(), resolver);
                        PolicyValidationUtils.validateIntents(policiedBinding, policiedBinding.getType());
                    }
                   
                    if (binding instanceof PolicySetAttachPoint) {
                        PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)binding;
                        resolvePolicySets(policiedBinding.getPolicySets(), resolver);
                        //validate if attached policysets apply to the binding
                        resolvePolicySets(policiedBinding.getApplicablePolicySets(), resolver);
                        //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());
                           
                            addInheritedIntents(((PolicySetAttachPoint)binding).getRequiredIntents(),
                                                confOp.getRequiredIntents());
                            addInheritedPolicySets(((PolicySetAttachPoint)binding).getPolicySets(),
                                                confOp.getPolicySets());
                        }
                    }
                }
   
                // Resolve callback bindings
                if (contract.getCallback() != null) {
                    resolveIntents(contract.getCallback().getRequiredIntents(), resolver);
                    resolvePolicySets(contract.getCallback().getPolicySets(), resolver);
                    resolvePolicySets(contract.getCallback().getApplicablePolicySets(), resolver);
                    //inherit the contract's policy intents and policysets
                    addInheritedIntents(contract.getRequiredIntents(), contract.getCallback().getRequiredIntents());
                    addInheritedPolicySets(contract.getPolicySets(), contract.getCallback().getPolicySets());
                    addInheritedPolicySets(contract.getApplicablePolicySets(), contract.getCallback().getApplicablePolicySets());
                   
                    for (int i = 0, n = contract.getCallback().getBindings().size(); i < n; i++) {
                        Binding binding = contract.getCallback().getBindings().get(i);
                        extensionProcessor.resolve(binding, resolver);
   
                        if (binding instanceof IntentAttachPoint) {
                            IntentAttachPoint policiedBinding = (IntentAttachPoint)binding;
                            resolveIntents(policiedBinding.getRequiredIntents(), resolver);
                            PolicyValidationUtils.validateIntents(policiedBinding, policiedBinding.getType());
                        }
                       
                        if (binding instanceof PolicySetAttachPoint) {
                            PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)binding;
                            resolvePolicySets(policiedBinding.getPolicySets(), resolver);
                            //validate if attached policysets apply to the binding
                            resolvePolicySets(policiedBinding.getApplicablePolicySets(), resolver);
                            //inherit the applicable policysets from parent contract as whatever applies to that
                            //applies to the binding as well
                            addInheritedPolicySets(contract.getApplicablePolicySets(), policiedBinding.getApplicablePolicySets());
                            PolicyValidationUtils.validatePolicySets(policiedBinding);
                        }
                       
                        if (binding instanceof OperationsConfigurator) {
                            OperationsConfigurator opConfigurator = (OperationsConfigurator)binding;
View Full Code Here

    }

    public void testPolicyIntentInheritance() throws Exception {
        String namespaceUri = "http://test";
       
        IntentAttachPoint policiedComposite = (IntentAttachPoint)composite;
        assertEquals(policiedComposite.getRequiredIntents().size(), 1);
        assertEquals(policiedComposite.getRequiredIntents().get(0).getName(), new QName(namespaceUri, "tuscanyIntent_1"));
       
        //1 defined for composite, 2 defined for the service, 1 defined and 3 inherited for the promoted service (4)
        assertEquals(composite.getServices().get(0).getRequiredIntents().size(), 7);
        //1 from the operation defined in this service and 2 from the operation defined in the promoted service
        assertEquals(composite.getServices().get(0).getConfiguredOperations().get(0).getRequiredIntents().size(), 5);
View Full Code Here

    @Test
    public void testPolicyIntentInheritance() throws Exception {
        String namespaceUri = "http://test";
       
        IntentAttachPoint policiedComposite = (IntentAttachPoint)composite;
        assertEquals(policiedComposite.getRequiredIntents().size(), 1);
        assertEquals(policiedComposite.getRequiredIntents().get(0).getName(), new QName(namespaceUri, "tuscanyIntent_1"));
       
        //1 defined for composite, 2 defined for the service, 1 defined and 3 inherited for the promoted service (4)
        assertEquals(composite.getServices().get(0).getRequiredIntents().size(), 7);
        //1 from the operation defined in this service and 2 from the operation defined in the promoted service
        assertEquals(composite.getServices().get(0).getConfiguredOperations().get(0).getRequiredIntents().size(), 5);
View Full Code Here

                for (int i = 0, n = contract.getBindings().size(); i < n; i++) {
                    Binding binding = contract.getBindings().get(i);
                    extensionProcessor.resolve(binding, resolver);
                   
                    if (binding instanceof IntentAttachPoint) {
                        IntentAttachPoint policiedBinding = (IntentAttachPoint)binding;
                       
                        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);
                            }
                           
                            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;
View Full Code Here

     * @param reader
     */
    private void readIntents(Object attachPoint, Operation operation, XMLStreamReader reader) {
        if (!(attachPoint instanceof IntentAttachPoint))
            return;
        IntentAttachPoint intentAttachPoint = (IntentAttachPoint)attachPoint;
        String value = reader.getAttributeValue(null, REQUIRES);
        if (value != null) {
            List<Intent> requiredIntents = intentAttachPoint.getRequiredIntents();
            for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
                QName qname = getQNameValue(reader, tokens.nextToken());
                Intent intent = policyFactory.createIntent();
                intent.setName(qname);
                if (operation != null) {
View Full Code Here

     */
    private XAttr writeIntents(Object attachPoint, Operation operation) {
        if (!(attachPoint instanceof IntentAttachPoint)) {
            return null;
        }
        IntentAttachPoint intentAttachPoint = (IntentAttachPoint)attachPoint;
        List<QName> qnames = new ArrayList<QName>();
        for (Intent intent: intentAttachPoint.getRequiredIntents()) {
            qnames.add(intent.getName());
        }
        return new XAttr(Constants.REQUIRES, qnames);
    }
View Full Code Here

TOP

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

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.