Package org.apache.tuscany.sca.contribution.resolver.impl

Examples of org.apache.tuscany.sca.contribution.resolver.impl.ModelResolverImpl


        AssemblyFactory assemblyFactory = new DefaultAssemblyFactory();
        ContributionFactory contributionFactory = new ContributionFactoryImpl();
        ContributionMetadataProcessor loader =
            new ContributionMetadataProcessor(assemblyFactory, contributionFactory, null);
        Contribution contribution = contributionFactory.createContribution();
        contribution.setModelResolver(new ModelResolverImpl(getClass().getClassLoader()));
        try {
            loader.read(reader);
            fail("InvalidException should have been thrown");
        } catch (ContributionReadException e) {
            assertTrue(true);
View Full Code Here


    private ModelResolver resolver;
    private ContributionFactory factory;
   
    @Override
    protected void setUp() throws Exception {
        resolver = new ModelResolverImpl(getClass().getClassLoader());
        factory = new ContributionFactoryImpl();
    }
View Full Code Here

    public void testContributeJAR() throws Exception {
        URL contributionLocation = getClass().getResource(JAR_CONTRIBUTION);
        //URL contributionLocation = new URL("file:/D:/dev/Opensource/Apache/Tuscany/source/java/sca/samples/calculator/target/sample-calculator.jar");
        String contributionId = CONTRIBUTION_001_ID;
        ModelResolver resolver = new ModelResolverImpl(getClass().getClassLoader());
        contributionService.contribute(contributionId, contributionLocation, resolver, false);
        assertNotNull(contributionService.getContribution(contributionId));
    }
View Full Code Here

    }

    public void testStoreContributionPackageInRepository() throws Exception {
        URL contributionLocation = getClass().getResource(JAR_CONTRIBUTION);
        String contributionId = CONTRIBUTION_001_ID;
        ModelResolver resolver = new ModelResolverImpl(getClass().getClassLoader());
        contributionService.contribute(contributionId, contributionLocation, resolver, true);

        assertTrue(FileHelper.toFile(new URL(contributionService.getContribution(contributionId).getLocation()))
            .exists());
View Full Code Here

        URL contributionLocation = getClass().getResource(JAR_CONTRIBUTION);
        String contributionId = CONTRIBUTION_001_ID;

        InputStream contributionStream = contributionLocation.openStream();
        try {
            ModelResolver resolver = new ModelResolverImpl(getClass().getClassLoader());
            contributionService.contribute(contributionId, contributionLocation, contributionStream, resolver);
        } finally {
            IOHelper.closeQuietly(contributionStream);
        }
View Full Code Here

    }

    public void testStoreDuplicatedContributionInRepository() throws Exception {
        URL contributionLocation = getClass().getResource(JAR_CONTRIBUTION);
        String contributionId1 = CONTRIBUTION_001_ID;
        ModelResolver resolver = new ModelResolverImpl(getClass().getClassLoader());
        contributionService.contribute(contributionId1, contributionLocation, resolver, true);
        assertNotNull(contributionService.getContribution(contributionId1));
        String contributionId2 = CONTRIBUTION_002_ID;
        ModelResolver resolver2 = new ModelResolverImpl(getClass().getClassLoader());
        contributionService.contribute(contributionId2, contributionLocation, resolver2, true);
        assertNotNull(contributionService.getContribution(contributionId2));
    }
View Full Code Here

         //File metadataDirectory = new File("target/classes/META-INF/");
         //if (!metadataDirectory.exists()) {
         //    FileHelper.forceMkdir(metadataDirectory);
         //}
         //FileHelper.copyFileToDirectory(calculatorMetadataFile, metadataDirectory);
         ModelResolver resolver = new ModelResolverImpl(getClass().getClassLoader());
         contributionService.contribute(contributionId, rootContributionFolder.toURL(), resolver, false);
         assertNotNull(contributionService.getContribution(contributionId));
    }
View Full Code Here

    }

    public void testAddDeploymentComposites() throws Exception {
        URL contributionLocation = getClass().getResource(JAR_CONTRIBUTION);
        String contributionId = CONTRIBUTION_001_ID;
        ModelResolver resolver = new ModelResolverImpl(getClass().getClassLoader());
        Contribution contribution = contributionService.contribute(contributionId, contributionLocation, resolver, false);
        assertNotNull(contributionService.getContribution(contributionId));

        String artifactId = "contributionComposite.composite";
        Composite composite = (new DefaultAssemblyFactory()).createComposite();
View Full Code Here

     *       a <component> so something is missing/wrong. Also this doesn't seem to be picking up composites
     *       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) {
        ModelResolverImpl modelResolver = new ModelResolverImpl(cl);
        ContributionService contributionService = scaDomain.getContributionService();
        for (URL jar : contributionJars) {
            InputStream is = null;
            try {
                is = jar.openStream();
                contributionService.contribute(jar.toString(), jar, is , modelResolver);
            } catch (Exception e) {
                System.err.println("exception adding contribution: " + jar);
                e.printStackTrace();
            }
            if (is != null) {
                try {
                    is.close();
                } catch (IOException e) {
                    // ignore
                }
            }
        }
       
        try {

            for (Object m : modelResolver.getModels()) {
                if (m instanceof Composite) {
                    Composite composite = (Composite)m;
                    scaDomain.getDomainComposite().getIncludes().add(composite);
                    scaDomain.getCompositeBuilder().build(composite);
                    scaDomain.getCompositeActivator().activate(composite);
                }
            }

            for (Object m : modelResolver.getModels()) {
                if (m instanceof Composite) {
                    Composite composite = (Composite)m;
                    scaDomain.getCompositeActivator().start(composite);
                }
            }
View Full Code Here

        domain.start();

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

        ModelResolver helloResolver = new ModelResolverImpl(cl);
        File helloContrib = new File("./target/classes/");
        URL helloURL = helloContrib.toURL();
        Contribution consumerContribution =
            contributionService.contribute("http://import-export/hello", helloURL, helloResolver, false);
        Composite consumerComposite = consumerContribution.getDeployables().get(0);
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.contribution.resolver.impl.ModelResolverImpl

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.