Package org.apache.tuscany.sca.contribution

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


                    // Add the deployed artifact model to the contribution
                    modelResolver.addModel(artifact, context);

                    monitor.pushContext("Artifact: " + artifact.getURI());

                    Artifact oldArtifact = context.setArtifact(artifact);
                    try {
                        // Read each artifact
                        URL artifactLocationURL = null;
                        try {
                            artifactLocationURL = new URL(artifact.getLocation());
View Full Code Here


            // Resolve all artifact models
            for (Artifact artifact : contribution.getArtifacts()) {
                Object model = artifact.getModel();
                if (model != null) {
                    Artifact oldArtifact = context.setArtifact(artifact);
                    try {
                        artifactProcessor.resolve(model, contributionResolver, context);
                    } catch (Throwable e) {
                        throw new ContributionResolveException(e);
                    } finally {
                        context.setArtifact(oldArtifact);
                    }
                }
            }

            // Resolve deployable composites
            List<Composite> deployables = contribution.getDeployables();
            Artifact oldArtifact = context.setArtifact(contribution);
            try {
                for (int i = 0, n = deployables.size(); i < n; i++) {
                    Composite deployable = deployables.get(i);
                    Composite resolved =
                        (Composite)contributionResolver.resolveModel(Composite.class, deployable, context);
View Full Code Here

    }

    @Test
    public void testResolvedArtifact() {
        ProcessorContext context = new ProcessorContext();
        Artifact artifact = factory.createArtifact();
        artifact.setURI("foo/bar");
        resolver.addModel(artifact, context);
        Artifact x = factory.createArtifact();
        x.setURI("foo/bar");
        x = resolver.resolveModel(Artifact.class, x, context);
        assertTrue(x == artifact);
    }
View Full Code Here

        assertTrue(x == y);
    }

    @Test
    public void testResolvedArtifact() {
        Artifact artifact = factory.createArtifact();
        artifact.setURI("foo/bar");
        resolver.addModel(artifact, context);
        Artifact x = factory.createArtifact();
        x.setURI("foo/bar");
        x = resolver.resolveModel(Artifact.class, x, context);
        assertTrue(x == artifact);
    }
View Full Code Here

        List<String> artifactURIs = scanContributionArtifacts(contribution);
        for(String uri : artifactURIs) {
            try {
                File file = new File(directory, uri);

                Artifact artifact = contributionFactory.createArtifact();
                artifact.setURI(uri);
                artifact.setLocation(file.toURI().toURL().toString());

                artifacts.add(artifact);
            } catch (MalformedURLException e) {
                throw new ContributionReadException(e);
            }
View Full Code Here

                }

                // Return list of artifacts
                List<Artifact> artifacts = new ArrayList<Artifact>();
                for(String uri : names) {
                    Artifact artifact = contributionFactory.createArtifact();
                    artifact.setURI(uri);
                    artifact.setLocation(getArtifactURL(contribution, uri).toString());
                   
                    artifacts.add(artifact);
                }
               
                contribution.getTypes().add(getContributionType());
View Full Code Here

     * introspector
     */
    public void resolve(XQueryImplementation xqueryImplementation, ModelResolver resolver)
        throws ContributionResolveException {

        Artifact artifact = contributionFactory.createArtifact();
        artifact.setURI(xqueryImplementation.getLocation());
      artifact = resolver.resolveModel(Artifact.class, artifact);
      if (artifact.getLocation() == null) {
            throw new ContributionResolveException("Could not locate file: " + xqueryImplementation.getLocation());
        }
      xqueryImplementation.setLocationURL(artifact.getLocation());

        XQueryIntrospector introspector = new XQueryIntrospector(assemblyFactory, javaFactory);

        boolean success = introspector.introspect(xqueryImplementation, resolver);

View Full Code Here

    private void importWSDL(ImportSDO 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) {
                    ContributionResolveException loaderException =
                        new ContributionResolveException("Fail to resolve location: " + location);
                    throw loaderException;
                }

                String wsdlURL = artifact.getLocation();
                URLConnection connection = new URL(wsdlURL).openConnection();
                connection.setUseCaches(false);
                InputStream xsdInputStream = connection.getInputStream();
                try {
                    XSDHelper xsdHelper = importSDO.getHelperContext().getXSDHelper();
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);
                   
                    if ( isSCADefnsFile(anArtifactUri) ) {
                        scaDefinitionsSink.add(model);
                    }
                }
            }
        }
       
        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

        Model y = resolver.resolveModel(Model.class, x);
        assertTrue(x == y);
    }
       
    public void testResolvedArtifact() {
        Artifact artifact = factory.createArtifact();
        artifact.setURI("foo/bar");
        resolver.addModel(artifact);
        Artifact x = factory.createArtifact();
        x.setURI("foo/bar");
        x = resolver.resolveModel(Artifact.class, x);
        assertTrue(x == artifact);
    }
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.