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

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


        // Create contribution model
        Contribution contribution = contributionFactory.createContribution();
        contribution.setURI(contributionURI.toString());
        contribution.setLocation(contributionURL.toString());
        ModelResolver modelResolver = new ExtensibleModelResolver(contribution, extensionPoints);
        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

            ContributionFactory contributionFactory = modelFactories.getFactory(ContributionFactory.class);
            Artifact compositeFile = contributionFactory.createArtifact();
            compositeFile.setUnresolved(true);
            compositeFile.setURI(composite.getURI());
            for (Contribution c : contributions) {
                ModelResolver resolver = c.getModelResolver();
                Artifact resolved = resolver.resolveModel(Artifact.class, compositeFile);
                if (resolved != null && resolved.isUnresolved() == false) {
                    composite = (Composite) resolved.getModel();
                    break;
                }
            }
View Full Code Here

        }
        ContributionFactory contributionFactory = modelFactories.getFactory(ContributionFactory.class);
        Artifact compositeFile = contributionFactory.createArtifact();
        compositeFile.setUnresolved(true);
        compositeFile.setURI(uri);
        ModelResolver resolver = contribution.getModelResolver();
        Artifact resolved = resolver.resolveModel(Artifact.class, compositeFile);
        if (resolved != null && !resolved.isUnresolved()) {
            return resolved.getLocation();
        } else {
            return null;
        }
View Full Code Here

        ContributionFactory contributionFactory = modelFactories.getFactory(ContributionFactory.class);
        Artifact compositeFile = contributionFactory.createArtifact();
        compositeFile.setUnresolved(true);
        compositeFile.setURI(compositeURI);
        for (Contribution c : contributions) {
            ModelResolver resolver = c.getModelResolver();
            Artifact resolved = resolver.resolveModel(Artifact.class, compositeFile);
            if (resolved != null && !resolved.isUnresolved()) {
                return c;
            }
        }
        return null;
View Full Code Here

        } else {
            packageName = null;
        }
       
        // First try to load the class using the Java import resolvers
        ModelResolver importResolver = importResolvers.get(packageName);
        if (importResolver != null) {
            ClassReference classReference = importResolver.resolveModel(ClassReference.class, new ClassReference(name));
            if (!classReference.isUnresolved()) {
                return classReference.getJavaClass();
            }
        }
View Full Code Here

     * @throws MalformedURLException
     */
    private void processReadPhase(Contribution contribution, List<URI> artifacts) throws ContributionException,
        MalformedURLException, XMLStreamException {

        ModelResolver modelResolver = contribution.getModelResolver();
        URL contributionURL = new URL(contribution.getLocation());

        List<URI> compositeUris = new ArrayList<URI>();

        Object model = null;
        for (URI anArtifactUri : artifacts) {
            if ( anArtifactUri.toString().endsWith(COMPOSITE_FILE_EXTN)) {
                compositeUris.add(anArtifactUri);
            } else {
                URL artifactURL = packageProcessor.getArtifactURL(new URL(contribution.getLocation()), anArtifactUri);

                // Add the deployed artifact model to the resolver
                Artifact artifact = this.contributionFactory.createArtifact();
                artifact.setURI(anArtifactUri.toString());
                artifact.setLocation(artifactURL.toString());
                contribution.getArtifacts().add(artifact);
                modelResolver.addModel(artifact);

                model = this.artifactProcessor.read(contributionURL, anArtifactUri, artifactURL);

                if (model != null) {
                    artifact.setModel(model);

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

                    // Add policy definitions to the list of policy definitions
                    if (model instanceof SCADefinitions) {
                        policyDefinitions.add(model);

                        SCADefinitions definitions = (SCADefinitions)model;
                        for (Intent intent : definitions.getPolicyIntents() ) {
                            policyDefinitionsResolver.addModel(intent);
                        }

                        for (PolicySet policySet : definitions.getPolicySets() ) {
                            policyDefinitionsResolver.addModel(policySet);
                        }

                        for (IntentAttachPointType attachPointType : definitions.getBindingTypes() ) {
                            policyDefinitionsResolver.addModel(attachPointType);
                        }

                        for (IntentAttachPointType attachPointType : definitions.getImplementationTypes() ) {
                            policyDefinitionsResolver.addModel(attachPointType);
                        }
                        for (Object binding : definitions.getBindings() ) {
                            policyDefinitionsResolver.addModel(binding);
                        }
                    }
                }
            }
        }

        for (URI anArtifactUri : compositeUris) {
            URL artifactURL = packageProcessor.getArtifactURL(new URL(contribution.getLocation()), anArtifactUri);

            // Add the deployed artifact model to the resolver
            Artifact artifact = this.contributionFactory.createArtifact();
            artifact.setURI(anArtifactUri.toString());
            artifact.setLocation(artifactURL.toString());
            contribution.getArtifacts().add(artifact);
            modelResolver.addModel(artifact);

            model = this.artifactProcessor.read(contributionURL, anArtifactUri, artifactURL);
            if (model != null) {
                artifact.setModel(model);
                // Add the loaded model to the model resolver
                modelResolver.addModel(model);
            }
        }
    }
View Full Code Here

        } catch (ValidationException e) {
            loadedContributions.remove(cd.getURI());
            throw e;
        }
        if (contribution.getClassLoader() == null && contribution.getModelResolver() instanceof ExtensibleModelResolver) {
            ModelResolver o = ((ExtensibleModelResolver)contribution.getModelResolver()).getModelResolverInstance(ClassReference.class);
            if (o instanceof ClassLoader) {
                contribution.setClassLoader((ClassLoader)o);       
            }
        }
    }
View Full Code Here

        builtComposite.setContributionURI(composite.getContributionURI());
       
        // attempt to ensure the contribution classloader is set
        // TODO: ideally the runtime would do this itself
        if (contribution.getClassLoader() == null && contribution.getModelResolver() instanceof ExtensibleModelResolver) {
            ModelResolver o = ((ExtensibleModelResolver)contribution.getModelResolver()).getModelResolverInstance(ClassReference.class);
            if (o instanceof ClassLoader) {
                contribution.setClassLoader((ClassLoader)o);       
            }
        }
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, context);
               
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.