Package org.apache.tuscany.sca.policy

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


    }

    static void computeImplementationIntentsAndPolicySets(Implementation implementation, Component parent
                                                                throws PolicyValidationException, PolicyConfigurationException {
        if ( implementation instanceof PolicySubject ) {
            PolicySubject policiedImplementation = (PolicySubject)implementation;
            //since for an implementation the component has its policy intents and policysets its possible
            //that there are some intents there that does not constrain the implementation.. so prune
            List<Intent> prunedIntents = computeInheritableIntents(policiedImplementation.getType(),
                                                                   parent.getRequiredIntents());
            parent.getRequiredIntents().clear();
            parent.getRequiredIntents().addAll(prunedIntents);
            normalizeIntents(parent);
   
            List<PolicySet> prunedPolicySets = computeInheritablePolicySets(parent.getPolicySets());
            parent.getPolicySets().clear();
            parent.getPolicySets().addAll(prunedPolicySets);
            normalizePolicySets(parent);
   
            PolicyComputationUtils.checkForMutuallyExclusiveIntents(
                parent.getRequiredIntents(),
                parent.getPolicySets(),
                policiedImplementation.getType(),
                parent.getName());
   
            determineApplicableImplementationPolicySets(parent);
   
        }
View Full Code Here


    }

    private static void determineApplicableImplementationPolicySets(Component component) throws PolicyConfigurationException {
        List<Intent> intentsCopy = null;
        if ( component.getImplementation() instanceof PolicySubject ) {
            PolicySubject policiedImplementation = (PolicySubject)component.getImplementation();
               
            intentsCopy = new ArrayList<Intent>(component.getRequiredIntents());
            trimInherentlyProvidedIntents(policiedImplementation.getType(),
                                          component.getRequiredIntents());
            trimProvidedIntents(component.getRequiredIntents(), component.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

     * @param reader
     */
    private void readIntents(Object attachPoint, Operation operation, XMLStreamReader reader) {
        if (!(attachPoint instanceof PolicySubject))
            return;
        PolicySubject intentAttachPoint = (PolicySubject)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 void readPolicySets(Object attachPoint, Operation operation, XMLStreamReader reader) {
        if (!(attachPoint instanceof PolicySubject)) {
            return;
        }
        PolicySubject policySubject = (PolicySubject)attachPoint;
        String value = reader.getAttributeValue(null, POLICY_SETS);
        if (value != null) {
            List<PolicySet> policySets = policySubject.getPolicySets();
            for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
                QName qname = getQNameValue(reader, tokens.nextToken());
                PolicySet policySet = policyFactory.createPolicySet();
                policySet.setName(qname);
                if (operation != null) {
View Full Code Here

     */
    private XAttr writeIntents(Object attachPoint, Operation operation) {
        if (!(attachPoint instanceof PolicySubject)) {
            return null;
        }
        PolicySubject intentAttachPoint = (PolicySubject)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

     */
    private XAttr writePolicySets(Object attachPoint, Operation operation) {
        if (!(attachPoint instanceof PolicySubject)) {
            return null;
        }
        PolicySubject policySetAttachPoint = (PolicySubject)attachPoint;
        List<QName> qnames = new ArrayList<QName>();
        for (PolicySet policySet: policySetAttachPoint.getPolicySets()) {
            qnames.add(policySet.getName());
        }
        return new XAttr(Constants.POLICY_SETS, qnames);
    }
View Full Code Here

        return new XAttr(Constants.POLICY_SETS, qnames);
    }
   
    public void resolvePolicies(Object attachPoint, ModelResolver resolver) {
        if ( attachPoint instanceof PolicySubject ) {
            PolicySubject policySetAttachPoint = (PolicySubject)attachPoint;
           
            List<Intent> requiredIntents = new ArrayList<Intent>();
            Intent resolvedIntent = null;
           
            if ( policySetAttachPoint.getRequiredIntents() != null && policySetAttachPoint.getRequiredIntents().size() > 0 ) {
                for ( Intent intent : policySetAttachPoint.getRequiredIntents() ) {
                    resolvedIntent = resolver.resolveModel(Intent.class, intent);
                    requiredIntents.add(resolvedIntent);
                }
                policySetAttachPoint.getRequiredIntents().clear();
                policySetAttachPoint.getRequiredIntents().addAll(requiredIntents);
            }
           
            if ( policySetAttachPoint.getPolicySets() != null && policySetAttachPoint.getPolicySets().size() > 0 ) {
                List<PolicySet> resolvedPolicySets = new ArrayList<PolicySet>();
                PolicySet resolvedPolicySet = null;
                for ( PolicySet policySet : policySetAttachPoint.getPolicySets() ) {
                    resolvedPolicySet = resolver.resolveModel(PolicySet.class, policySet);
                    resolvedPolicySets.add(resolvedPolicySet);
                }
                policySetAttachPoint.getPolicySets().clear();
                policySetAttachPoint.getPolicySets().addAll(resolvedPolicySets);
            }
        }
    }
View Full Code Here

    @Test
    // @Ignore("The inheritance will be calculated differently in OASIS SCA")
    public void testPolicyIntentInheritance() throws Exception {
        String namespaceUri = "http://test";

        PolicySubject policiedComposite = composite;
        assertEquals(policiedComposite.getRequiredIntents().size(), 1);
        assertEquals(policiedComposite.getRequiredIntents().get(0).getName(),
                     new QName(namespaceUri, "tuscanyIntent_1"));

        Component component = composite.getComponents().get(0);
        Endpoint ep = component.getServices().get(0).getEndpoints().get(0);
        EndpointReference epr = component.getReferences().get(0).getEndpointReferences().get(0);
View Full Code Here

    public static PolicySet getPolicySet(Binding wsBinding, QName intentName) {
        PolicySet returnPolicySet = null;

        if (wsBinding instanceof PolicySubject) {
            PolicySubject policiedBinding = (PolicySubject)wsBinding;
            for (PolicySet policySet : policiedBinding.getPolicySets()) {
                for (Intent intent : policySet.getProvidedIntents()) {
                    if (intent.getName().equals(intentName)) {
                        returnPolicySet = policySet;
                        break;
                    }
View Full Code Here

    public static PolicySet getPolicySet(Binding wsBinding, QName intentName) {
        PolicySet returnPolicySet = null;

        if (wsBinding instanceof PolicySubject) {
            PolicySubject policiedBinding = (PolicySubject)wsBinding;
            for (PolicySet policySet : policiedBinding.getPolicySets()) {
                for (Intent intent : policySet.getProvidedIntents()) {
                    if (intent.getName().equals(intentName)) {
                        returnPolicySet = policySet;
                        break;
                    }
View Full Code Here

TOP

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

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.