Package org.apache.tuscany.sca.policy

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


    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);
               
                readAlwaysProvidedIntents(bindingType, reader);
                readMayProvideIntents(bindingType, reader);
                return bindingType;
            } else if ( type.getLocalPart().startsWith(IMPLEMENTATION) ) {
                IntentAttachPointType implType = attachPointTypeFactory.createImplementationType();
                implType.setName(type);
               
                readAlwaysProvidedIntents(implType, reader);
                readMayProvideIntents(implType, reader);
                return implType;
            } else {
View Full Code Here


   
    private void computeIntentsForIntentAttachPoint(IntentAttachPoint intentAttachPoint, List<Intent> inheritedIntents) {
        boolean found = false;
        List<Intent> expandedIntents = null;
       
        IntentAttachPointType attachPointType = intentAttachPoint.getType();

        //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);
        }
       
        //validate intents specified for the attachpoint (binding / implementation)
        for (Intent intent : intentAttachPoint.getRequiredIntents()) {
            for (QName constrained : intent.getConstrains()) {
                if (attachPointType != null && attachPointType.getName().getNamespaceURI().equals(constrained
                    .getNamespaceURI()) && attachPointType.getName().getLocalPart()
                    .startsWith(constrained.getLocalPart())) {
                    found = true;
                    break;
                }
            }

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

        //validate if inherited intent applies to the attachpoint (binding / implementation) and
        //only add such intents to the attachpoint (binding / implementation)
        for (Intent intent : inheritedIntents) {
            for (QName constrained : intent.getConstrains()) {
                if (attachPointType != null && attachPointType.getName().getNamespaceURI().equals(constrained
                    .getNamespaceURI()) && attachPointType.getName().getLocalPart()
                    .startsWith(constrained.getLocalPart())) {
                    intentAttachPoint.getRequiredIntents().add(intent);
                    break;
                }
            }
View Full Code Here

    private void computePolicySetsForPolicySetAttachPoint(Base parent,
                                                           PolicySetAttachPoint policySetAttachPoint,
                                                           List<PolicySet> inheritedPolicySets) {
        String appliesTo = null;
        HashMap<QName, PolicySet> policySetTable = new HashMap<QName, PolicySet>();
        IntentAttachPointType attachPointType = policySetAttachPoint.getType();

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

   
   
   
    private void determineApplicableDomainPolicySets(Contract contract, PolicySetAttachPoint policiedBinding) {
        if ( domainPolicySets != null && policiedBinding.getRequiredIntents().size() > 0 ) {
            IntentAttachPointType bindingType = policiedBinding.getType();
            for ( PolicySet policySet : domainPolicySets ) {
                if ( isPolicySetApplicable(contract, policySet.getAppliesTo(), bindingType) ) {
                    int prevSize = policiedBinding.getRequiredIntents().size();
                    trimProvidedIntents(policiedBinding.getRequiredIntents(), policySet);
                    //if any intent was trimmed off, then this policyset must be attached to the binding
View Full Code Here

    }
   
   
    private void determineApplicableDomainPolicySets(Component component, PolicySetAttachPoint policiedImplementation) {
        if ( domainPolicySets != null && policiedImplementation.getRequiredIntents().size() > 0 ) {
            IntentAttachPointType implType = policiedImplementation.getType();
            for ( PolicySet policySet : domainPolicySets ) {
                if ( isPolicySetApplicable(component, policySet.getAppliesTo(), implType) ) {
                    int prevSize = policiedImplementation.getRequiredIntents().size();
                    trimProvidedIntents(policiedImplementation.getRequiredIntents(), policySet);
                    //if any intent was trimmed off, then this policyset must be attached to the implementation
View Full Code Here

       
    private void determineApplicableBindingPolicySets(Contract source, Contract target) {
        for ( Binding aBinding : source.getBindings() ) {
            if ( aBinding instanceof PolicySetAttachPoint ) {
                PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)aBinding;
                IntentAttachPointType bindingType = policiedBinding.getType();
               
                //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

    }
   
    private void determineApplicableImplementationPolicySets(Component component) {
        if ( component.getImplementation() instanceof PolicySetAttachPoint ) {
            PolicySetAttachPoint policiedImplementation = (PolicySetAttachPoint)component.getImplementation();
            IntentAttachPointType implType = policiedImplementation.getType();
               
            trimProvidedIntents(policiedImplementation.getRequiredIntents(), policiedImplementation.getPolicySets());
               
            //determine additional policysets that match remaining intents
            //if there are intents that are not provided by any policy set throw a warning
View Full Code Here

        //testing to ensure that inclusion of referred policy sets has not happened
        PolicySet basicAuthMsgProtSecurityPolicySet = policySetTable.get(basicAuthMsgProtSecurity);
        assertTrue(basicAuthMsgProtSecurityPolicySet.getPolicies().isEmpty());
        assertTrue(basicAuthMsgProtSecurityPolicySet.getMappedPolicies().isEmpty());
       
        IntentAttachPointType wsBindingType = bindingTypesTable.get(wsBinding);
        assertNull(wsBindingType.getAlwaysProvidedIntents().get(0).getDescription());
        assertNull(wsBindingType.getMayProvideIntents().get(0).getDescription());
       
        IntentAttachPointType javaImplType = implTypesTable.get(javaImpl);
        assertNull(javaImplType.getAlwaysProvidedIntents().get(0).getDescription());
        assertNull(javaImplType.getMayProvideIntents().get(0).getDescription());
       
        scaDefnDocProcessor.resolve(scaDefinitions, null);
        //builder.build(scaDefinitions);
       
        //testing if policy intents have been linked have property been linked up
        assertNotNull(profileIntent.getRequiredIntents().get(0).getDescription());
        assertNotNull(qualifiedIntent.getQualifiableIntent().getDescription());
        assertEquals(secureReliablePolicySet.getProvidedIntents().get(1).getName(), integrity);
        assertNotNull(secureReliablePolicySet.getProvidedIntents().get(1).getDescription());
       
        //testing if policysets have been properly linked up with intents
        assertFalse(secureMessagingPolicySet.isUnresolved());
        assertNotNull(secureMessagingPolicySet.getMappedPolicies().get(intentTable.get(confidentiality)));
        assertNotNull(secureMessagingPolicySet.getMappedPolicies().get(intentTable.get(confidentiality_transport)));
       
        //testing if intent maps have been properly mapped to policies
        assertFalse(securityPolicySet.isUnresolved());
        assertNotNull(securityPolicySet.getMappedPolicies().get(intentTable.get(confidentiality)));
        assertNotNull(securityPolicySet.getMappedPolicies().get(intentTable.get(confidentiality_message)));
       
        //testing for inclusion of referred policysets
        assertFalse(basicAuthMsgProtSecurityPolicySet.getPolicies().isEmpty());
        assertFalse(basicAuthMsgProtSecurityPolicySet.getMappedPolicies().isEmpty());
        assertNotNull(basicAuthMsgProtSecurityPolicySet.getMappedPolicies().get(intentTable.get(confidentiality_transport)));
       
        assertNotNull(wsBindingType.getAlwaysProvidedIntents().get(0).getDescription());
        assertNotNull(wsBindingType.getMayProvideIntents().get(0).getDescription());
       
        assertNotNull(javaImplType.getAlwaysProvidedIntents().get(0).getDescription());
        assertNotNull(javaImplType.getMayProvideIntents().get(0).getDescription());
    }
View Full Code Here

                        policySetTable.put(policySet.getName(), policySet);
                    } else if ( artifact instanceof Intent ) {
                        Intent intent = (Intent)artifact;
                        intentTable.put(intent.getName(), intent);
                    } else if ( artifact instanceof BindingTypeImpl ) {
                        IntentAttachPointType bindingType = (IntentAttachPointType)artifact;
                        bindingTypesTable.put(bindingType.getName(), bindingType);
                    } else if ( artifact instanceof ImplementationTypeImpl ) {
                        IntentAttachPointType implType = (IntentAttachPointType)artifact;
                        implTypesTable.put(implType.getName(), implType);
                    }
                   
                    if ( artifact != null ) {
                        resolver.addModel(artifact);
                    }
View Full Code Here

        //testing to ensure that inclusion of referred policy sets has not happened
        PolicySet basicAuthMsgProtSecurityPolicySet = policySetTable.get(basicAuthMsgProtSecurity);
        assertTrue(basicAuthMsgProtSecurityPolicySet.getPolicies().isEmpty());
        assertTrue(basicAuthMsgProtSecurityPolicySet.getMappedPolicies().isEmpty());
       
        IntentAttachPointType wsBindingType = bindingTypesTable.get(wsBinding);
        assertNull(wsBindingType.getAlwaysProvidedIntents().get(0).getDescription());
        assertNull(wsBindingType.getMayProvideIntents().get(0).getDescription());
       
        IntentAttachPointType javaImplType = implTypesTable.get(javaImpl);
        assertNull(javaImplType.getAlwaysProvidedIntents().get(0).getDescription());
        assertNull(javaImplType.getMayProvideIntents().get(0).getDescription());
       
        for ( Intent intent : intentTable.values() ) {
            staxProcessor.resolve(intent, resolver);
        }
       
        for ( PolicySet policySet : policySetTable.values() ) {
            staxProcessor.resolve(policySet, resolver);
        }
       
        for IntentAttachPointType bindingType : bindingTypesTable.values() ) {
            staxProcessor.resolve(bindingType, resolver);
        }
       
        for ( IntentAttachPointType implType : implTypesTable.values() ) {
            staxProcessor.resolve(implType, resolver);
        }
       
       
       
        //testing if policy intents have been linked have property been linked up
        assertNotNull(profileIntent.getRequiredIntents().get(0).getDescription());
        assertNotNull(qualifiedIntent.getQualifiableIntent().getDescription());
        assertEquals(secureReliablePolicySet.getProvidedIntents().get(1).getName(), integrity);
        assertNotNull(secureReliablePolicySet.getProvidedIntents().get(1).getDescription());
       
        //testing if policysets have been properly linked up with intents
        assertFalse(secureMessagingPolicySet.isUnresolved());
        assertNotNull(secureMessagingPolicySet.getMappedPolicies().get(intentTable.get(confidentiality)));
        assertNotNull(secureMessagingPolicySet.getMappedPolicies().get(intentTable.get(confidentiality_transport)));
       
        //testing if intent maps have been properly mapped to policies
        assertFalse(securityPolicySet.isUnresolved());
        assertNotNull(securityPolicySet.getMappedPolicies().get(intentTable.get(confidentiality)));
        assertNotNull(securityPolicySet.getMappedPolicies().get(intentTable.get(confidentiality_message)));
       
        //testing for inclusion of referred policysets
        assertFalse(basicAuthMsgProtSecurityPolicySet.getPolicies().isEmpty());
        assertFalse(basicAuthMsgProtSecurityPolicySet.getMappedPolicies().isEmpty());
        assertNotNull(basicAuthMsgProtSecurityPolicySet.getMappedPolicies().get(intentTable.get(confidentiality_transport)));
       
        assertNotNull(wsBindingType.getAlwaysProvidedIntents().get(0).getDescription());
        assertNotNull(wsBindingType.getMayProvideIntents().get(0).getDescription());
       
        assertNotNull(javaImplType.getAlwaysProvidedIntents().get(0).getDescription());
        assertNotNull(javaImplType.getMayProvideIntents().get(0).getDescription());
    }
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.