Package org.apache.tuscany.sca.contribution.service

Examples of org.apache.tuscany.sca.contribution.service.ContributionService


        //Start the domain
        domain.start();

        // Contribute the SCA contribution
        ContributionService contributionService = domain.getContributionService();

        //        File wsdlContribLocation = new File("../export-wsdl/target/classes");
        //        URL wsdlContribURL = wsdlContribLocation.toURL();
        URL wsdlContribURL = getContributionURL(getClass().getClassLoader(), "helloworld.wsdl");
        wsdlContribution = contributionService.contribute("http://import-export/export-wsdl", wsdlContribURL, false);
        for (Composite deployable : wsdlContribution.getDeployables()) {
            domain.getDomainComposite().getIncludes().add(deployable);
            domain.buildComposite(deployable);
        }

        //        File helloWorldContribLocation = new File("./target/classes/");
        //        URL helloWorldContribURL = helloWorldContribLocation.toURL();
        URL helloWorldContribURL = getContributionURL(HelloWorldService.class);
        consumerContribution =
            contributionService.contribute("http://import-export/helloworld", helloWorldContribURL, false);
        for (Composite deployable : consumerContribution.getDeployables()) {
            domain.getDomainComposite().getIncludes().add(deployable);
            domain.buildComposite(deployable);
        }
View Full Code Here


        assertEquals("Hello Smith", helloWorldService.getGreetings("Smith"));
    }

    @Override
    public void tearDown() throws Exception {
        ContributionService contributionService = domain.getContributionService();

        // Remove the contribution from the in-memory repository
        contributionService.remove("http://import-export/helloworld");
        contributionService.remove("http://import-export/export-wsdl");

        // Stop Components from my composite
        for (Composite deployable : consumerContribution.getDeployables()) {
            domain.getCompositeActivator().stop(deployable);
            domain.getCompositeActivator().deactivate(deployable);
View Full Code Here

        // Start the domain
        domain.start();

        // Contribute the SCA contribution
        ContributionService contributionService = domain.getContributionService();

        URL helloURL = getContributionURL(Hello.class);
       
        // File helloContrib = new File("./target/classes/");
        // URL helloURL = helloContrib.toURL();
        Contribution consumerContribution =
            contributionService.contribute("http://import-export/hello", helloURL, false);
        Composite consumerComposite = consumerContribution.getDeployables().get(0);
        domain.getDomainComposite().getIncludes().add(consumerComposite);
        domain.buildComposite(consumerComposite);

        // Start Components from my composite
View Full Code Here

        } catch (ActivationException e) {
            throw new ServiceRuntimeException(e);
        }

        // Contribute the given contribution to an in-memory repository
        ContributionService contributionService = runtime.getContributionService();
        URL contributionURL;
        try {
            contributionURL = getContributionLocation(applicationClassLoader, location, this.composites);
        } catch (MalformedURLException e) {
            throw new ServiceRuntimeException(e);
        }

        try {
            ModelResolverImpl modelResolver = new ModelResolverImpl(applicationClassLoader);
            String contributionURI = FileHelper.getName(contributionURL.getPath());
            contribution = contributionService.contribute(contributionURI, contributionURL, modelResolver, false);
        } catch (ContributionException e) {
            throw new ServiceRuntimeException(e);
        } catch (IOException e) {
            throw new ServiceRuntimeException(e);
        }
View Full Code Here

    public void close() {
       
        super.close();

        // Remove the contribution from the in-memory repository
        ContributionService contributionService = runtime.getContributionService();
        try {
            contributionService.remove(contribution.getURI());
        } catch (ContributionException e) {
            throw new ServiceRuntimeException(e);
        }
       
        // Stop the SCA domain composite
View Full Code Here

        String url = myClassLoader.getResource("test.txt").toString();
        url = url.substring(0, url.length()-8);
       
        // Contribute the SCA contribution
        TestModelResolver myResolver = new TestModelResolver(myClassLoader);
        ContributionService contributionService = domain.getContributionService();
        Contribution contribution = contributionService.contribute("http://test/contribution", new URL(url), myResolver, false);
        assertNotNull(contribution);
       
        // Decide which SCA composite I want to deploy
        Composite myComposite = myResolver.getComposite(new QName("http://sample/crud", "crud"));
       
        // Add the deployable composite to the domain
        EmbeddedSCADomain.DomainCompositeHelper domainHelper = domain.getDomainCompositeHelper();
        domainHelper.addComposite(myComposite);

        // Start the components in my composite
        domainHelper.startComposite(myComposite);
       
        // At this point the domain contains my contribution, my composite and
        // it's started, my application code can start using it
       
        // Get the CRUDServiceComponent service
        CRUD service = domain.getService(CRUD.class, "CRUDServiceComponent");
       
        // Invoke the service
        String id = service.create("ABC");
        Object result = service.retrieve(id);
        assertEquals("ABC", result);
        service.update(id, "EFG");
        result = service.retrieve(id);
        assertEquals("EFG", result);
        service.delete(id);
        result = service.retrieve(id);
        assertNull(result);
       
        // Stop my composite
        domainHelper.stopComposite(myComposite);
       
        // Remove my composite
        domainHelper.removeComposite(myComposite);
       
        // Remove my contribution
        contributionService.remove("http://test/contribution");
       
        // Stop the domain
        domain.stop();
    }
View Full Code Here

            throw new ActivationException(e);
        }

        ContributionFactory contributionFactory = new ContributionFactoryImpl();
        ExtensibleURLArtifactProcessor documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors);
        ContributionService contributionService = new ContributionServiceImpl(repository, packageProcessor,
                                                                              documentProcessor, assemblyFactory,
                                                                              contributionFactory, xmlFactory);
        return contributionService;
    }
View Full Code Here

        // Find if any contribution JARs already available locally on the classpath
        Map<String, URL> localContributions = localContributions();

        // Load the specified contributions
        ContributionService contributionService = runtime.getContributionService();
        List<Contribution> contributions = new ArrayList<Contribution>();
        for (Contribution contribution : configuration.getContributions()) {
            URI uri = URI.create(contribution.getLocation());
            if (uri.getScheme() == null) {
                uri = new File(contribution.getLocation()).toURI();
            }
            URL contributionURL = uri.toURL();

            // Extract contribution file name
            String file = contributionURL.getPath();
            int i = file.lastIndexOf('/');
            if (i != -1 && i < file.length() - 1) {
                file = file.substring(i + 1);

                // If we find the local contribution file on the classpath, use it in
                // place of the original contribution URL
                URL localContributionURL = localContributions.get(file);
                if (localContributionURL != null) {
                    contributionURL = localContributionURL;
                }
            }

            // Load the contribution
            logger.log(Level.INFO, "Loading contribution: " + contributionURL);
            contributions.add(contributionService.contribute(contribution.getURI(), contributionURL, false));
            analyseProblems();
        }
       
        // Resolve the metadata within the context of the first contribution
        Contribution mainContribution = contributions.get(contributions.size() - 1);
View Full Code Here

        } catch (ActivationException e) {
            throw new ServiceRuntimeException(e);
        }
       
        // Contribute the given contribution to an in-memory repository
        ContributionService contributionService = runtime.getContributionService();
        URL contributionURL;
        try {
            contributionURL = getContributionLocation(applicationClassLoader, contributionLocation, this.composites);
            if (contributionURL != null) {
                // Make sure the URL is correctly encoded (for example, escape the space characters)
View Full Code Here

                throw new ServiceRuntimeException(e);
            }
        }

        // Remove the contribution from the in-memory repository
        ContributionService contributionService = runtime.getContributionService();
        for (Contribution contribution : contributions) {
            try {
                contributionService.remove(contribution.getURI());
            } catch (ContributionException e) {
                throw new ServiceRuntimeException(e);
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.contribution.service.ContributionService

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.