Package org.apache.tuscany.sca.contribution

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


     * Return an artifact builder.
     */
    static Builder<Artifact> artifact(final String uri, final Object model) {
        return new Builder<Artifact>() {
            public Artifact build(final Context ec) {
                final Artifact a = ec.cf.createArtifact();
                a.setURI(uri);
                a.setModel(model);
                return a;
            }
        };
    }
View Full Code Here


    private void importWSDL(ImportSDO importSDO, ModelResolver resolver,ProcessorContext context) throws ContributionResolveException {
        String location = importSDO.getSchemaLocation();
        if (location != null) {
            try {
                Artifact artifact = contributionFactory.createArtifact();
                artifact.setURI(location);
                artifact = resolver.resolveModel(Artifact.class, artifact,context);
                if (artifact.getLocation() != null) {
                  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

        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

            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

    }

    public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {

        // Filter based on the artifact URI
        Artifact artifact = (Artifact)unresolved;
        if (export.getURI().equals(artifact.getURI())) {

            // The artifact URI matches the exported URI, delegate to the
            // contribution's resolver
            return resolver.resolveModel(modelClass, unresolved, context);
        } else {
View Full Code Here

        }
    }

    @Override
    public void addComposite(Composite composite) {
        Artifact a = new ArtifactImpl();
        a.setURI(composite.getURI());
        a.setModel(composite);
        a.setUnresolved(false);
        artifacts.add(a);
    }
View Full Code Here

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

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

        if (uri == null) {
          return (T)unresolved;
        }

        // Lookup the artifact
        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)) &&
                    (resourceImport.getModelResolver() != null)){
                    // Delegate the resolution to the import resolver
                    resolved = resourceImport.getModelResolver().resolveModel(Artifact.class, (Artifact)unresolved, context);
                    if (!resolved.isUnresolved()) {
                        return modelClass.cast(resolved);
                    }
                }
            }
        }
View Full Code Here

     *
     * @param artifact The new artifact
     * @return The old artifact
     */
    public Artifact setArtifact(Artifact artifact) {
        Artifact old = this.artifact;
        this.artifact = artifact;
        return old;
    }
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.