Package org.apache.tuscany.sca.contribution

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


            composite = getDefaultComposite(configuration, workspace);
        }

        // Find the composite in the given contributions
        boolean found = false;
        Artifact compositeFile = contributionFactory.createArtifact();
        compositeFile.setUnresolved(true);
        compositeFile.setURI(composite.getURI());
        for (Contribution contribution : workspace.getContributions()) {
            ModelResolver resolver = contribution.getModelResolver();
            //            for (Artifact artifact : contribution.getArtifacts()){
            //                logger.log(Level.INFO,"artifact - " + artifact.getURI());
            //            }
            Artifact resolvedArtifact = resolver.resolveModel(Artifact.class, compositeFile);
            //            if (!resolvedArtifact.isUnresolved() && resolvedArtifact.getModel() instanceof Composite) {

            if (!composite.isUnresolved()) {

                // The composite content was passed into the node and read into a composite model,
                // don't use the composite found in the contribution, use that composite, but just resolve
                // it within the context of the contribution
                compositeProcessor.resolve(composite, resolver);

            } else {

                // Use the resolved composite we've found in the contribution
                composite = (Composite)resolvedArtifact.getModel();
            }
            found = true;
            //            break;
            //          }
        }
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());
                }
            }
        }
       
        // 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

            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

                // 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

    private URL resolveLocation(ModelResolver resolver, String contextPath, ProcessorContext context)
        throws MalformedURLException, ContributionReadException {
        URL resource = null;
        URI uri = URI.create(contextPath);
        if (!uri.isAbsolute()) {
            Artifact parent = context.getArtifact();
            if (parent != null && parent.getURI() != null) {
                URI base = URI.create("/" + parent.getURI());
                uri = base.resolve(uri);
                // Remove the leading / to make artifact resolver happy
                if (uri.toString().startsWith("/")) {
                    uri = URI.create(uri.toString().substring(1));
                }
            }
            Artifact artifact = contributionFactory.createArtifact();
            artifact.setUnresolved(true);
            artifact.setURI(uri.toString());
            artifact = resolver.resolveModel(Artifact.class, artifact, context);
            if (!artifact.isUnresolved()) {
                resource = new URL(artifact.getLocation());
            } else {
                // The resource can be out of scope of the contribution root
                if (parent != null && parent.getLocation() != null) {
                    resource = new URL(new URL(parent.getLocation()), contextPath);
                    return resource;
View Full Code Here

        systemContribution.setUnresolved(true);

        // create an artifact to represent the system defintions and
        // add it to the contribution
        List<Artifact> artifacts = systemContribution.getArtifacts();
        Artifact artifact = contributionFactory.createArtifact();
        artifact.setURI("http://tuscany.apache.org/SystemContribution/Definitions");
        artifact.setLocation("Derived");
        artifact.setModel(systemDefinitions);
        artifacts.add(artifact);
               
        // now resolve and add the system contribution
        try {
            contributionProcessor.resolve(systemContribution, modelResolver, context);
View Full Code Here

        DefinitionsUtil.aggregate(systemDefinitions, definitions, monitor);
       
        // create an artifact to represent the system defintions and
        // add it to the contribution
        List<Artifact> artifacts = contribution.getArtifacts();
        Artifact artifact = contributionFactory.createArtifact();
        artifact.setURI("http://tuscany.apache.org/SystemContribution/Definitions");
        artifact.setLocation("Derived");
        artifact.setModel(definitions);
        artifacts.add(artifact);
       
        // create resolver entries to represent the SCA schema. We don't create artifacts
        // in the contribution as the XSD schema are only actually loaded on demand
        // so as long as they are in the model resolver we are set. We do it on the clone
View Full Code Here

                }
            }
        }

        // Create an artifact for the deployment composite
        Artifact artifact = contributionFactory.createArtifact();
        artifact.setURI(compositeArtifactURI);

        artifact.setLocation(compositeArtifactURI);
        artifact.setModel(composite);
        artifact.setUnresolved(false);
        // Add it to the contribution
        contribution.getArtifacts().add(artifact);

        // Replace the deployable composites with the deployment composites
        // Clear the deployable composites if it's the first deployment composite
View Full Code Here

        }
    }

    public Artifact loadArtifact(URI uri, URL location, Monitor monitor) throws ContributionReadException {
        init();
        Artifact artifact = contributionFactory.createArtifact();
        artifact.setLocation(location.toString());
        artifact.setURI(uri.toString());
        URLArtifactProcessorExtensionPoint artifactProcessors =
            registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
        ExtensibleURLArtifactProcessor processor = new ExtensibleURLArtifactProcessor(artifactProcessors);
        Object model = processor.read(null, uri, location, new ProcessorContext(monitor));
        artifact.setModel(model);
        return 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.