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

Examples of org.apache.tuscany.sca.contribution.resolver.ModelResolver


        assertTrue(prop2 instanceof OSGiProperty);
        OSGiProperty osgiProp2 = (OSGiProperty)prop2;
        assertEquals("ABC", osgiProp2.getValue());
        assertEquals("prop2", osgiProp2.getName());

        ModelResolver resolver = new TestModelResolver(getClass().getClassLoader());
        staxProcessor.resolve(componentType, resolver);
        resolver.addModel(componentType);

        staxProcessor.resolve(composite, resolver);
    }
View Full Code Here


       
        // Create contribution model
        Contribution contribution = contributionFactory.createContribution();
        contribution.setURI(contributionURI.toString());
        contribution.setLocation(contributionURL.toString());
        ModelResolver modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories);
        contribution.setModelResolver(modelResolver);
        contribution.setUnresolved(true);

        // Create a contribution scanner
        ContributionScanner scanner;
View Full Code Here

    }
   
    public void resolve(Contribution contribution, ModelResolver resolver) throws ContributionResolveException {
       
        // Mark the contribution model resolved
        ModelResolver contributionResolver = contribution.getModelResolver();
        contribution.setUnresolved(false);
        contributionResolver.addModel(contribution);
       
        // Resolve imports and exports
        for (Export export: contribution.getExports()) {
            if (export instanceof DefaultExport) {
               
View Full Code Here

    private Contribution createDeploymentContribution(String compositeContent) throws Exception {
        // Create the deployment contribution
        Contribution contrib = contributionFactory.createContribution();
        contrib.setURI(SCA11_TUSCANY_NS + "/contributions/_deployment_");
        contrib.setLocation(SCA11_TUSCANY_NS + "/contributions/_deployment_");
        ModelResolver modelResolver = new ExtensibleModelResolver(contrib, modelResolvers, modelFactories);
        contrib.setModelResolver(modelResolver);
        contrib.setUnresolved(false);

        // Load the deployment composite
        XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(compositeContent));
View Full Code Here

        // create a system contribution to hold the definitions. The contribution
        // will be extended later with definitions from application contributions
        systemContribution = contributionFactory.createContribution();
        systemContribution.setURI(SCA11_TUSCANY_NS + "/contributions/_system_");
        systemContribution.setLocation(SCA11_TUSCANY_NS + "/contributions/_system_");
        ModelResolver modelResolver = new ExtensibleModelResolver(systemContribution, modelResolvers, modelFactories);
        systemContribution.setModelResolver(modelResolver);
        systemContribution.setUnresolved(true);

        // create an artifact to represent the system defintions and
        // add it to the contribution
View Full Code Here

        boolean found = false;
        Artifact compositeFile = contributionFactory.createArtifact();
        compositeFile.setUnresolved(true);
        compositeFile.setURI(composite.getURI());
        for (Contribution contribution : workspace.getContributions()) {
            ModelResolver resolver = contribution.getModelResolver();
            //            for (Artifact artifact : contribution.getArtifacts()){
            //                logger.log(Level.INFO,"artifact - " + artifact.getURI());
            //            }
            Artifact resolvedArtifact = resolver.resolveModel(Artifact.class, compositeFile);
            //            if (!resolvedArtifact.isUnresolved() && resolvedArtifact.getModel() instanceof Composite) {

            if (!composite.isUnresolved()) {

                // The composite content was passed into the node and read into a composite model,
View Full Code Here

       
        // Create contribution model
        Contribution contribution = contributionFactory.createContribution();
        contribution.setURI(contributionURI.toString());
        contribution.setLocation(contributionURL.toString());
        ModelResolver modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories);
        contribution.setModelResolver(modelResolver);
        contribution.setUnresolved(true);

        // Create a contribution scanner
        ContributionScanner scanner = scanners.getContributionScanner(contributionURL.getProtocol());
        if (scanner == null) {
            if ("file".equals(contributionURL.getProtocol()) && new File(contributionURL.getFile()).isDirectory()) {
                scanner = new DirectoryContributionScanner();
            } else {
                scanner = new JarContributionScanner();
            }
        }
       
        // Scan the contribution and list the artifacts contained in it
        List<Artifact> artifacts = contribution.getArtifacts();
        boolean contributionMetadata = false;
        List<String> artifactURIs = scanner.getArtifacts(contributionURL);
        for (String artifactURI: artifactURIs) {
            URL artifactURL = scanner.getArtifactURL(contributionURL, artifactURI);

            // Add the deployed artifact model to the contribution
            Artifact artifact = this.contributionFactory.createArtifact();
            artifact.setURI(artifactURI);
            artifact.setLocation(artifactURL.toString());
            artifacts.add(artifact);
            modelResolver.addModel(artifact);
           
            // Read each artifact
            Object model = artifactProcessor.read(contributionURL, URI.create(artifactURI), artifactURL);
            if (model != null) {
                artifact.setModel(model);

                // Add the loaded model to the model resolver
                modelResolver.addModel(model);

                // Merge contribution metadata into the contribution model
                if (model instanceof ContributionMetadata) {
                    contributionMetadata = true;
                    ContributionMetadata c = (ContributionMetadata)model;
View Full Code Here

    }
   
    public void resolve(Contribution contribution, ModelResolver resolver) throws ContributionResolveException {
       
        // Resolve the contribution model itself
        ModelResolver contributionResolver = contribution.getModelResolver();
        contribution.setUnresolved(false);
        contributionResolver.addModel(contribution);
       
        // Resolve imports and exports
        for (Export export: contribution.getExports()) {
            if (export instanceof DefaultExport) {
               
                // Initialize the default export's resolver
                export.setModelResolver(contributionResolver);
               
            } else {
                extensionProcessor.resolve(export, contributionResolver);
            }
        }
        for (Import import_: contribution.getImports()) {
            extensionProcessor.resolve(import_, contributionResolver);
        }
       
        // Resolve all artifact models
        for (Artifact artifact : contribution.getArtifacts()) {
            Object model = artifact.getModel();
            if (model != null) {
                try {
                   artifactProcessor.resolve(model, contributionResolver);
                } catch (Exception e) {
                    //FIXME this shouldn't happen
                }
            }
        }
       
        // Resolve deployable composites
        List<Composite> deployables = contribution.getDeployables();
        for (int i = 0, n = deployables.size(); i < n; i++) {
            Composite deployable = deployables.get(i);
            Composite resolved = (Composite)contributionResolver.resolveModel(Composite.class, deployable);
            if (resolved != deployable) {
                deployables.set(i, resolved);
            }
        }
    }
View Full Code Here

    }

    @Ignore("To be fixed")
    @Test
    public void testPolicyIntents() throws Exception {
        ModelResolver resolver = new TestModelResolver(getClass().getClassLoader());
       
        URL url = getClass().getResource("definitions.xml");
        URI uri = URI.create("definitions.xml");
        Definitions scaDefns = policyDefinitionsProcessor.read(null, uri, url);
               
View Full Code Here

    }
   
    @Test
    @Ignore("Broken for now in 2.0 bringup")
    public void testPolicySets() throws Exception {
        ModelResolver resolver = new TestModelResolver(getClass().getClassLoader());
       
        URL url = getClass().getResource("definitions_with_policysets.xml");
        URI uri = URI.create("definitions_with_policysets.xml");
        Definitions policyDefinitions = policyDefinitionsProcessor.read(null, uri, url);
               
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.contribution.resolver.ModelResolver

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.