Package org.apache.tuscany.sca.contribution

Examples of org.apache.tuscany.sca.contribution.ContributionMetadata


                        modelResolver.addModel(model, context);
       
                        // Merge contribution metadata into the contribution model
                        if (model instanceof ContributionMetadata) {
                            contributionMetadata = true;
                            ContributionMetadata c = (ContributionMetadata)model;
                            contribution.getImports().addAll(c.getImports());
                            contribution.getExports().addAll(c.getExports());
                            contribution.getDeployables().addAll(c.getDeployables());
                            contribution.getExtensions().addAll(c.getExtensions());
                            contribution.getAttributeExtensions().addAll(c.getAttributeExtensions());
                        }
                    }
                } finally {
                    monitor.popContext();
                    context.setArtifact(oldArtifact);
View Full Code Here


        installContribution(contribution, dependentContributionURIs, runDeployables);
        return uri;
    }

    private void mergeContributionMetaData(String metaDataURL, Contribution contribution) throws ValidationException {
        ContributionMetadata metaData;
        Monitor monitor = deployer.createMonitor();
        try {
            metaData = deployer.loadXMLDocument(IOHelper.getLocationAsURL(metaDataURL), monitor);
        } catch (Exception e) {
            throw new ValidationException(e);
        }
        monitor.analyzeProblems();
        contribution.getDeployables().addAll(metaData.getDeployables());
        contribution.getImports().addAll(metaData.getImports());
        contribution.getExports().addAll(metaData.getExports());
    }
View Full Code Here

        return contribution;
    }

    private void readContributionMetadata(Contribution contribution) {
        ContributionMetadata m1 = null, m2 = null;
        for(Artifact a: contribution.getArtifacts()) {
            if(Contribution.SCA_CONTRIBUTION_GENERATED_META.equals(a.getURI())) {
                m1 = (ContributionMetadata) a.getModel();
            }
            if(Contribution.SCA_CONTRIBUTION_META.equals(a.getURI())) {
                m2 = (ContributionMetadata) a.getModel();
            }
        }
        if (m1 != null) {
            contribution.getImports().addAll(m1.getImports());
            contribution.getExports().addAll(m1.getExports());
            contribution.getDeployables().addAll(m1.getDeployables());
        }
        if (m2 != null) {
            contribution.getImports().addAll(m2.getImports());
            contribution.getExports().addAll(m2.getExports());
            contribution.getDeployables().addAll(m2.getDeployables());
View Full Code Here

        staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory, null);
    }

    public void testRead() throws Exception {
        XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(VALID_XML));
        ContributionMetadata contribution = (ContributionMetadata)staxProcessor.read(reader);
        assertNotNull(contribution);
        assertEquals(2, contribution.getDeployables().size());
        assertEquals(1, contribution.getAttributeExtensions().size());
        assertEquals(1, contribution.getExtensions().size());
  }
View Full Code Here

        assertEquals("AttributeCompositeMissing", problem.getMessageId());
    }

    public void testWrite() throws Exception {
        XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(VALID_XML));
        ContributionMetadata contribution = (ContributionMetadata)staxProcessor.read(reader);

        validateContribution(contribution);

        //write the contribution metadata contents
        StringWriter stringWriter = new StringWriter();
View Full Code Here

            urlStream = connection.getInputStream();
            XMLStreamReader reader = inputFactory.createXMLStreamReader(urlStream);
            reader.nextTag();
           
            // Read the contribution model
            ContributionMetadata contribution = (ContributionMetadata)staxProcessor.read(reader);

            return contribution;
           
        } catch (XMLStreamException e) {
          ContributionReadException ex = new ContributionReadException(e);
View Full Code Here

    public Class<ContributionMetadata> getModelType() {
        return ContributionMetadata.class;
    }

    public ContributionMetadata read(XMLStreamReader reader) throws ContributionReadException {
        ContributionMetadata contribution = null;
        QName name = null;

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

                        if (CONTRIBUTION_QNAME.equals(name)) {

                            // Read <contribution>
                            contribution = this.contributionFactory.createContributionMetadata();
                            contribution.setUnresolved(true);
                            readExtendedAttributes(reader, contribution, attributeProcessor, extensionFactory);

                        } else if (DEPLOYABLE_QNAME.equals(name)) {

                            // Read <deployable>
                            QName compositeName = getQName(reader, "composite");
                            if (compositeName == null) {
                                error("AttributeCompositeMissing", reader);
                                //throw new ContributionReadException("Attribute 'composite' is missing");
                            } else {
                                if (contribution != null) {
                                    Composite composite = assemblyFactory.createComposite();
                                    composite.setName(compositeName);
                                    composite.setUnresolved(true);
                                    contribution.getDeployables().add(composite);
                                }
                            }
                        } else {

                            // Read an extension element
                            Object extension = extensionProcessor.read(reader);
                            if (extension != null && contribution != null) {
                                if (extension instanceof Import) {
                                    contribution.getImports().add((Import)extension);
                                } else if (extension instanceof Export) {
                                    contribution.getExports().add((Export)extension);
                                } else {
                                    contribution.getExtensions().add(extension);
                                }
                            }
                        }
                        break;
View Full Code Here

                }

                // Merge contribution metadata into the contribution model
                if (model instanceof ContributionMetadata) {
                    contributionMetadata = true;
                    ContributionMetadata c = (ContributionMetadata)model;
                    contribution.getImports().addAll(c.getImports());
                    contribution.getExports().addAll(c.getExports());
                    contribution.getDeployables().addAll(c.getDeployables());
                    contribution.getExtensions().addAll(c.getExtensions());
                    contribution.getAttributeExtensions().addAll(c.getAttributeExtensions());
                }
            }
        }

        // If no sca-contribution.xml file was provided then just consider
View Full Code Here

                continue;
            }
            contributionMetadata = true;

            // Read the sca-contribution.xml file
            ContributionMetadata c = (ContributionMetadata)artifactProcessor.read(contributionURL, URI.create(path), url);
            contribution.getImports().addAll(c.getImports());
            contribution.getExports().addAll(c.getExports());
            contribution.getDeployables().addAll(c.getDeployables());
            contribution.getExtensions().addAll(c.getExtensions());
            contribution.getAttributeExtensions().addAll(c.getAttributeExtensions());
        }

        // If no sca-contribution.xml file was provided then consider
        // all composites in the contribution as deployables, and also
        // read any files that are explicitly asssigned artifact processors
View Full Code Here

                modelResolver.addModel(model);

                // Merge contribution metadata into the contribution model
                if (model instanceof ContributionMetadata) {
                    contributionMetadata = true;
                    ContributionMetadata c = (ContributionMetadata)model;
                    contribution.getImports().addAll(c.getImports());
                    contribution.getExports().addAll(c.getExports());
                    contribution.getDeployables().addAll(c.getDeployables());
                    contribution.getExtensions().addAll(c.getExtensions());
                    contribution.getAttributeExtensions().addAll(c.getAttributeExtensions());
                }
            }
        }

        // If no sca-contribution.xml file was provided then just consider
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.contribution.ContributionMetadata

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.