Package org.apache.tuscany.sca.contribution

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


    private Contribution contribution(List<Contribution> contributions, String compositeURI) {
        if (compositeURI != null && compositeURI.startsWith("/")) {
            compositeURI = compositeURI.substring(1);
        }
        ContributionFactory contributionFactory = modelFactories.getFactory(ContributionFactory.class);
        Artifact compositeFile = contributionFactory.createArtifact();
        compositeFile.setUnresolved(true);
        compositeFile.setURI(compositeURI);
        for (Contribution c : contributions) {
            ModelResolver resolver = c.getModelResolver();
            Artifact resolved = resolver.resolveModel(Artifact.class, compositeFile);
            if (resolved != null && !resolved.isUnresolved()) {
                return c;
            }
        }
        return null;
    }
View Full Code Here


                URL url = null;
                if (importLocation.startsWith("/")) {
                    // The URI is relative to the contribution
                    String uri = importLocation.substring(1);

                    Artifact proxyArtifact = contributionFactory.createArtifact();
                    proxyArtifact.setURI(uri);

                    //use contribution resolution (this supports import/export)
                    Artifact importedArtifact =
                        contribution.getModelResolver().resolveModel(Artifact.class, proxyArtifact);
                    if (importedArtifact.getLocation() != null) {
                        //get the artifact URL
                        url = new URL(importedArtifact.getLocation());
                    }
                } else {
                    url = new URL(new URL(parentLocation), importLocation);
                }
                if (url == null) {
View Full Code Here

            resolveContracts(component, component.getServices(), resolver);
            resolveContracts(component, component.getReferences(), resolver);
           
            for (ComponentProperty componentProperty : component.getProperties()) {
                if (componentProperty.getFile() != null) {
                    Artifact artifact = contributionFactory.createArtifact();
                    artifact.setURI(componentProperty.getFile());
                    artifact = resolver.resolveModel(Artifact.class, artifact);
                    if (artifact.getLocation() != null) {
                        componentProperty.setFile(artifact.getLocation());
                    }
                }
            }
           
            //resolve component implementation
View Full Code Here

        List<String> artifactURIs = scanner.getArtifacts(contributionURL);
        for (String artifactURI: artifactURIs) {
            URL artifactURL = scanner.getArtifactURL(contributionURL, artifactURI);

            // Add the deployed artifact model to the contribution
            Artifact artifact = this.contributionFactory.createArtifact();
            artifact.setURI(artifactURI);
            artifact.setLocation(artifactURL.toString());
            artifacts.add(artifact);
            modelResolver.addModel(artifact);

            // Read each artifact
            Object model = artifactProcessor.read(contributionURL, URI.create(artifactURI), artifactURL);
            if (model != null) {
                artifact.setModel(model);

                // Add the loaded model to the model resolver
                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
        // all composites in the contribution as deployables
        if (!contributionMetadata) {
            for (Artifact artifact: artifacts) {
                if (artifact.getModel() instanceof Composite) {
                    contribution.getDeployables().add((Composite)artifact.getModel());
                }
            }

            // Add default contribution import and export
            DefaultImport defaultImport = contributionFactory.createDefaultImport();
View Full Code Here

        composite = configuration.getComposite();
       
        if(composite != null && composite.isUnresolved()) {
            ContributionFactory contributionFactory = modelFactories.getFactory(ContributionFactory.class);
            Artifact compositeFile = contributionFactory.createArtifact();
            compositeFile.setUnresolved(true);
            compositeFile.setURI(composite.getURI());
            for (Contribution c : contributions) {
                ModelResolver resolver = c.getModelResolver();
                Artifact resolved = resolver.resolveModel(Artifact.class, compositeFile);
                if (resolved != null && resolved.isUnresolved() == false) {
                    composite = (Composite) resolved.getModel();
                    break;
                }
            }
        }
View Full Code Here

    private String location(Contribution contribution, String uri) {
        if (uri != null && uri.startsWith("/")) {
            uri = uri.substring(1);
        }
        ContributionFactory contributionFactory = modelFactories.getFactory(ContributionFactory.class);
        Artifact compositeFile = contributionFactory.createArtifact();
        compositeFile.setUnresolved(true);
        compositeFile.setURI(uri);
        ModelResolver resolver = contribution.getModelResolver();
        Artifact resolved = resolver.resolveModel(Artifact.class, compositeFile);
        if (resolved != null && !resolved.isUnresolved()) {
            return resolved.getLocation();
        } else {
            return null;
        }
    }
View Full Code Here

    private Contribution contribution(List<Contribution> contributions, String compositeURI) {
        if (compositeURI != null && compositeURI.startsWith("/")) {
            compositeURI = compositeURI.substring(1);
        }
        ContributionFactory contributionFactory = modelFactories.getFactory(ContributionFactory.class);
        Artifact compositeFile = contributionFactory.createArtifact();
        compositeFile.setUnresolved(true);
        compositeFile.setURI(compositeURI);
        for (Contribution c : contributions) {
            ModelResolver resolver = c.getModelResolver();
            Artifact resolved = resolver.resolveModel(Artifact.class, compositeFile);
            if (resolved != null && !resolved.isUnresolved()) {
                return c;
            }
        }
        return null;
    }
View Full Code Here

    private void defineFromXSD(SDOTypes importSDO, ModelResolver resolver) throws ContributionResolveException {
        String location = importSDO.getSchemaLocation();
        if (location != null) {
            try {
                Artifact artifact = contributionFactory.createArtifact();
                artifact.setURI(location);
                artifact = resolver.resolveModel(Artifact.class, artifact);
                if (artifact.getLocation() != null) {
                    String wsdlURL = artifact.getLocation();
                    URLConnection connection = new URL(wsdlURL).openConnection();
                    connection.setUseCaches(false);
                    InputStream xsdInputStream = connection.getInputStream();
                    try {
                        XSDHelper xsdHelper = helperContext.getXSDHelper();
View Full Code Here

    /**
     * Add a composite model to the contribution
     */
    public void addDeploymentComposite(Contribution contribution, Composite composite) throws ContributionException {
        Artifact artifact = this.contributionFactory.createArtifact();
        artifact.setURI(composite.getURI());
        artifact.setModel(composite);

        contribution.getArtifacts().add(artifact);

        contribution.getDeployables().add(composite);
    }
View Full Code Here

                compositeUris.add(anArtifactUri);
            } else {
                URL artifactURL = packageProcessor.getArtifactURL(new URL(contribution.getLocation()), anArtifactUri);

                // Add the deployed artifact model to the resolver
                Artifact artifact = this.contributionFactory.createArtifact();
                artifact.setURI(anArtifactUri.toString());
                artifact.setLocation(artifactURL.toString());
                contribution.getArtifacts().add(artifact);
                modelResolver.addModel(artifact);

                model = this.artifactProcessor.read(contributionURL, anArtifactUri, artifactURL);

                if (model != null) {
                    artifact.setModel(model);

                    // Add the loaded model to the model resolver
                    modelResolver.addModel(model);

                    // Add policy definitions to the list of policy definitions
                    if (model instanceof SCADefinitions) {
                        policyDefinitions.add(model);

                        SCADefinitions definitions = (SCADefinitions)model;
                        for (Intent intent : definitions.getPolicyIntents() ) {
                            policyDefinitionsResolver.addModel(intent);
                        }

                        for (PolicySet policySet : definitions.getPolicySets() ) {
                            policyDefinitionsResolver.addModel(policySet);
                        }

                        for (IntentAttachPointType attachPointType : definitions.getBindingTypes() ) {
                            policyDefinitionsResolver.addModel(attachPointType);
                        }

                        for (IntentAttachPointType attachPointType : definitions.getImplementationTypes() ) {
                            policyDefinitionsResolver.addModel(attachPointType);
                        }
                        for (Object binding : definitions.getBindings() ) {
                            policyDefinitionsResolver.addModel(binding);
                        }
                    }
                }
            }
        }

        for (URI anArtifactUri : compositeUris) {
            URL artifactURL = packageProcessor.getArtifactURL(new URL(contribution.getLocation()), anArtifactUri);

            // Add the deployed artifact model to the resolver
            Artifact artifact = this.contributionFactory.createArtifact();
            artifact.setURI(anArtifactUri.toString());
            artifact.setLocation(artifactURL.toString());
            contribution.getArtifacts().add(artifact);
            modelResolver.addModel(artifact);

            model = this.artifactProcessor.read(contributionURL, anArtifactUri, artifactURL);
            if (model != null) {
                artifact.setModel(model);
                // Add the loaded model to the model resolver
                modelResolver.addModel(model);
            }
        }
    }
View Full Code Here

TOP

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

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.