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

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


        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://test", "test"));
       
        // Add the deployable composite to the domain
        domain.getDomainComposite().getIncludes().add(myComposite);
       
       
        //update for sca definitions processed from contributions.. need to do this  before building
        //the composite
        domain.updateContributionSCADefinitions(contributionService.getContributionSCADefinitions());
       
        domain.buildComposite(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 TestServiceComponent service
        TestService service = domain.getService(TestService.class, "TestServiceComponent");
       
        // Invoke the service
        String result = service.ping("Bob");
        assertEquals("Hello Bob", 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://test", "test"));
       
        // Add the deployable composite to the domain
        domain.getDomainComposite().getIncludes().add(myComposite);
       
        //update for sca definitions processed from contributions.. need to do this  before building
        //the composite
        domain.updateContributionSCADefinitions(contributionService.getContributionSCADefinitions());
       
        domain.buildComposite(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("TestServiceComponent", componentManager.getComponentNames().iterator().next());
       
        Component component = componentManager.getComponent("TestServiceComponent");
        assertNotNull(component);
        assertEquals("TestServiceComponent", component.getName());
       
        MyComponentListener cl = new MyComponentListener();
        componentManager.addComponentListener(cl);

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

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

        // Start the domain
        domain.start();

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

        helloContribution =
            contributionService.contribute("http://import-export/export-composite", helloContribution_URL, false);
       
        for (Composite deployable : helloContribution.getDeployables()) {
            domain.getDomainComposite().getIncludes().add(deployable);
            domain.buildComposite(deployable);
        }
        for (Composite deployable : helloContribution.getDeployables()) {
            domain.getCompositeActivator().activate(deployable);
            domain.getCompositeActivator().start(deployable);
        }

        helloWorldContribution_one =
            contributionService.contribute("http://import-export/helloworld_one", helloWorldContribution_one_URL, false);
        for (Composite deployable : helloWorldContribution_one.getDeployables()) {
            domain.getDomainComposite().getIncludes().add(deployable);
            domain.buildComposite(deployable);
        }
View Full Code Here

            if (contributionClassLoader != null)  {
                modelResolver = new ModelResolverImpl(contributionClassLoader);
            }
           
            // Add the contribution to the node
            ContributionService contributionService = nodeRuntime.getContributionService();
            Contribution contribution = contributionService.contribute(contributionURI,
                                                                       contributionURL,
                                                                       modelResolver,
                                                                       false);
           
            // remember the contribution
View Full Code Here

            ModelFactoryExtensionPoint factories = nodeRuntime.getExtensionPointRegistry().getExtensionPoint(ModelFactoryExtensionPoint.class);
            NodeFactoryImpl domainFactory = new NodeFactoryImpl(this);
            factories.addFactory(domainFactory);                      

            // add a contribution to the domain
            ContributionService contributionService = nodeRuntime.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
            nodeComposite.getIncludes().add(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, 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

        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

                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

        }

        ExtensibleURLArtifactProcessor documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors);

        // Create the contribution service
        ContributionService contributionService =
            new ContributionServiceImpl(repository, packageProcessor, documentProcessor, staxProcessor,
                                        contributionListener, domainModelResolver, modelResolvers, modelFactories,
                                        assemblyFactory, contributionFactory, inputFactory);
        return contributionService;
    }
View Full Code Here

                if (contributionClassLoader != null)  {
                    modelResolver = new ModelResolverImpl(contributionClassLoader);
                }
               
                // Add the contribution to the node
                ContributionService contributionService = nodeRuntime.getContributionService();
                Contribution contribution = contributionService.contribute(contributionURI,
                                                                           contributionURL,
                                                                           modelResolver,
                                                                           false);
               
                // remember the contribution
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.