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

        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, registry, monitor);
        return contributionService;
    }
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, registry, 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

     *       located in META-INF/deployables or specified in the sca-deployables.xml. Maybe the EmbeddedSCADomain
     *       and ContributionService APIs should make all this easier?
     */
    protected void initContributions(EmbeddedSCADomain scaDomain,  ClassLoader cl, URL[] contributionJars) {
      Contribution contribution = null;
        ContributionService contributionService = scaDomain.getContributionService();
        for (URL jar : contributionJars) {
            InputStream is = null;
            try {
                is = jar.openStream();
                contribution = contributionService.contribute(jar.toString(), jar, is);
            } catch (Exception e) {
                System.err.println("exception adding contribution: " + jar);
                e.printStackTrace();
            }
            if (is != null) {
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

        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, registry, monitor);
        return contributionService;
    }
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, registry, 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

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.