Package org.apache.tuscany.sca.definitions

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


            public URL run() {
                return getClass().getClassLoader().getResource(definitionsFile);
            }
        });

        Definitions scaDefn = null;
        try {
            final URI uri = new URI(definitionsFile);
            // Allow bindings to read properties. Requires PropertyPermission read in security policy.
            scaDefn = AccessController.doPrivileged(new PrivilegedExceptionAction<Definitions>() {
                public Definitions run() throws ContributionReadException {
View Full Code Here


        urlArtifactProcessor = (URLArtifactProcessor)documentProcessors.getProcessor(Definitions.class);
    }

    public Definitions getDefinitions() throws DefinitionsProviderException {
        final URL definitionsFileUrl = getClass().getClassLoader().getResource(definitionsFile);
        Definitions scaDefn = null;
        try {
            final URI uri = new URI(definitionsFile);
            // Allow bindings to read properties. Requires PropertyPermission read in security policy.
            scaDefn = AccessController.doPrivileged(new PrivilegedExceptionAction<Definitions>() {
                public Definitions run() throws ContributionReadException {
View Full Code Here

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

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

    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);
               
        InputStream is = getClass().getResourceAsStream("Calculator.composite");
        XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
        Composite composite = (Composite)staxProcessor.read(reader);
        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);
               
        InputStream is = getClass().getResourceAsStream("Calculator.composite");
        XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
        Composite composite = (Composite)staxProcessor.read(reader);
        assertNotNull(composite);
       
        for ( Component component : composite.getComponents() ) {
            for ( PolicySet policySet : policyDefinitions.getPolicySets() ) {
                component.getApplicablePolicySets().add(policySet);
            }
        }
       
        staxProcessor.resolve(policyDefinitions, resolver);
View Full Code Here

        composite = (Composite)documentProcessor.read(null, uri, url);
        assertNotNull(composite);
       
        url = BuildPolicyTestCase.class.getResource("another_test_definitions.xml");
        uri = URI.create("another_test_definitions.xml");
        Definitions definitions = (Definitions)policyDefinitionsProcessor.read(null, uri, url);
        assertNotNull(definitions);
        policyDefinitions.add(definitions);
       
        documentProcessor.resolve(definitions, resolver);
        documentProcessor.resolve(composite, resolver);
View Full Code Here

            }

            //urlStream = createInputStream(url);
            XMLStreamReader reader = inputFactory.createXMLStreamReader(url.toString(), urlStream);

            Definitions definitions = definitionsFactory.createDefinitions();
            QName name = null;
            int event;
            while (reader.hasNext()) {
                event = reader.next();

                if (event == XMLStreamConstants.START_ELEMENT || event == XMLStreamConstants.END_ELEMENT) {
                    name = reader.getName();
                    if (name.equals(DEFINITIONS_QNAME)) {
                        if (event == XMLStreamConstants.END_ELEMENT) {
                            return definitions;
                        }
                    } else {
                        Definitions aDefn = (Definitions)extensionProcessor.read(reader);
                        DefinitionsUtil.aggregate(aDefn, definitions);
                    }
                }
            }
View Full Code Here

        this.definitionsFactory = factoryExtensionPoint.getFactory(DefinitionsFactory.class);
    }

    public Definitions read(XMLStreamReader reader) 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 (SCA_DEFINITIONS_QNAME.equals(name)) {
                        definitions = definitionsFactory.createDefinitions();
                        targetNamespace = reader.getAttributeValue(null, TARGET_NAMESPACE);
                        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()));
                                definitions.getPolicySets().add(policySet);
                            } else if (extension instanceof Binding) {
                                Binding binding = (Binding)extension;
                                definitions.getBindings().add(binding);
                            } else if (extension instanceof IntentAttachPointType) {
                                IntentAttachPointType type = (IntentAttachPointType)extension;
                                if (type.getName().getLocalPart().startsWith(BINDING)) {
                                    definitions.getBindingTypes().add((IntentAttachPointType)extension);
                                } else if (type.getName().getLocalPart().startsWith(IMPLEMENTATION)) {
                                    definitions.getImplementationTypes().add((IntentAttachPointType)extension);
                                }
                            }
                        }
                        break;
                    }
View Full Code Here

        URLArtifactProcessorExtensionPoint documentProcessors = registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
        urlArtifactProcessor = (URLArtifactProcessor)documentProcessors.getProcessor(Definitions.class);
    }

    public Definitions getDefinitions() throws DefinitionsProviderException {
        Definitions scaDefns = null;
        Definitions tuscanyDefns = null;
        try {
            // Allow privileged access to load resource. Requires RuntimePermssion in security policy.
            URL definitionsFileUrl = AccessController.doPrivileged(new PrivilegedAction<URL>() {
                public URL run() {
                    return getClass().getClassLoader().getResource(definitionsFile);
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.