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

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


            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
            String contributionDirectory = nodeName.substring(nodeName.lastIndexOf('/') + 1);
            URL contributionURL = Thread.currentThread().getContextClassLoader().getResource(contributionDirectory + "/");

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

            // Add the deployable composite to the domain
            nodeComposite.getIncludes().add(appComposite);
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, scaDefinitionsSink);
        return contributionService;
    }
View Full Code Here

        try {         

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

        // 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()) {
            URL contributionURL = new URL(contribution.getLocation());

            // 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));
        }
       
        // Load the specified composite
        StAXArtifactProcessor<Composite> compositeProcessor = artifactProcessors.getProcessor(Composite.class);
        URL compositeURL = new URL(configuration.getComposite().getURI());
View Full Code Here

    protected void setUp(String contributionJarName) throws Exception {
       
        scaDomain = new EmbeddedSCADomain(EmbeddedSCADomain.class.getClassLoader(), "http://localhost");
        scaDomain.start();
        ContributionService contributionService = scaDomain.getContributionService();
        String folderName = "../test-bundles/target/";
        String supplychainJarName = contributionJarName;
        URL supplyChainURL = new File(folderName + supplychainJarName).toURI().toURL();
       
        Contribution contribution = contributionService.contribute("SupplyChain", supplyChainURL, false);
        for (Composite deployable : contribution.getDeployables() ) {
            scaDomain.getDomainComposite().getIncludes().add(deployable);
            scaDomain.buildComposite(deployable);
        }
       
View Full Code Here

        //Start the domain
        domain.start();

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

        // File compositeContribLocation = new File("../export-composite/target/classes");
        // URL compositeContribURL = compositeContribLocation.toURL();
        URL compositeContribURL = getContributionURL(Hello.class);
        compositeContribution =
            contributionService.contribute("http://import-export/export-composite", compositeContribURL, false);
        for (Composite deployable : compositeContribution.getDeployables()) {
            domain.getDomainComposite().getIncludes().add(deployable);
            domain.buildComposite(deployable);
        }

//        File helloWorldContribLocation = new File("./target/classes/");
//        URL helloWorldContribURL = helloWorldContribLocation.toURL();
        URL helloWorldContribURL = getContributionURL(HelloWorldService.class);
        helloWorldContribution =
            contributionService.contribute("http://import-export/helloworld", helloWorldContribURL, false);
        for (Composite deployable : helloWorldContribution.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-composite");

        //Stop Components from my composite
        for (Composite deployable : helloWorldContribution.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();

        File contribLocation = new File("./target/classes/");
        URL contributionURL = contribLocation.toURL();
        contribution = contributionService.contribute("http://contribution", contributionURL, false);
        for (Composite deployable : contribution.getDeployables()) {
            domain.getDomainComposite().getIncludes().add(deployable);
            domain.buildComposite(deployable);
        }
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.