Package org.apache.tuscany.sca.policy

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


     * @param policySets list of attached policy sets
     * @param resolver
     */
    protected void resolvePolicySets(List<PolicySet> policySets, ModelResolver resolver) {
        List<PolicySet> resolvedPolicySets = new ArrayList<PolicySet>();
        PolicySet resolvedPolicySet = null;
        for (PolicySet policySet : policySets) {
            resolvedPolicySet = resolver.resolveModel(PolicySet.class, policySet);
            resolvedPolicySets.add(resolvedPolicySet);
        }
        policySets.clear();
View Full Code Here


                                }
                            }
                        } else if (POLICY_SET_ATTACHMENT_QNAME.equals(name)) {
                            QName ps = getQName(reader, NAME);
                            if (ps != null) {
                                PolicySet policySet = policyFactory.createPolicySet();
                                policySet.setName(ps);
                                if (composite != null) {
                                    composite.getPolicySets().add(policySet);
                                } else if (component != null) {
                                    component.getPolicySets().add(policySet);
                                } else if (contract != null) {
View Full Code Here

    /**
     * @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation)
     */
    public Interceptor createInterceptor(Operation operation) {
        PolicySet ps = findPolicySet();
        return ps == null ? null : new JDKLoggingPolicyInterceptor(getContext(), operation, ps);
    }
View Full Code Here

        throws SCADefinitionsBuilderException {

        List<PolicySet> referredPolicySets = new ArrayList<PolicySet>();
        for (PolicySet referredPolicySet : policySet.getReferencedPolicySets()) {
            if (referredPolicySet.isUnresolved()) {
                PolicySet resolvedReferredPolicySet = definedPolicySets.get(referredPolicySet.getName());
                if (resolvedReferredPolicySet != null) {
                    referredPolicySets.add(resolvedReferredPolicySet);
                } else {
                    throw new SCADefinitionsBuilderException("Referred PolicySet - " + referredPolicySet
                        + "not found for PolicySet - "
View Full Code Here

    /**
     * @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation)
     */
    public Interceptor createInterceptor(Operation operation) {
        PolicySet ps = findPolicySet(operation);
        return ps == null ? null : new JDKLoggingPolicyInterceptor(getContext(), operation, ps);
    }
View Full Code Here

    /**
     * @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation)
     */
    public Interceptor createInterceptor(Operation operation) {
        PolicySet ps = findPolicySet();
        return ps == null ? null : new JDKLoggingPolicyInterceptor(getContext(), operation, ps);
    }
View Full Code Here

    }

    public PolicySet read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
        String policySetName = reader.getAttributeValue(null, NAME);
       
        PolicySet policySet = policyFactory.createPolicySet();
        policySet.setName(new QName(policySetName));
        String appliesTo = reader.getAttributeValue(null, APPLIES_TO);
        String alwaysAppliesTo = reader.getAttributeValue(TUSCANY_NS, ALWAYS_APPLIES_TO);
       
        //TODO: with 1.0 version of specs the applies to xpath is given related to the immediate
        //parent whereas the runtime evaluates the xpath aginst the composite element.  What the runtime
        //is doing is what the future version of the specs could be tending towards.  When that happens
        //this 'if' must be deleted
        if ( appliesTo != null && !appliesTo.startsWith("/") ) {
            appliesTo = "//" + appliesTo;
        }
       
        if ( alwaysAppliesTo != null && !alwaysAppliesTo.startsWith("/") ) {
            alwaysAppliesTo = "//" + alwaysAppliesTo;
        }
       
        policySet.setAppliesTo(appliesTo);
        policySet.setAlwaysAppliesTo(alwaysAppliesTo);

        XPath path = xpathFactory.newXPath();
        path.setNamespaceContext(reader.getNamespaceContext());
        try {
            if (appliesTo != null) {
                policySet.setAppliesToXPathExpression(path.compile(appliesTo));
            }
            if (alwaysAppliesTo != null) {
                policySet.setAlwaysAppliesToXPathExpression(path.compile(alwaysAppliesTo));
            }
        } catch (XPathExpressionException e) {
            throw new ContributionReadException(e);
       
       
        readProvidedIntents(policySet, reader);
       
        int event = reader.getEventType();
        QName name = null;
        reader.next();
        while (reader.hasNext()) {
            event = reader.getEventType();
            switch (event) {
                case START_ELEMENT : {
                    name = reader.getName();
                    if ( POLICY_INTENT_MAP_QNAME.equals(name) ) {
                        Intent mappedIntent = policyFactory.createIntent();
                        mappedIntent.setName(getQName(reader, PROVIDES));
                        if ( policySet.getProvidedIntents().contains(mappedIntent) ) {
                            readIntentMap(reader, policySet, mappedIntent);
                        } else {
                            throw new ContributionReadException("Intent Map provides for Intent not spcified as provided by parent PolicySet - " + policySetName);
                        }
                    } else if ( POLICY_SET_REFERENCE_QNAME.equals(name) )  {
                        PolicySet referredPolicySet = policyFactory.createPolicySet();
                        referredPolicySet.setName(getQName(reader, NAME));
                        policySet.getReferencedPolicySets().add(referredPolicySet);
                    } /*else if ( WS_POLICY_QNAME.equals(name) )  {
                        OMElement policyElement = loadElement(reader);
                        org.apache.neethi.Policy wsPolicy = PolicyEngine.getPolicy(policyElement);
                        policySet.getPolicies().add(wsPolicy);
View Full Code Here

    private void resolveReferredPolicySets(PolicySet policySet, ModelResolver resolver) throws ContributionResolveException {
   
        List<PolicySet> referredPolicySets = new ArrayList<PolicySet>();
        for (PolicySet referredPolicySet : policySet.getReferencedPolicySets()) {
            if (referredPolicySet.isUnresolved()) {
                PolicySet resolvedReferredPolicySet = resolver.resolveModel(PolicySet.class, referredPolicySet);
                if (resolvedReferredPolicySet != null) {
                    referredPolicySets.add(resolvedReferredPolicySet);
                } else {
                    throw new ContributionResolveException("Referred PolicySet - " + referredPolicySet
                        + "not found for PolicySet - "
View Full Code Here

            String[] policySetNames = policySetAnnotation.value();
            if (policySetNames.length != 0) {
                for (String policySetName : policySetNames) {

                    // Add each intent to the list
                    PolicySet policySet = policyFactory.createPolicySet();
                    policySet.setName(getQName(policySetName));
                    policySets.add(policySet);
                }
            }
        }
    }
View Full Code Here

                //operation.setName(method.getName());
                //operation.setUnresolved(true);
                for (String policySetName : policySetNames) {
                    // Add each intent to the list, associated with the
                    // operation corresponding to the annotated method
                    PolicySet policySet = policyFactory.createPolicySet();
                    policySet.setName(getQName(policySetName));
                    //intent.getOperations().add(operation);
                    policySets.add(policySet);
                }
            }
        }
View Full Code Here

TOP

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

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.