Package org.apache.tuscany.sca.policy

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


    public PolicyIntentProcessor(PolicyFactory policyFactory, StAXArtifactProcessor<Object> extensionProcessor) {
        this.policyFactory = policyFactory;
    }

    public T read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
        Intent policyIntent = null;
        String policyIntentName = reader.getAttributeValue(null, NAME);
        // 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);
                    if (resolvedRequiredIntent != null) {
                        requiredIntents.add(resolvedRequiredIntent);
                    } else {
                        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);
   
                if (resolvedQualifiableIntent != null) {
                    policyIntent.setQualifiableIntent(resolvedQualifiableIntent);
                } else {
                    throw new ContributionResolveException("Qualifiable Intent - " + qualifiableIntent
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, 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

            String[] intentNames = intentAnnotation.value();
            if (intentNames.length != 0) {
                for (String intentName : intentNames) {

                    // Add each intent to the list
                    Intent intent = policyFactory.createIntent();
                    intent.setName(getQName(intentName));
                    requiredIntents.add(intent);
                }
            }
        }
       
View Full Code Here

                //operation.setUnresolved(true);
                for (String intentName : intentNames) {

                    // Add each intent to the list, associated with the
                    // operation corresponding to the annotated method
                    Intent intent = policyFactory.createIntent();
                    intent.setName(getQName(intentName));
                    //intent.getOperations().add(operation);
                    requiredIntents.add(intent);
                }
            }
        }
View Full Code Here

           
            //validateIntents(confOp, attachPointType);
           
            //add intents specified for parent intent attach point (binding / implementation)
            //wherever its not overriden in the operation
            Intent tempIntent = null;
            List<Intent> attachPointOpIntents = new ArrayList<Intent>();
            for (Intent anIntent : parentIntents) {
                found = false;
           
                tempIntent = anIntent;
                while ( tempIntent instanceof QualifiedIntent ) {
                    tempIntent = ((QualifiedIntent)tempIntent).getQualifiableIntent();
                }
               
                for ( Intent opIntent : confOp.getRequiredIntents() ) {
                    if ( opIntent.getName().getLocalPart().startsWith(tempIntent.getName().getLocalPart())) {
                        found = true;
                        break;
                    }
                }
               
View Full Code Here

                    if ( artifact instanceof PolicySet ) {
                        PolicySet policySet = (PolicySet)artifact;
                        policySet.setName(new QName(namespace, policySet.getName().getLocalPart()));
                        policySetTable.put(policySet.getName(), policySet);
                    } else if ( artifact instanceof Intent ) {
                        Intent intent = (Intent)artifact;
                        intent.setName(new QName(namespace, intent.getName().getLocalPart()));
                        if ( intent instanceof QualifiedIntent ) {
                            ((QualifiedIntent)intent).getQualifiableIntent().
                                    setName(new QName(namespace,
                                                      ((QualifiedIntent)intent).getQualifiableIntent().getName().getLocalPart()));
                        }
                        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;
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.