Package org.apache.tuscany.sca.contribution

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


                resolveContracts(component, component.getReferences(), resolver, context);

                for (ComponentProperty componentProperty : component.getProperties()) {
                    // resolve a reference to a property file
                    if (componentProperty.getFile() != null) {
                        Artifact artifact = contributionFactory.createArtifact();
                        artifact.setURI(componentProperty.getFile());
                        artifact = resolver.resolveModel(Artifact.class, artifact, context);
                        if (artifact.getLocation() != null) {
                            componentProperty.setFile(artifact.getLocation());
                        }
                    }
                   
                    // resolve the reference to a complex property
                    resolvePropertyType("component " + component.getName(),
View Full Code Here


        boolean contributionMetadata = false;
        for (String artifactURI: scanner.getArtifacts(contributionURL)) {
            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 Contribution) {
                    contributionMetadata = true;
                    Contribution c = (Contribution)model;
                    contribution.getImports().addAll(c.getImports());
                    contribution.getExports().addAll(c.getExports());
                    contribution.getDeployables().addAll(c.getDeployables());
                }
            }
        }
       
        // 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());
                }
            }
        }
       
        return contribution;
View Full Code Here

    }

    public void resolve(ResourceImplementation implementation, ModelResolver resolver) throws ContributionResolveException {
       
        // Resolve the resource directory location
        Artifact artifact = contributionFactory.createArtifact();
        artifact.setURI(implementation.getLocation());
        Artifact resolved = resolver.resolveModel(Artifact.class, artifact);
        if (resolved.getLocation() != null) {
            try {
                implementation.setLocationURL(new URL(resolved.getLocation()));
                implementation.setUnresolved(false);
            } catch (IOException e) {
                throw new ContributionResolveException(e);
            }
        }
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

     * 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

    public ArtifactModelResolver(Contribution contribution, ModelFactoryExtensionPoint modelFactories) {
      this.contribution = contribution;
    }

    public void addModel(Object resolved) {
      Artifact artifact = (Artifact)resolved;
        map.put(artifact.getURI(), artifact);
    }
View Full Code Here

        if (uri == null) {
          return (T)unresolved;
        }
       
        //lookup the componentType
        Artifact resolved = (Artifact) map.get(uri);
        if (resolved != null) {
            return modelClass.cast(resolved);
        }
       
        //If not found, delegate the resolution to the imports (in this case based on the resource imports)

        for (Import import_ : this.contribution.getImports()) {
            if (import_ instanceof ResourceImport) {
              ResourceImport resourceImport = (ResourceImport)import_;
              //check the import location against the computed package name from the componentType URI
                if (resourceImport.getURI().equals(uri)) {
                    // Delegate the resolution to the import resolver
                    resolved = resourceImport.getModelResolver().resolveModel(Artifact.class, (Artifact)unresolved);
                    if (!resolved.isUnresolved()) {
                        return modelClass.cast(resolved);
                    }
                }
            }
        }
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 implemenation
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);
                   
                    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

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.