Package org.apache.tuscany.sca.policy

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


        return count;
    }

    @Test
    public void testResolveSCADefinitions() throws Exception {
        Intent i1 = intentTable.get(messageProtection);
        assertTrue(!i1.getRequiredIntents().isEmpty());
        assertNull(i1.getRequiredIntents().get(0).getDescription());

        QName confidentiality_transport = new QName(namespace, "confidentiality.transport");
        Intent i2 = intentTable.get(confidentiality_transport);
        assertNotNull(i2.getQualifiableIntent());

        PolicySet secureReliablePolicySet = policySetTable.get(secureReliablePolicy);
        PolicySet secureMessagingPolicySet = policySetTable.get(secureMessagingPolicies);
        PolicySet securityPolicySet = policySetTable.get(securityPolicy);
View Full Code Here


         if (attachment != null) {
              //resolve all provided intents
              List<Intent> providedIntents = new ArrayList<Intent>();
              for (Intent providedIntent : attachment.getIntents()) {
                  if (providedIntent.isUnresolved()) {
                      Intent resolved = resolver.resolveModel(Intent.class, providedIntent, context);
                      if (!resolved.isUnresolved() || resolved != providedIntent) {
                          providedIntents.add(resolved);
                      } else {
                          error(context.getMonitor(), "ProvidedIntentNotFound", attachment, providedIntent, attachment);
                          return;                       
                      }
View Full Code Here

        String value = reader.getAttributeValue(null, INTENTS);
          if (value != null) {
              List<Intent> intents = attachment.getIntents();
              for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
                  QName qname = getQNameValue(reader, tokens.nextToken());
                  Intent intent = policyFactory.createIntent();
                  intent.setName(qname);                
                  intents.add(intent);
              }
          }
   
  }
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()));
                        intentTable.put(intent.getName(), intent);
                        for (Intent i : intent.getQualifiedIntents()) {
                            i.setName(new QName(namespace, i.getName().getLocalPart()));
                            intentTable.put(i.getName(), i);
                            resolver.addModel(i, context);
                        }
                    } else if (artifact instanceof BindingType) {
View Full Code Here

    }

    @Test
    public void testResolution() throws Exception {
        assertTrue(!intentTable.get(messageProtection).getRequiredIntents().isEmpty());
        Intent profileIntent = intentTable.get(new QName(namespace, "messageProtection"));
        assertNull(profileIntent.getRequiredIntents().get(0).getDescription());

        QName confidentiality_transport = new QName(namespace, "confidentiality.transport");
        assertTrue(intentTable.get(confidentiality_transport) instanceof Intent);
        Intent qualifiedIntent = (Intent)intentTable.get(new QName(namespace, "confidentiality.transport"));
        assertNull(qualifiedIntent.getDescription());
        assertNotNull(qualifiedIntent.getQualifiableIntent().getDescription());

        PolicySet secureReliablePolicySet = policySetTable.get(secureReliablePolicy);
        PolicySet secureMessagingPolicySet = policySetTable.get(secureMessagingPolicies);
        PolicySet securityPolicySet = policySetTable.get(securityPolicy);

        assertEquals(secureReliablePolicySet.getProvidedIntents().get(1).getName(), integrity);
        assertNull(secureReliablePolicySet.getProvidedIntents().get(1).getDescription());
        assertTrue(secureMessagingPolicySet.isUnresolved());
        assertEquals(2, getNumberOfQualifiedPolicies(securityPolicySet));

        //testing to ensure that inclusion of referred policy sets has not happened
        PolicySet basicAuthMsgProtSecurityPolicySet = policySetTable.get(basicAuthMsgProtSecurity);
        assertTrue(basicAuthMsgProtSecurityPolicySet.getPolicies().isEmpty());
        assertTrue(basicAuthMsgProtSecurityPolicySet.getIntentMaps().isEmpty());

        ExtensionType wsBindingType = bindingTypesTable.get(wsBinding);
        assertNull(wsBindingType.getAlwaysProvidedIntents().get(0).getDescription());
        assertNull(wsBindingType.getMayProvidedIntents().get(0).getDescription());

        ExtensionType javaImplType = implTypesTable.get(javaImpl);
        assertNull(javaImplType.getAlwaysProvidedIntents().get(0).getDescription());
        assertNull(javaImplType.getMayProvidedIntents().get(0).getDescription());

        ExternalAttachment attachment = attachmentsTable.values().iterator().next();
        PolicySet psOne = policySetTable.get(testPolicySetOne);
        assertEquals(psOne, attachment.getPolicySets().get(0));
       
        List<Intent> intents = new ArrayList<Intent>(intentTable.values());

        for (Intent intent : intents) {
            staxProcessor.resolve(intent, resolver, context);
        }

        for (PolicySet policySet : policySetTable.values()) {
            if (policySet.getReferencedPolicySets().isEmpty())
                staxProcessor.resolve(policySet, resolver, context);
        }

        for (PolicySet policySet : policySetTable.values()) {
            if (!policySet.getReferencedPolicySets().isEmpty())
                staxProcessor.resolve(policySet, resolver, context);
        }

        for (ExtensionType bindingType : bindingTypesTable.values()) {
            staxProcessor.resolve(bindingType, resolver, context);
        }

        for (ExtensionType implType : implTypesTable.values()) {
            staxProcessor.resolve(implType, resolver, context);
        }
       
        for ( ExternalAttachment ea : attachmentsTable.values()) {
          staxProcessor.resolve(ea, resolver, context);
        }

        //testing if policy intents have been linked have property been linked up
        assertNotNull(profileIntent.getRequiredIntents().get(0).getDescription());
        assertNotNull(qualifiedIntent.getQualifiableIntent().getDescription());
        assertEquals(secureReliablePolicySet.getProvidedIntents().get(1).getName(), integrity);
        assertNotNull(secureReliablePolicySet.getProvidedIntents().get(1).getDescription());

        //testing if policysets have been properly linked up with intents
        assertFalse(secureMessagingPolicySet.isUnresolved());
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 attachPoint, ModelResolver resolver) {
        if ( attachPoint instanceof PolicySetAttachPoint ) {
            PolicySetAttachPoint policySetAttachPoint = (PolicySetAttachPoint)attachPoint;
           
            List<Intent> requiredIntents = new ArrayList<Intent>();
            Intent resolvedIntent = null;
           
            if ( policySetAttachPoint instanceof Binding ) {
                if ( policySetAttachPoint.getType().isUnresolved() ) {
                    IntentAttachPointType resolved =
                        resolver.resolveModel(IntentAttachPointType.class, policySetAttachPoint.getType());
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

                            component.setImplementation(implementation);
                            policyProcessor.readPolicies(implementation, reader);
                        } else if (REQUIRES_QNAME.equals(name)) {
                            List<QName> intents = getQNames(reader, INTENTS);
                            for (QName i : intents) {
                                Intent intent = policyFactory.createIntent();
                                intent.setName(i);
                                if (composite != null) {
                                    composite.getRequiredIntents().add(intent);
                                } else if (component != null) {
                                    component.getRequiredIntents().add(intent);
                                } else if (contract != null) {
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 = definedIntents.get(requiredIntent.getName());
                    if (resolvedRequiredIntent != null) {
                        requiredIntents.add(resolvedRequiredIntent);
                    } else {
                        throw new SCADefinitionsBuilderException("Required Intent - " + requiredIntent
                            + " not found for ProfileIntent "
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.