Package org.apache.tuscany.sca.contribution

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


        }
       
        // Resolve the referenced contributions
        List<Contribution> contributions = implementation.getContributions();
        for (int i = 0, n = contributions.size(); i < n; i++) {
            Contribution contribution = contributions.get(i);
            contribution = resolver.resolveModel(Contribution.class, contribution);
            if (!contribution.isUnresolved()) {
                contributions.set(i, contribution);
            }
        }
       
        implementation.setUnresolved(false);
View Full Code Here


          //FIXME What to do when a contribution uses a separate class loader ? (e.g contributionClassLoader != null)
           
            // Add the contribution to the node
            ContributionService contributionService = nodeRuntime.getContributionService();
            Contribution contribution = contributionService.contribute(contributionURI,
                                                                       contributionURL,
                                                                       false);
           
            // remember the contribution
            contributions.put(contributionURI, contribution);
               
            // remember all the composites that have been found
            for (Artifact artifact : contribution.getArtifacts()) {
                if (artifact.getModel() instanceof Composite) {
                    Composite composite = (Composite)artifact.getModel();
                    composites.put(composite.getName(), composite);
                    compositeFiles.put(composite.getURI(), composite);
                }
View Full Code Here

            throw new NodeException("Contribution " + contributionURI + " has not been added");
        }       
       
        try {

            Contribution contribution = contributions.get(contributionURI);
           
            // remove the local record of composites associated with this contribution
            for (Artifact artifact : contribution.getArtifacts()) {
                if (artifact.getModel() instanceof Composite) {
                    Composite composite = (Composite)artifact.getModel();
                    composites.remove(composite.getName());
                    compositeFiles.remove(composite.getURI());
                }
            }           
       
            // remove the contribution from the contribution service
            nodeRuntime.getContributionService().remove(contributionURI);
           
            // remove any deployed composites from the node level composite
            for (Composite composite : contribution.getDeployables()) {
                if (nodeComposite.getIncludes().contains(composite)){
                    // deactivate it
                    deactivateComposite(composite);
                   
                    // remove it
View Full Code Here

            if (import_ instanceof ResourceImport) {
                ResourceImport resourceImport = (ResourceImport)import_;
               
                // Find a matching contribution
                if (resourceImport.getLocation() != null) {
                    Contribution targetContribution = repository.getContribution(resourceImport.getLocation());
                    if (targetContribution != null) {
                   
                        // Find a matching contribution export
                        for (Export export: targetContribution.getExports()) {
                            if (export instanceof ResourceExport) {
                                ResourceExport resourceExport = (ResourceExport)export;
                                if (resourceImport.getURI().equals(resourceExport.getURI())) {
                                  resourceImport.setModelResolver(resourceExport.getModelResolver());
                                    initialized = true;
View Full Code Here

        } else if (targetReference.getCallback().getBindings().isEmpty()
                && reference.getCallback() != null) {
            targetReference.getCallback().getBindings().addAll(
                    reference.getCallback().getBindings());
        }
        Contribution contrib = contributionService.getContribution(contribURI);
        List<DeployedArtifact> artifacts = contrib.getArtifacts();
        // RuntimeComponent source = null;
        Composite composite = ArtifactsFinder.findComposite(compositeURI,
                artifacts);
        Component c = ArtifactsFinder.findComponent(composite, componentName);
        if (targetReference.getAutowire() == null) {
View Full Code Here

        StAXArtifactProcessorExtensionPoint staxProcessors = registry
                .getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
        MetaComponentProcessor processor = (MetaComponentProcessor) staxProcessors
                .getProcessor(Component.class);

        Contribution contrib = contributionService.getContribution(contribURI);

        List<DeployedArtifact> artifacts = contrib.getArtifacts();
        RuntimeComponent source = null;
        Composite composite = ArtifactsFinder.findComposite(compositeURI,
                artifacts);
        // TODO error handling
        if (composite != null)
            source = (RuntimeComponent) ArtifactsFinder.findComponent(
                    composite, componentName);
        else {
            throw new ComponentNotFoundException("Not found component "
                    + componentName + " for update");
        }
        if (source != null) {
            // Debig this
            RuntimeComponentReference targetReference = (RuntimeComponentReference) assemblyFactory
                    .createComponentReference();
            targetReference.setName(referenceName);
            targetReference.setUnresolved(true);
            Reference reference = null;
            try {
                reference = buildReference(referenceName, className,
                        interfaceName, true);
            } catch (Exception e) {
                throw new ComponentUpdaterException(e.getMessage());
            }
            source.getImplementation().getReferences().add(reference);

            // targetService.
            ComponentService targetService = assemblyFactory
                    .createComponentService();
            targetService.setUnresolved(true);
            targetService.setName(targetComponent);
            targetReference.getTargets().add(targetService);

            // reconciliate
            reconcileReference(reference, targetReference, componentName);
            // create component reference for the reference
            source.getReferences().add(targetReference);
            try {
                processor.resolveReference(targetReference, contrib
                        .getModelResolver());
            } catch (ContributionResolveException e) {
                throw new ComponentUpdaterException(
                        "Contribution Resolving Exception while updating..");
            }
View Full Code Here

            throws CompositeUpdaterException {
        StAXArtifactProcessorExtensionPoint staxProcessors = registry
                .getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
        MetaComponentProcessor processor = (MetaComponentProcessor) staxProcessors
                .getProcessor(Component.class);
        Contribution contrib = contribService.getContribution(contribURI);
        List<DeployedArtifact> artifacts = contrib.getArtifacts();
        Composite composite = ArtifactsFinder.findComposite(compositeURI,
                artifacts);
        boolean found = false;

        if (composite == null)
            throw new CompositeUpdaterException(
                    "Composite not found in contribution" + contribURI);
        else {
            processor.setComposite(composite);
            try {
                processor.read(c.build());
            } catch (Exception e) {
                throw new CompositeUpdaterException(
                        "Component error parsing in contribution" + contribURI);

            }
            found = true;
        }

        if (found) {
            Component component = processor.getParsedComponent();
            Composite augmentedComposite = processor.getParsedComposite();
            try {
                processor.resolve(component, contrib.getModelResolver());
                compositeBuilder.attach(augmentedComposite, component);
                ((CompositeActivatorImpl) compositeActivator)
                        .activateComponent(component);
            } catch (Exception e) {
View Full Code Here

        }
        return null;
    }

    public Component findComponent(String componentName) {
        Contribution contrib = contribService.getContribution(contribURI);
        List<DeployedArtifact> artifacts = contrib.getArtifacts();
        Composite composite = ArtifactsFinder.findComposite(compositeURI,
                artifacts);
        return ArtifactsFinder.findComponent(composite, componentName);
    }
View Full Code Here

        return ArtifactsFinder.findComponent(composite, componentName);
    }

    public Component removeComponent(String componentName)
            throws CompositeUpdaterException {
        Contribution contrib = contribService.getContribution(contribURI);
        List<DeployedArtifact> artifacts = contrib.getArtifacts();

        Composite composite = ArtifactsFinder.findComposite(compositeURI,
                artifacts);
        List<Component> components = composite.getComponents();
        Component toRemove = null;
View Full Code Here

            if(import_ instanceof JavaImport) {
                JavaImport javaImport = (JavaImport) import_;
               
                //Find a matching contribution
                if(javaImport.getLocation() != null) {
                    Contribution targetContribution = repository.getContribution(javaImport.getLocation());
                    if (targetContribution != null) {
                   
                        // Find a matching contribution export
                        for (Export export: targetContribution.getExports()) {
                            if (export instanceof JavaExport) {
                                JavaExport javaExport = (JavaExport)export;
                                if (javaImport.getPackage().equals(javaExport.getPackage())) {
                                    List<Contribution> exportingContributions = new ArrayList<Contribution>();
                                    exportingContributions.add(targetContribution);
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.contribution.Contribution

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.