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

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


        init();
        Contribution contribution = contributionFactory.createContribution();
        contribution.setURI(systemContribution.getURI());
        contribution.setLocation(systemContribution.getLocation());

        ModelResolver modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories);
        contribution.setModelResolver(modelResolver);
        contribution.setUnresolved(true);

        DefinitionsFactory definitionsFactory = modelFactories.getFactory(DefinitionsFactory.class);
        Definitions definitions = definitionsFactory.createDefinitions();
        DefinitionsUtil.aggregate(systemDefinitions, definitions, monitor);
       
        // create an artifact to represent the system defintions and
        // add it to the contribution
        List<Artifact> artifacts = contribution.getArtifacts();
        Artifact artifact = contributionFactory.createArtifact();
        artifact.setURI("http://tuscany.apache.org/SystemContribution/Definitions");
        artifact.setLocation("Derived");
        artifact.setModel(definitions);
        artifacts.add(artifact);
       
        // create resolver entries to represent the SCA schema. We don't create artifacts
        // in the contribution as the XSD schema are only actually loaded on demand
        // so as long as they are in the model resolver we are set. We do it on the clone
        // so that every copy of the system contribution has the schema
        ProcessorContext context = new ProcessorContext(monitor);
        XSDFactory xsdFactory = modelFactories.getFactory(XSDFactory.class);
        List<String> scaSchemas = validationSchema.getSchemas();
        for (String scaSchemaLocation : scaSchemas){
            try {
                URL scaSchemaURL = new URL(scaSchemaLocation);
                String namespace = staxHelper.readAttribute(scaSchemaURL, XSD, "targetNamespace");

                // if this is the SCA schema store it in the system contribution
                if (namespace.equals(Constants.SCA11_TUSCANY_NS)){
                   
                    // add the schema to the model resolver under the Tuscany namespace
                    XSDefinition scaSchema = xsdFactory.createXSDefinition();
                    scaSchema.setUnresolved(true);
                    scaSchema.setNamespace(namespace);
                    scaSchema.setLocation(IOHelper.toURI(scaSchemaURL));
                    scaSchema.setUnresolved(false);
//                    modelResolver.addModel(scaSchema, context);
                } else if (namespace.equals(Constants.SCA11_NS)) {
                    // we know that the SCA schema's are referenced form the Tuscany schemas so
                    // register the schema under the SCA namespace too
                    XSDefinition scaSchema = xsdFactory.createXSDefinition();
                    scaSchema.setUnresolved(true);
                    scaSchema.setNamespace(Constants.SCA11_NS);
                    scaSchema.setLocation(IOHelper.toURI(scaSchemaURL));
                    scaSchema.setUnresolved(false);
                    modelResolver.addModel(scaSchema, context);                 
                }
            } catch (Exception ex) {
                throw new IllegalStateException(ex);
            }
        }       
View Full Code Here


            } finally {
                monitor.popContext();
            }
        }

        ExtensibleModelResolver modelResolver =
            new ExtensibleModelResolver(new Contributions(contributionList), modelResolvers, modelFactories);

        // now resolve and add the system contribution
        contributionProcessor.resolve(systemContribution, modelResolver, context);
        contributionList.add(systemContribution);
View Full Code Here

            } finally {
                monitor.popContext();
            }
        }

        ExtensibleModelResolver modelResolver =
            new ExtensibleModelResolver(new Contributions(contributionList), modelResolvers, modelFactories);

        // now resolve and add the system contribution
        contributionProcessor.resolve(systemContribution, modelResolver, context);
        contributionList.add(systemContribution);
View Full Code Here

        Contribution contribution = contributionFactory.createContribution();
        contribution.setClassLoader(OSGiHelper.createBundleClassLoader(bundle));
        contribution.setURI(id);
        contribution.setLocation(bundle.getEntry("/").toString());
        deployer.attachDeploymentComposite(contribution, composite, false);
        ModelResolver modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, factories);
        contribution.setModelResolver(modelResolver);
        // compositeProcessor.resolve(composite, modelResolver, new ProcessorContext(registry));
        contribution.setUnresolved(true);
        return contribution;
    }
View Full Code Here

        // Create a contribution
        ContributionFactory contributionFactory = modelFactories.getFactory(ContributionFactory.class);
        Contribution contribution = contributionFactory.createContribution();
        contribution.setURI("testContribution");
        ModelResolverExtensionPoint modelResolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class);
        ModelResolver modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories);
        contribution.setModelResolver(modelResolver);
        contribution.setClassLoader(new URLClassLoader(new URL[] {new File("src/test/resources/sample-helloworld.jar").toURI().toURL()}));

        // Create a composite
        AssemblyFactory assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
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("http://tuscany.apache.org/SystemContribution");
        systemContribution.setLocation("http://tuscany.apache.org/SystemContribution");
        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

    private void configureNode(ConfiguredNodeImplementation configuration) throws Exception {

        // Create workspace model
        Workspace workspace = workspaceFactory.createWorkspace();
        workspace.setModelResolver(new ExtensibleModelResolver(workspace, modelResolvers, modelFactories));

        // Load the specified contributions
        for (Contribution c : configuration.getContributions()) {
            URI contributionURI = URI.create(c.getURI());
View Full Code Here

    public void loadContribution(String compositeURL, String sourceURI, String sourceURL) throws Exception {
        init();

        // Create workspace model
        workspace = workspaceFactory.createWorkspace();
        workspace.setModelResolver(new ExtensibleModelResolver(workspace, modelResolvers, modelFactories));

        // Read the test contribution
        URI artifactURI = URI.create(sourceURI);
        URL artifactURL = new File(sourceURL).toURI().toURL();
        URL contributionURL = new File(compositeURL).toURI().toURL();
View Full Code Here

    public void loadContribution(String compositeURL, String sourceURI, String sourceURL) throws Exception {
      init();

        // Create workspace model
        workspace = workspaceFactory.createWorkspace();
        workspace.setModelResolver(new ExtensibleModelResolver(workspace, modelResolvers, modelFactories));

        // Read the sample store contribution
        URI artifactURI = URI.create(sourceURI);
        //URL contributionURL = FileHelper.toFile(new URL(sourceURL)).toURI().toURL();
        URL artifactURL = new File(sourceURL).toURI().toURL();
View Full Code Here

    public void readContribution(String compositeURL, String sourceURI, String sourceURL) throws Exception {
      init();

        // Create workspace model
        workspace = workspaceFactory.createWorkspace();
        workspace.setModelResolver(new ExtensibleModelResolver(workspace, modelResolvers, modelFactories));

        // Read the sample store contribution
        URI artifactURI = URI.create(sourceURI);
        //URL contributionURL = FileHelper.toFile(new URL(sourceURL)).toURI().toURL();
        URL artifactURL = new File(sourceURL).toURI().toURL();
View Full Code Here

TOP

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

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.