Package org.apache.tuscany.sca.contribution

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


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


        List deployables = contributionService.getContribution(contributionId).getDeployables();
        Composite composite1 = (Composite)deployables.get(deployables.size() - 1);
        assertEquals("contributionComposite", composite1.getName().toString());

        Artifact artifact = null;
        contribution = contributionService.getContribution(contributionId);
        String id = artifactId.toString();
        for (Artifact a : contribution.getArtifacts()) {
            if (id.equals(a.getURI())) {
                artifact = a;
                break;
            }
        }
        Composite composite2 = (Composite)artifact.getModel();
        assertEquals("contributionComposite", composite2.getName().toString());
    }
View Full Code Here

                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

    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

                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, context);
                    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(WidgetImplementation implementation, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {

        if (implementation != null) {
            // Resolve the resource directory location
            Artifact artifact = contributionFactory.createArtifact();
            artifact.setURI(implementation.getLocation());
            Artifact resolved = resolver.resolveModel(Artifact.class, artifact, context);

            if(resolved.getLocation() == null) {
                URL resource = null;
                URI uri = URI.create(implementation.getLocation());
                Artifact parent = context.getArtifact();
                if (!uri.isAbsolute()) {
                    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));
                        }
                    }
                }


                // The resource can be out of scope of the contribution root
                if (parent != null && parent.getLocation() != null) {
                    try {
                        resource = new URL(new URL(parent.getLocation()), implementation.getLocation());

                        implementation.setLocationURL(resource);

                    } catch (MalformedURLException e) {
                        ContributionResolveException ce = new ContributionResolveException(e);
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.