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

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


            // create and start domainA
            domain = new EmbeddedSCADomain(cl, DEFULT_DOMAIN_NAME);
            domain.start();

            // add a contribution to the domain
            ContributionService contributionService = domain.getContributionService();

            // find the current directory as a URL. This is where our contribution
            // will come from
            URL contributionURL = Thread.currentThread().getContextClassLoader().getResource(nodeName + "/");

            // Contribute the SCA application
            Contribution contribution = contributionService.contribute("http://calculator", contributionURL, null, //resolver,
                                                                       false);
            Composite composite = contribution.getDeployables().get(0);

            // Add the deployable composite to the domain
            domain.getDomainComposite().getIncludes().add(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
        domain.getDomainComposite().getIncludes().add(myComposite);
        domain.getCompositeBuilder().build(myComposite);

        // Start the composite
        domain.getCompositeActivator().activate(myComposite);
        domain.getCompositeActivator().start(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
        domain.getCompositeActivator().stop(myComposite);
        domain.getCompositeActivator().deactivate(myComposite);
       
        // Remove my composite
        domain.getDomainComposite().getIncludes().remove(myComposite);
       
        // Remove my contribution
        contributionService.remove("http://test/contribution");
       
        // Stop the domain
        domain.stop();
    }
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
        domain.getDomainComposite().getIncludes().add(myComposite);
        domain.getCompositeBuilder().build(myComposite);

        // Start the composite
        domain.getCompositeActivator().activate(myComposite);
        domain.getCompositeActivator().start(myComposite);
       
        // At this point the domain contains my contribution, my composite and
        // it's started, my application code can start using it

        ComponentManager componentManager = domain.getComponentManager();
        assertEquals(1, componentManager.getComponentNames().size());
        assertEquals("CRUDServiceComponent", componentManager.getComponentNames().iterator().next());
       
        Component component = componentManager.getComponent("CRUDServiceComponent");
        assertNotNull(component);
        assertEquals("CRUDServiceComponent", component.getName());
       
        MyComponentListener cl = new MyComponentListener();
        componentManager.addComponentListener(cl);

        assertTrue(componentManager.isComponentStarted("CRUDServiceComponent"));
       
        assertFalse(cl.stopCalled);
        componentManager.stopComponent("CRUDServiceComponent");
        assertTrue(cl.stopCalled);
        assertFalse(componentManager.isComponentStarted("CRUDServiceComponent"));
       
        assertFalse(cl.startCalled);
        componentManager.startComponent("CRUDServiceComponent");
        assertTrue(cl.startCalled);
        assertTrue(componentManager.isComponentStarted("CRUDServiceComponent"));

        // Stop my composite
        domain.getCompositeActivator().stop(myComposite);
        domain.getCompositeActivator().deactivate(myComposite);
       
        // Remove my composite
        domain.getDomainComposite().getIncludes().remove(myComposite);
       
        // Remove my contribution
        contributionService.remove("http://test/contribution");
       
        // Stop the domain
        domain.stop();
    }
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)
                contributionURL = contributionURL.toURI().toURL();
            }
        } catch (Exception e) {
            throw new ServiceRuntimeException(e);
        }

        try {
            String contributionURI = FileHelper.getName(contributionURL.getPath());
            if(contributionURI == null || contributionURI.length() == 0) {
                contributionURI = contributionURL.toString();
            }
            contribution = contributionService.contribute(contributionURI, contributionURL, false);
        } catch (ContributionException e) {
            throw new ServiceRuntimeException(e);
        } catch (IOException e) {
            throw new ServiceRuntimeException(e);
        }
View Full Code Here

                throw new ServiceRuntimeException(e);
            }
        }

        // 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 runtime
View Full Code Here

            throw new ActivationException(e);
        }

        ExtensibleURLArtifactProcessor documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors);

        ContributionService contributionService =
            new ContributionServiceImpl(repository, packageProcessor, documentProcessor,
                                        staxProcessor, contributionListener,
                                        postProcessor, domainModelResolver, modelResolvers, modelFactories,
                                        assemblyFactory, contributionFactory, xmlFactory);
        return contributionService;
View Full Code Here

        //Start the domain
        domain.start();

        // Contribute the SCA contribution
        ContributionService contributionService = domain.getContributionService();
       
        URL javaContribURL = getContributionURL(SavingsAccountService.class);
        Contribution bigbankAcContribution = contributionService.contribute("http://bigbank-account", javaContribURL, false);
        for (Composite deployable : bigbankAcContribution.getDeployables()) {
            domain.getDomainComposite().getIncludes().add(deployable);
            domain.buildComposite(deployable);
        }
       
        URL bigbankContribUrl = getContributionURL(BigBankServer.class);
        Contribution bigbankContribution = contributionService.contribute("http://bigbank", bigbankContribUrl, false);
        for (Composite deployable : bigbankContribution.getDeployables()) {
            domain.getDomainComposite().getIncludes().add(deployable);
            domain.buildComposite(deployable);
        }


        //Start Components from  composite
        for (Composite deployable : bigbankAcContribution.getDeployables()) {
            domain.getCompositeActivator().activate(deployable);
            domain.getCompositeActivator().start(deployable);
        }

        for (Composite deployable : bigbankContribution.getDeployables()) {
            domain.getCompositeActivator().activate(deployable);
            domain.getCompositeActivator().start(deployable);
        }
       
        if (timeout < 0) {
            System.out.println("Press Enter to Exit...");
            System.in.read();
        } else {
            Thread.sleep(timeout);
        }
       
        contributionService.remove("http://bigbank-account");
        contributionService.remove("http://bigbank");

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

        ExtensibleURLArtifactProcessor documentProcessor =
            new ExtensibleURLArtifactProcessor(documentProcessors, monitor);

        // Create the contribution service
        ContributionService contributionService =
            new ContributionServiceImpl(repository, packageProcessor, documentProcessor, staxProcessor,
                                        contributionListener, policyDefinitionResolver, modelResolvers, modelFactories,
                                        assemblyFactory, contributionFactory, inputFactory, policyDefinitions, monitor);
        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();
        contributions = new ArrayList<Contribution>();
        for (Contribution contribution : configuration.getContributions()) {
            URI uri = createURI(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));
            analyzeProblems();
        }

        composite = configuration.getComposite();
View Full Code Here

        }

        ExtensibleURLArtifactProcessor documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors, monitor);

        // Create the contribution service
        ContributionService contributionService =
            new ContributionServiceImpl(repository, packageProcessor, documentProcessor, staxProcessor,
                                        contributionListener, policyDefinitionResolver, modelResolvers, modelFactories,
                                        assemblyFactory, contributionFactory, inputFactory, policyDefinitions, monitor);
        return contributionService;
    }
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.