Package org.apache.tuscany.sca.policy

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


                        definitions.setTargetNamespace(targetNamespace);
                    } else {
                        Object extension = extensionProcessor.read(reader);
                        if (extension != null) {
                            if (extension instanceof Intent) {
                                Intent intent = (Intent)extension;
                                intent.setName(new QName(targetNamespace, intent.getName().getLocalPart()));
                                if (intent instanceof QualifiedIntent) {
                                    QualifiedIntent qualifiedIntent = (QualifiedIntent)intent;
                                    qualifiedIntent.getQualifiableIntent()
                                        .setName(new QName(targetNamespace, qualifiedIntent.getQualifiableIntent()
                                            .getName().getLocalPart()));
                                }

                                // FIXME: Workaround for TUSCANY-2499
                                intent.setUnresolved(false);

                                definitions.getIntents().add(intent);
                            } else if (extension instanceof PolicySet) {
                                PolicySet policySet = (PolicySet)extension;
                                policySet.setName(new QName(targetNamespace, policySet.getName().getLocalPart()));
View Full Code Here


            monitor.problem(problem);
        }
    }

    public T read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
        Intent policyIntent = null;
        String policyIntentName = reader.getAttributeValue(null, NAME);
        if (policyIntentName == null) {
            error("IntentNameMissing", reader);
            return (T)policyIntent;
        }

        // Read an <sca:intent>
        if (reader.getAttributeValue(null, REQUIRES) != null) {
            policyIntent = policyFactory.createProfileIntent();
        } else if (policyIntentName != null && policyIntentName.indexOf(QUALIFIER) != -1) {
            policyIntent = policyFactory.createQualifiedIntent();

            int qualifierIndex = policyIntentName.lastIndexOf(QUALIFIER);
            Intent qualifiableIntent = policyFactory.createIntent();
            qualifiableIntent.setUnresolved(true);
            qualifiableIntent.setName(new QName(policyIntentName.substring(0, qualifierIndex)));

            ((QualifiedIntent)policyIntent).setQualifiableIntent(qualifiableIntent);
        } else {
            policyIntent = policyFactory.createIntent();
        }
View Full Code Here

        if (policyIntent != null) {
            // resolve all required intents
            List<Intent> requiredIntents = new ArrayList<Intent>();
            for (Intent requiredIntent : policyIntent.getRequiredIntents()) {
                if (requiredIntent.isUnresolved()) {
                    Intent resolvedRequiredIntent = resolver.resolveModel(Intent.class, requiredIntent);
                    // At this point, when the required intent is not resolved, it does not mean
                    // its undeclared, chances are that their dependency are not resolved yet.
                    // Lets try to resolve them first.
                    if (resolvedRequiredIntent.isUnresolved()) {
                        if (resolvedRequiredIntent instanceof ProfileIntent) {
                            if ((((ProfileIntent)resolvedRequiredIntent).getRequiredIntents()).contains(policyIntent)) {
                                error("CyclicReferenceFound", resolver, requiredIntent, policyIntent);
                                return;
                            }
                            resolveDependent(resolvedRequiredIntent, resolver);
                        }
                    }

                    if (!resolvedRequiredIntent.isUnresolved()) {
                        requiredIntents.add(resolvedRequiredIntent);
                    } else {
                        error("RequiredIntentNotFound", resolver, requiredIntent, policyIntent);
                        return;
                        //throw new ContributionResolveException("Required Intent - " + requiredIntent
View Full Code Here

    private void resolveQualifiedIntent(QualifiedIntent policyIntent, ModelResolver resolver)
        throws ContributionResolveException {
        if (policyIntent != null) {
            //resolve the qualifiable intent
            Intent qualifiableIntent = policyIntent.getQualifiableIntent();
            if (qualifiableIntent.isUnresolved()) {
                Intent resolvedQualifiableIntent = resolver.resolveModel(Intent.class, qualifiableIntent);
                // At this point, when the qualifiable intent is not resolved, it does not mean
                // its undeclared, chances are that their dependency are not resolved yet.
                // Lets try to resolve them first.
                if (resolvedQualifiableIntent.isUnresolved()) {
                    if (resolvedQualifiableIntent instanceof QualifiedIntent) {
                        resolveDependent(resolvedQualifiableIntent, resolver);
                    }
                }

                if (!resolvedQualifiableIntent.isUnresolved()) {
                    policyIntent.setQualifiableIntent(resolvedQualifiableIntent);
                } else {
                    error("QualifiableIntentNotFound", resolver, qualifiableIntent, policyIntent);
                    //throw new ContributionResolveException("Qualifiable Intent - " + qualifiableIntent
                    //+ " not found for QualifiedIntent " + policyIntent);
View Full Code Here

        String value = reader.getAttributeValue(null, REQUIRES);
        if (value != null) {
            List<Intent> requiredIntents = policyIntent.getRequiredIntents();
            for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
                QName qname = getQNameValue(reader, tokens.nextToken());
                Intent intent = policyFactory.createIntent();
                intent.setName(qname);
                intent.setUnresolved(true);
                requiredIntents.add(intent);
            }
        }
    }
View Full Code Here

        String value = reader.getAttributeValue(null, "excludes");
        if (value != null) {
            List<Intent> excludedIntents = policyIntent.getExcludedIntents();
            for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
                QName qname = getQNameValue(reader, tokens.nextToken());
                Intent intent = policyFactory.createIntent();
                intent.setName(qname);
                intent.setUnresolved(true);
                excludedIntents.add(intent);
            }
        }
    }
View Full Code Here

        if (policyIntent != null) {
            // resolve all excluded intents
            List<Intent> excludedIntents = new ArrayList<Intent>();
            for (Intent excludedIntent : policyIntent.getExcludedIntents()) {
                if (excludedIntent.isUnresolved()) {
                    Intent resolvedExcludedIntent = resolver.resolveModel(Intent.class, excludedIntent);
                    if (!resolvedExcludedIntent.isUnresolved()) {
                        excludedIntents.add(resolvedExcludedIntent);
                    } else {
                        error("ExcludedIntentNotFound", resolver, excludedIntent, policyIntent);
                        return;
                        //throw new ContributionResolveException("Excluded Intent " + excludedIntent
View Full Code Here

        String value = reader.getAttributeValue(null, ALWAYS_PROVIDES);
        if (value != null) {
            List<Intent> alwaysProvided = extnType.getAlwaysProvidedIntents();
            for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
                QName qname = getQNameValue(reader, tokens.nextToken());
                Intent intent = policyFactory.createIntent();
                intent.setName(qname);
                alwaysProvided.add(intent);
            }
        }
    }
View Full Code Here

        String value = reader.getAttributeValue(null, MAY_PROVIDE);
        if (value != null) {
            List<Intent> mayProvide = extnType.getMayProvideIntents();
            for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
                QName qname = getQNameValue(reader, tokens.nextToken());
                Intent intent = policyFactory.createIntent();
                intent.setName(qname);
                mayProvide.add(intent);
            }
        }
    }
View Full Code Here

     * @param policyIntents list of policy intents
     * @param resolver
     */
    protected void resolveIntents(List<Intent> policyIntents, ModelResolver resolver) {
        List<Intent> requiredIntents = new ArrayList<Intent>();
        Intent resolvedIntent = null;
        for (Intent intent : policyIntents) {
            resolvedIntent = resolver.resolveModel(Intent.class, intent);
            requiredIntents.add(resolvedIntent);
        }
        policyIntents.clear();
View Full Code Here

TOP

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

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.