Package org.apache.tuscany.sca.contribution.namespace

Examples of org.apache.tuscany.sca.contribution.namespace.NamespaceExport


        contribB.getImports().add(import1_);
       
        JavaExport export = javaImportExportFactory.createJavaExport();
        export.setPackage(this.getClass().getPackage().getName());
        contribA.getExports().add(export);
        NamespaceExport export1 = namespaceImportExportFactory.createNamespaceExport();
        export1.setNamespace("calculator");
        contribC.getExports().add(export1);

        // Load resource from parent
        URL resB = contribB.getClassLoader().getResource("deployables/sample-calculator.jar");
        Assert.assertNotNull(resB);
View Full Code Here


    /**
     * Process <export namespace=""/>
     */
    public NamespaceExport read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException {
        NamespaceExport namespaceExport = this.factory.createNamespaceExport();
        QName element = null;

        try {
            while (reader.hasNext()) {
                int event = reader.getEventType();
                switch (event) {
                    case START_ELEMENT:
                        element = reader.getName();

                        // Read <export>
                        if (EXPORT.equals(element)) {
                            String ns = reader.getAttributeValue(null, NAMESPACE);
                            if (ns == null) {
                              error(context.getMonitor(), "AttributeNameSpaceMissing", reader);
                                //throw new ContributionReadException("Attribute 'namespace' is missing");
                            } else {
                                namespaceExport.setNamespace(ns);
                            }
                            readExtendedAttributes(reader, namespaceExport, attributeProcessor, extensionFactory, context);
                        } else {
                            //read extended elements
                            Object ext = extensionProcessor.read(reader, context);
                            if (namespaceExport != null) {
                                namespaceExport.getExtensions().add(ext);
                            }
                        }

                        break;
                    case XMLStreamConstants.END_ELEMENT:
View Full Code Here

    /**
     * Process <export namespace=""/>
     */
    public NamespaceExport read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException {
        NamespaceExport namespaceExport = this.factory.createNamespaceExport();
        QName element = null;

        try {
            while (reader.hasNext()) {
                int event = reader.getEventType();
                switch (event) {
                    case START_ELEMENT:
                        element = reader.getName();

                        // Read <export>
                        if (EXPORT.equals(element)) {
                            String ns = reader.getAttributeValue(null, NAMESPACE);
                            if (ns == null) {
                              error(context.getMonitor(), "AttributeNameSpaceMissing", reader);
                                //throw new ContributionReadException("Attribute 'namespace' is missing");
                            } else {
                                namespaceExport.setNamespace(ns);
                            }
                            readExtendedAttributes(reader, namespaceExport, attributeProcessor, extensionFactory, context);
                        } else {
                            //read extended elements
                            Object ext = extensionProcessor.read(reader, context);
                            if (namespaceExport != null) {
                                namespaceExport.getExtensions().add(ext);
                            }
                        }

                        break;
                    case XMLStreamConstants.END_ELEMENT:
View Full Code Here

                    if (targetContribution != null) {
                   
                        // Find a matching contribution export
                        for (Export export: targetContribution.getExports()) {
                            if (export instanceof NamespaceExport) {
                                NamespaceExport namespaceExport = (NamespaceExport)export;
                                if (namespaceImport.getNamespace().equals(namespaceExport.getNamespace())) {
                                    namespaceImport.setModelResolver(namespaceExport.getModelResolver());
                                    initialized = true;
                                    break;
                                }
                            }
                        }
View Full Code Here

   
    /**
     * Process <export namespace=""/>
     */
    public NamespaceExport read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
        NamespaceExport namespaceExport = this.factory.createNamespaceExport();
        QName element = null;
       
        while (reader.hasNext()) {
            int event = reader.getEventType();
            switch (event) {
                case START_ELEMENT:
                    element = reader.getName();
                   
                    // Read <export>
                    if (EXPORT.equals(element)) {
                        String ns = reader.getAttributeValue(null, NAMESPACE);
                        if (ns == null) {
                            throw new ContributionReadException("Attribute 'namespace' is missing");
                        }
                        namespaceExport.setNamespace(ns);
                    }
                   
                    break;
                case XMLStreamConstants.END_ELEMENT:
                    if (EXPORT.equals(reader.getName())) {
View Full Code Here

        XMLStreamReader reader = xmlFactory.createXMLStreamReader(new StringReader(VALID_XML));

        ModelFactoryExtensionPoint factories = new DefaultModelFactoryExtensionPoint();
        factories.addFactory(new NamespaceImportExportFactoryImpl());
        NamespaceExportProcessor exportProcessor = new NamespaceExportProcessor(factories);
        NamespaceExport namespaceExport = exportProcessor.read(reader);
       
        assertEquals("http://foo", namespaceExport.getNamespace());
    }
View Full Code Here

        importer.getImports().add(import_);

        Contribution imported = contributionFactory.createContribution();
        imported.setURI("imported");
        workspace.getContributions().add(imported);
        NamespaceExport export = importExportFactory.createNamespaceExport();
        export.setNamespace("http://foo");
        imported.getExports().add(export);
        import_ = importExportFactory.createNamespaceImport();
        import_.setNamespace("http://bar");
        imported.getImports().add(import_);
       
        Contribution imported2 = contributionFactory.createContribution();
        imported2.setURI("imported2");
        workspace.getContributions().add(imported2);
        export = importExportFactory.createNamespaceExport();
        export.setNamespace("http://bar");
        imported2.getExports().add(export);
       
        Contribution another = contributionFactory.createContribution();
        another.setURI("another");
        workspace.getContributions().add(another);
        export = importExportFactory.createNamespaceExport();
        export.setNamespace("http://another");
        another.getExports().add(export);
       
        ContributionDependencyBuilderImpl analyzer = new ContributionDependencyBuilderImpl(null);
        List<Contribution> dependencies = analyzer.buildContributionDependencies(workspace, importer);
        assertTrue(dependencies.size() == 3);
View Full Code Here

     * @throws Exception
     */
    @Test
    public void testLoad() throws Exception {
        XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(VALID_XML));
        NamespaceExport namespaceExport = (NamespaceExport)staxProcessor.read(reader, context);
        assertEquals("http://foo", namespaceExport.getNamespace());
        assertEquals(1, namespaceExport.getAttributeExtensions().size());
        assertEquals(1, namespaceExport.getExtensions().size());
    }
View Full Code Here

        importer.getImports().add(import_);

        Contribution imported = contributionFactory.createContribution();
        imported.setURI("imported");
        workspace.getContributions().add(imported);
        NamespaceExport export = importExportFactory.createNamespaceExport();
        export.setNamespace("http://foo");
        imported.getExports().add(export);
        import_ = importExportFactory.createNamespaceImport();
        import_.setNamespace("http://bar");
        imported.getImports().add(import_);
       
        Contribution imported2 = contributionFactory.createContribution();
        imported2.setURI("imported2");
        workspace.getContributions().add(imported2);
        export = importExportFactory.createNamespaceExport();
        export.setNamespace("http://bar");
        imported2.getExports().add(export);
       
        Contribution another = contributionFactory.createContribution();
        another.setURI("another");
        workspace.getContributions().add(another);
        export = importExportFactory.createNamespaceExport();
        export.setNamespace("http://another");
        another.getExports().add(export);
       
        ContributionDependencyBuilderImpl builder = new ContributionDependencyBuilderImpl(null);
        builder.build(importer, workspace, null);
        List<Contribution> dependencies = importer.getDependencies();
View Full Code Here

   
    /**
     * Process <export namespace=""/>
     */
    public NamespaceExport read(XMLStreamReader reader) throws ContributionReadException {
        NamespaceExport namespaceExport = this.factory.createNamespaceExport();
        QName element = null;
       
        try {
            while (reader.hasNext()) {
                int event = reader.getEventType();
                switch (event) {
                    case START_ELEMENT:
                        element = reader.getName();
                       
                        // Read <export>
                        if (EXPORT.equals(element)) {
                            String ns = reader.getAttributeValue(null, NAMESPACE);
                            if (ns == null) {
                              error("AttributeNameSpaceMissing", reader);
                                //throw new ContributionReadException("Attribute 'namespace' is missing");
                            } else
                                namespaceExport.setNamespace(ns);
                        }
                       
                        break;
                    case XMLStreamConstants.END_ELEMENT:
                        if (EXPORT.equals(reader.getName())) {
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.contribution.namespace.NamespaceExport

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.