Package org.apache.tuscany.sca.runtime

Examples of org.apache.tuscany.sca.runtime.ContributionDescription


    public <T> T getService(Class<T> interfaze, String serviceURI) throws NoSuchServiceException {
        return ServiceHelper.getService(interfaze, serviceURI, domainRegistry, extensionPointRegistry, deployer);
    }

    public ContributionDescription getInstalledContribution(String contributionURI) {
        ContributionDescription cd = domainRegistry.getInstalledContribution(contributionURI);
        if (cd == null) {
            throw new IllegalArgumentException("Contribution not installed: " + contributionURI);
        }
        return cd;
    }
View Full Code Here


    protected List<Contribution> calculateDependentContributions(ContributionDescription cd) throws ContributionReadException, ValidationException {
        List<Contribution> dependentContributions = new ArrayList<Contribution>();
        if (cd.getDependentContributionURIs() != null && cd.getDependentContributionURIs().size() > 0) {
            // if the install specified dependent uris use just those contributions
            for (String uri : cd.getDependentContributionURIs()) {
                ContributionDescription dependee = domainRegistry.getInstalledContribution(uri);
                if (dependee != null) {
                    dependentContributions.add(loadContribution(dependee));
                }
            }
        } else {
View Full Code Here

    private List<ContributionDescription> findExportingContributions(Import imprt) {
        List<ContributionDescription> ics = new ArrayList<ContributionDescription>();
        // TODO: Handle Imports in a more extensible way
        for (String curi : domainRegistry.getInstalledContributionURIs()) {
            ContributionDescription cd = domainRegistry.getInstalledContribution(curi);
            if (imprt instanceof JavaImport) {
                for (String s : cd.getJavaExports()) {
                    if (s.startsWith(((JavaImport)imprt).getPackage())) {
                        ics.add(cd);
                    }
                }
            } else if (imprt instanceof NamespaceImport) {
                if (cd.getNamespaceExports().contains(((NamespaceImport)imprt).getNamespace())) {
                    ics.add(cd);
                }
            }
        }
        return ics;
View Full Code Here

        Assert.assertTrue(nodeB.getInstalledContributionURIs().contains("export"));
        Assert.assertTrue(nodeB.getInstalledContributionURIs().contains("helloworld"));
        Contribution cB = nodeB.getContribution("helloworld");
        Assert.assertNotNull(cB);

        ContributionDescription cd = ((NodeImpl)nodeB).getInstalledContribution("export");
        Assert.assertEquals(1, cd.getJavaExports().size());
        Assert.assertEquals("sample", cd.getJavaExports().get(0));
        } finally {
            runtime.stop();
        }
    }
View Full Code Here

        node.installContribution("src/test/resources/export.jar");

        Assert.assertEquals(1, node.getInstalledContributionURIs().size());
        Assert.assertEquals("export", node.getInstalledContributionURIs().get(0));
       
        ContributionDescription cd = ((NodeImpl)node).getInstalledContribution("export");
        Assert.assertEquals(1, cd.getJavaExports().size());
        Assert.assertEquals("sample", cd.getJavaExports().get(0));
    }
View Full Code Here

    public void invalidCompositeStartTest() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, XMLStreamException {
        Node node = TuscanyRuntime.newInstance().createNode("invalidCompositeStartTest");
        String curi = node.installContribution("src/test/resources/helloworld-invalidComposite.jar");
        Assert.assertEquals(1, node.getInstalledContributionURIs().size());
        Assert.assertEquals(0, node.getStartedCompositeURIs().size());
        ContributionDescription cd = node.getInstalledContribution(curi);
        Assert.assertEquals(1, cd.getDeployables().size());
       
        String compositeXML =
            "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\""
                + "     xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.1\""
                + "     targetNamespace=\"http://test/composite\""
View Full Code Here

        Assert.assertEquals(2, scs.get("helloworld-contribution").size());
        Assert.assertTrue(scs.get("helloworld-contribution").contains("helloworld.composite"));
        Assert.assertTrue(scs.get("helloworld-contribution").contains("helloworld2.composite"));
       
        // validate metadata side file
        ContributionDescription ic = node.getInstalledContribution("helloworld-contribution");
        Assert.assertEquals(1, ic.getJavaExports().size());
        Assert.assertEquals("sample", ic.getJavaExports().get(0));
    }
View Full Code Here

    public boolean updateContribution(String uri, String contributionURL, String metaDataURL, List<String> dependentContributionURIs) throws ContributionReadException, ValidationException, ActivationException {
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, "updateContribution" + Arrays.asList(new Object[]{uri, contributionURL, metaDataURL, dependentContributionURIs}));
        }
        ContributionDescription ic = domainRegistry.getInstalledContribution(uri);
        if (ic == null) {
            installContribution(uri, contributionURL, metaDataURL, dependentContributionURIs);
            return true;
        }

        // do this if only updating if the contribution has been modified:
        // if url equal and a file and last modified not changed
            // if metadata url equal and a file and laqst modified not changed
                 // if (dependent contributions uris not changed)
                     // return false

        uninstallContribution(uri);

        installContribution(uri, contributionURL, metaDataURL, dependentContributionURIs);
       
        // merge in additional deployables
        if (ic.getAdditionalDeployables().size() > 0) {
            ContributionDescription newIC = getInstalledContribution(uri);
            newIC.getAdditionalDeployables().putAll(ic.getAdditionalDeployables());
            domainRegistry.updateInstalledContribution(newIC);
        }

        // stop/start all started composites using the contribution
        for (DeployedComposite dc : new ArrayList<DeployedComposite>(startedComposites.values())) {
View Full Code Here

   
    public String installContribution(String uri, String contributionURL, String metaDataURL, List<String> dependentContributionURIs) throws ContributionReadException, ValidationException {
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, "installContribution" + Arrays.asList(new Object[]{uri, contributionURL, metaDataURL, dependentContributionURIs}));
        }
        ContributionDescription cd = new ContributionDescription(uri, IOHelper.getLocationAsURL(contributionURL).toString());

        if (dependentContributionURIs != null) {
            cd.getDependentContributionURIs().addAll(dependentContributionURIs);
        }
       
        if (metaDataURL != null) {
            mergeContributionMetaData(metaDataURL, loadContribution(cd));
        }

        peekIntoContribution(cd);

        domainRegistry.installContribution(cd);

        if (logger.isLoggable(quietLogging? Level.FINE : Level.INFO)) logger.log(quietLogging? Level.FINE : Level.INFO, "installContribution: " + cd.getURI());
        return cd.getURI();
    }
View Full Code Here

   
    public void installContribution(Contribution contribution, List<String> dependentContributionURIs) {
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, "installContribution" + Arrays.asList(new Object[]{contribution, dependentContributionURIs}));
        }
        ContributionDescription cd = new ContributionDescription(contribution.getURI(), contribution.getLocation());
        if (dependentContributionURIs != null) {
            cd.getDependentContributionURIs().addAll(dependentContributionURIs);
        }
        cd.configureMetaData(contribution);
        domainRegistry.installContribution(cd);
        loadedContributions.put(cd.getURI(), contribution);
        if (logger.isLoggable(quietLogging? Level.FINE : Level.INFO)) logger.log(quietLogging? Level.FINE : Level.INFO, "installContribution: " + cd.getURI());
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.runtime.ContributionDescription

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.