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()));
View Full Code Here


        writeEndDocument(writer);
    }
   
    public void resolve(SCADefinitions scaDefns, ModelResolver resolver) throws ContributionResolveException {
        for (int count = 0, size = scaDefns.getPolicyIntents().size(); count < size; count++) {
            Intent intent = scaDefns.getPolicyIntents().get(count);
            extensionProcessor.resolve(intent, resolver);
        }
       
        for (int count = 0, size = scaDefns.getPolicySets().size(); count < size; count++) {
            PolicySet policySet = scaDefns.getPolicySets().get(count);
View Full Code Here

        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) {
                    //FIXME Don't we need to handle intent specification
                    // on an operation basis?
                    //intent.getOperations().add(operation);
                }
View Full Code Here

    public void resolvePolicies(Object subject, ModelResolver resolver, ProcessorContext context) {
        if ( subject instanceof PolicySubject ) {
            PolicySubject policySetAttachPoint = (PolicySubject)subject;
           
            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, context);
                    requiredIntents.add(resolvedIntent);
View Full Code Here

    protected void resolveAndNormalize(PolicySubject subject, BuilderContext context) {
        Definitions definitions = context.getDefinitions();
        Set<Intent> intents = new HashSet<Intent>();
        if (definitions != null) {
            for (Intent i : subject.getRequiredIntents()) {
                Intent resolved = resolve(definitions, i);
                if (resolved != null) {
                    intents.add(resolved);
                } else {
                    error(context.getMonitor(), "IntentNotFoundAtBuild", subject, i);
                    // Intent cannot be resolved
View Full Code Here

    public void populatePolicies(List<SpringSCAServiceElement> appCxtServices,
                                 List<SpringSCAReferenceElement> appCxtReferences) {
        for (SpringSCAReferenceElement e : appCxtReferences) {
            for (QName qn : e.getIntentNames()) {
                Intent intent = policyFactory.createIntent();
                intent.setName(qn);
                e.getRequiredIntents().add(intent);
            }
            for (QName qn : e.getPolicySetNames()) {
                PolicySet ps = policyFactory.createPolicySet();
                ps.setName(qn);
                e.getPolicySets().add(ps);
            }
        }

        for (SpringSCAServiceElement e : appCxtServices) {
            for (QName qn : e.getIntentNames()) {
                Intent intent = policyFactory.createIntent();
                intent.setName(qn);
                e.getRequiredIntents().add(intent);
            }
            for (QName qn : e.getPolicySetNames()) {
                PolicySet ps = policyFactory.createPolicySet();
                ps.setName(qn);
View Full Code Here

            monitor.problem(problem);
        }
    }

    public Intent read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
        Intent intent = null;
        String intentLocalName = reader.getAttributeValue(null, NAME);
        if (intentLocalName == null) {
            error(context.getMonitor(), "IntentNameMissing", reader);
            return null;
        }

        String intentType = reader.getAttributeValue(null, INTENT_TYPE);
        if (intentType == null) {
            intentType = Intent.Type.interaction.name();
        }

        intent = policyFactory.createIntent();

        // [rfeng] the target namespace is not available, set the local part for now
        // This will be changed in the definitions processor
        intent.setName(new QName(intentLocalName));
        intent.setType(Type.valueOf(intentType));

        readRequiredIntents(intent, reader, context);
        readExcludedIntents(intent, reader);

        readConstrainedTypes(intent, reader);
       
        String mutuallyExclusiveString = reader.getAttributeValue(null, MUTUALLY_EXCLUSIVE);
        if (mutuallyExclusiveString != null &&
            mutuallyExclusiveString.equals("true")){
            intent.setMutuallyExclusive(true);
        } else {
            intent.setMutuallyExclusive(false);
        }

        Intent current = intent;
        int event = reader.getEventType();
        QName name = null;
        while (reader.hasNext()) {
            event = reader.getEventType();
            switch (event) {
                case START_ELEMENT: {
                    name = reader.getName();
                    if (DESCRIPTION_QNAME.equals(name)) {
                        String text = reader.getElementText();
                        if (text != null) {
                            text = text.trim();
                        }
                        current.setDescription(text);
                    } else if (INTENT_QUALIFIER_QNAME.equals(name)) {
                        String qualifierName = reader.getAttributeValue(null, NAME);
                        String defaultQ = reader.getAttributeValue(null, DEFAULT);
                        boolean isDefault = defaultQ == null ? false : Boolean.parseBoolean(defaultQ);
                        String qualifiedIntentName = intentLocalName + QUALIFIER + qualifierName;
                        Intent qualified = policyFactory.createIntent();
                        qualified.setUnresolved(false);
                        qualified.setType(intent.getType());
                        qualified.setName(new QName(qualifiedIntentName));
                        if (isDefault) {
                            if (intent.getDefaultQualifiedIntent() == null){
                                intent.setDefaultQualifiedIntent(qualified);
                            } else {
                                Monitor.error(context.getMonitor(),
                                              this,
                                              Messages.RESOURCE_BUNDLE,
                                              "MultipleDefaultQualifiers",
                                              intent.getName().toString());
                            }
                        }
                       
                        // check that the qualifier is unique
                        if ( !intent.getQualifiedIntents().contains(qualified)){
                            intent.getQualifiedIntents().add(qualified);
                        } else {
                            Monitor.error(context.getMonitor(),
                                          this,
                                          Messages.RESOURCE_BUNDLE,
                                          "QualifierIsNotUnique",
                                          intent.getName().toString(),
                                          qualifierName);
                        }
                       
                        qualified.setQualifiableIntent(intent);
                        current = qualified;
                    }
                    break;
                }
                case END_ELEMENT: {
View Full Code Here

        if (intent != null && !intent.getRequiredIntents().isEmpty()) {
            // resolve all required intents
            List<Intent> requiredIntents = new ArrayList<Intent>();
            for (Intent required : intent.getRequiredIntents()) {
                if (required.isUnresolved()) {
                    Intent resolved = resolver.resolveModel(Intent.class, required, context);
                    // 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 (resolved.isUnresolved()) {
                        if (((resolved).getRequiredIntents()).contains(intent)) {
                            error(monitor, "CyclicReferenceFound", resolver, required, intent);
                            return;
                        }
                    }

                    if (!resolved.isUnresolved() || resolved != required) {
                        requiredIntents.add(resolved);
                    } else {
                        error(monitor, "RequiredIntentNotFound", resolver, required, intent);
                        return;
                        //throw new ContributionResolveException("Required Intent - " + requiredIntent
View Full Code Here

    }

    private void resolveQualifiedIntent(Intent qualifed, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
        if (qualifed != null) {
            //resolve the qualifiable intent
            Intent parent = qualifed.getQualifiableIntent();
            if (parent == null) {
                return;
            }
            if (parent.isUnresolved()) {
                Intent resolved = resolver.resolveModel(Intent.class, parent, context);
                // 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 (!resolved.isUnresolved() || resolved != qualifed) {
                    qualifed.setQualifiableIntent(resolved);
                } else {
                    error(context.getMonitor(), "QualifiableIntentNotFound", resolver, parent, qualifed);
                    //throw new ContributionResolveException("Qualifiable Intent - " + qualifiableIntent
                    //+ " not found for Intent " + policyIntent);
View Full Code Here

        String value = reader.getAttributeValue(null, REQUIRES);
        if (value != null) {
            List<Intent> requiredIntents = intent.getRequiredIntents();
            for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
                QName qname = getQNameValue(reader, tokens.nextToken());
                Intent required = policyFactory.createIntent();
                required.setName(qname);
                required.setUnresolved(true);
                requiredIntents.add(required);
            }
           
            // Check that a profile intent does not have "." in its name
            if (requiredIntents.size() > 0) {
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.