Package org.apache.tuscany.sca.contribution

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


        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


    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

    }

    public void resolve(WidgetImplementation 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);
               
                //introspect implementation
                WidgetImplementationIntrospector widgetIntrospector = new WidgetImplementationIntrospector(assemblyFactory, implementation);
                widgetIntrospector.introspectImplementation();
View Full Code Here

        // (for example it's an existing JAR developed before SCA existed)
        // export all its Java packages
        ModelResolver modelResolver = contribution.getModelResolver();
       
        // Look for META-INF/sca-contribution.xml
        Artifact artifact = contributionFactory.createArtifact();
        artifact.setURI(Contribution.SCA_CONTRIBUTION_META);
        artifact = modelResolver.resolveModel(Artifact.class, artifact);
        if (artifact.getLocation() == null) {

            // Look for META-INF/sca-contribution-generated.xml
            artifact.setURI(Contribution.SCA_CONTRIBUTION_GENERATED_META);
            artifact = modelResolver.resolveModel(Artifact.class, artifact);
            if (artifact.getLocation() == null) {
               
                // No contribution metadata file was found, default to export all the
                // Java packages found in the contribution
                Set<String> packages = new HashSet<String>();
                for (Artifact a: contribution.getArtifacts()) {
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

            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

                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

    public void resolve(ModelResolver resolver) {
     
      if (scriptName != null) {
          //FIXME The contribution factory should be injected
          ContributionFactory contributionFactory = new DefaultContributionFactory();
            Artifact artifact = contributionFactory.createArtifact();
            artifact.setURI(scriptName);
            artifact = resolver.resolveModel(Artifact.class, artifact);
            if (artifact.getLocation() != null) {
                try {
                    scriptURL = new URL(artifact.getLocation());
                } catch (MalformedURLException e) {
                    throw new RuntimeException(e);
                }
            }
      }
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.