Package org.apache.tuscany.sca.definitions

Examples of org.apache.tuscany.sca.definitions.Definitions


    public void testPolicyIntents() throws Exception {
        ModelResolver resolver = new TestModelResolver(getClass().getClassLoader());
       
        URL url = getClass().getResource("definitions.xml");
        URI uri = URI.create("definitions.xml");
        Definitions scaDefns = policyDefinitionsProcessor.read(null, uri, url, context);
               
        InputStream is = getClass().getResourceAsStream("Calculator.composite");
        XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
        Composite composite = (Composite)staxProcessor.read(reader, context);
        assertNotNull(composite);
View Full Code Here


    public void testPolicySets() throws Exception {
        ModelResolver resolver = new TestModelResolver(getClass().getClassLoader());
       
        URL url = getClass().getResource("definitions_with_policysets.xml");
        URI uri = URI.create("definitions_with_policysets.xml");
        Definitions policyDefinitions = policyDefinitionsProcessor.read(null, uri, url, context);
               
        InputStream is = getClass().getResourceAsStream("Calculator.composite");
        XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
        Composite composite = (Composite)staxProcessor.read(reader, context);
        assertNotNull(composite);
       
        for ( Component component : composite.getComponents() ) {
            for ( PolicySet policySet : policyDefinitions.getPolicySets() ) {
                component.getPolicySets().add(policySet);
            }
        }
       
        staxProcessor.resolve(policyDefinitions, resolver, context);
View Full Code Here

        if (compositeContext == null){
            // will be null if this is the SCAClient
            return;
        }
       
        Definitions systemDefinitions = compositeContext.getSystemDefinitions();
        if (systemDefinitions != null){
            // Find pre-resolved intents from the system definition
            List<Intent> intents = new ArrayList<Intent>();
           
            for (Intent intent : endpoint.getRequiredIntents()){
                Intent resolvedIntent = PolicyHelper.getIntent(systemDefinitions, intent.getName());
             
                if (resolvedIntent != null){
                    intents.add(resolvedIntent);
                } else {
                    // look to see if this intent is provided by the binding
                    BindingType bindingType = systemDefinitions.getBindingType(endpoint.getBinding().getType());

                    if (bindingType != null){
                        for (Intent apIntent : bindingType.getAlwaysProvidedIntents()){
                            if (apIntent.getName().equals(intent.getName())){
                                resolvedIntent = apIntent;
View Full Code Here

       
        // TODO - seems that we should do this loop on a binding by binding basis
        //        rather than each time we do matching
        BindingType bindingType = null;
       
        Definitions systemDefinitions = null;
        if (builderContext != null){
            systemDefinitions = builderContext.getDefinitions();
        } else {
            systemDefinitions = ((RuntimeEndpoint)endpoint).getCompositeContext().getSystemDefinitions();
        }
       
        bindingType = systemDefinitions.getBindingType(binding.getType());
       
        // Before we start examining intents, remove any whose constrained
        // types don't include the binding type
        removeConstrainedIntents(endpointReference, bindingType);
       
View Full Code Here

        this.policyFactory = factoryExtensionPoint.getFactory(PolicyFactory.class);       
    }

    public Definitions read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
        QName name = null;
        Definitions definitions = null;
        String targetNamespace = null;

        while (reader.hasNext()) {
            int event = reader.getEventType();
            switch (event) {
                case START_ELEMENT: {
                    name = reader.getName();
                    if (DEFINITIONS_QNAME.equals(name)) {
                        definitions = definitionsFactory.createDefinitions();
                        targetNamespace = getURIString(reader, TARGET_NAMESPACE);
                        definitions.setTargetNamespace(targetNamespace);
                    } else {
                        Object extension = extensionProcessor.read(reader, context);
                        if (extension != null) {
                            if (extension instanceof Intent) {
                                Intent intent = (Intent)extension;
                                intent.setName(new QName(targetNamespace, intent.getName().getLocalPart()));
                                definitions.getIntents().add(intent);
                                for (Intent i : intent.getQualifiedIntents()) {
                                    i.setName(new QName(targetNamespace, i.getName().getLocalPart()));
                                }
                            } else if (extension instanceof PolicySet) {
                                PolicySet policySet = (PolicySet)extension;
                                policySet.setName(new QName(targetNamespace, policySet.getName().getLocalPart()));
                                definitions.getPolicySets().add(policySet);
                            } else if (extension instanceof Binding) {
                                Binding binding = (Binding)extension;
                                definitions.getBindings().add(binding);
                            } else if (extension instanceof BindingType) {
                                definitions.getBindingTypes().add((BindingType)extension);
                            } else if (extension instanceof ImplementationType) {
                                definitions.getImplementationTypes().add((ImplementationType)extension);
                            } else if (extension instanceof ExternalAttachment) {
                              definitions.getExternalAttachments().add((ExternalAttachment)extension);
                            }
                        }
                        break;
                    }
                }
View Full Code Here

            URLArtifactProcessorExtensionPoint processors =
                registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
            URLArtifactProcessor<Definitions> processor = processors.getProcessor(Definitions.class);
            ProcessorContext context = new ProcessorContext(monitorFactory.createMonitor());
            for (URL url : documents) {
                Definitions def;
                try {
                    def = processor.read(null, DEFINITIONS_URI, url, context);
                    definitions.add(def);
                } catch (ContributionReadException e) {
                    logger.log(Level.SEVERE, e.getMessage(), e);
View Full Code Here

        * TODO - can we get this code into the actual impl modules itself. Move this builder?
        */       
        List<DefaultIntent> defaultIntents = ((DefaultingPolicySubject)binding).getDefaultIntents();
        DefaultIntent defaultIntent = policyFactory.createDefaultIntent();
       
        Definitions systemDefinitions = context.getDefinitions();
        if (systemDefinitions != null){
            BindingType bindingType = systemDefinitions.getBindingType(binding.getType());
            for (Intent mayProvideIntent : bindingType.getMayProvidedIntents()){
                if (mayProvideIntent.getName().getLocalPart().equals("SOAP.v1_1")){
                    defaultIntent.setIntent(mayProvideIntent);
                }
                if (mayProvideIntent.getName().getLocalPart().equals("SOAP.v1_2")){
View Full Code Here

            }

            //urlStream = createInputStream(url);
            XMLStreamReader reader = inputFactory.createXMLStreamReader(url.toString(), urlStream);
            ValidatingXMLInputFactory.setMonitor(reader, context.getMonitor());
            Definitions definitions = definitionsFactory.createDefinitions();
            int event = reader.getEventType();
            while (reader.hasNext()) {
                event = reader.next();

                // We only deal with the root element
View Full Code Here

        InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite");
        Composite composite = staxProcessor.read(is, Composite.class, context);
       
        URL url = getClass().getResource("test_definitions.xml");
        URI uri = URI.create("test_definitions.xml");
        Definitions scaDefns = (Definitions)policyDefinitionsProcessor.read(null, uri, url, context);
        assertNotNull(scaDefns);
        policyDefinitionsProcessor.resolve(scaDefns, resolver, context);
       
        staxProcessor.resolve(composite, resolver, context);
        // compositeBuilder.build(composite, null, monitor);
View Full Code Here

        Composite composite = readComposite("TestAllCalculator.composite");
       
        URL url = getClass().getResource("test_definitions.xml");
        URI uri = URI.create("test_definitions.xml");
        Definitions scaDefns = (Definitions)policyDefinitionsProcessor.read(null, uri, url, context);
        assertNotNull(scaDefns);
       
        policyDefinitionsProcessor.resolve(scaDefns, resolver, context);
       
        staxProcessor.resolve(composite, resolver, context);
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.definitions.Definitions

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.