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

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


    }
   
    @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, context);
               
View Full Code Here


        Contribution contribution = contributionFactory.createContribution();
        contribution.setURI(contributionURI.toString());
        if (contributionURL != null) {
            contribution.setLocation(contributionURL.toString());
        }
        ModelResolver modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories);
        contribution.setModelResolver(modelResolver);
        contribution.setUnresolved(true);

        Monitor monitor = context.getMonitor();
        monitor.pushContext("Contribution: " + contribution.getURI());

        Contribution old = context.setContribution(contribution);
        try {
            if (contributionURL != null) {
                // Create a contribution scanner
                ContributionScanner scanner = scanners.getContributionScanner(contributionURL.getProtocol());
                if (scanner == null) {
                    File file = toFile(contributionURL);
                    if (file != null && file.isDirectory()) {
                        scanner = new DirectoryContributionScanner(contributionFactory);
                    } else {
                        scanner = new JarContributionScanner(contributionFactory);
                    }
                }

                // Scan the contribution and list the artifacts contained in it
                boolean contributionMetadata = false;
                List<Artifact> artifacts = scanner.scan(contribution);
                for (Artifact artifact : artifacts) {
                    // Add the deployed artifact model to the contribution
                    modelResolver.addModel(artifact, context);

                    monitor.pushContext("Artifact: " + artifact.getURI());

                    Artifact oldArtifact = context.setArtifact(artifact);
                    try {
                        // Read each artifact
                        URL artifactLocationURL = null;
                        try {
                            artifactLocationURL = new URL(artifact.getLocation());
                        } catch (MalformedURLException e) {
                            //ignore
                        }

                        Object model =
                            artifactProcessor.read(contributionURL,
                                                   URI.create(artifact.getURI()),
                                                   artifactLocationURL,
                                                   context);
                        if (model != null) {
                            artifact.setModel(model);

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

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

     * @throws ContributionResolveException
     */
    public void preResolve(Contribution contribution, ModelResolver resolver, ProcessorContext context)
        throws ContributionResolveException {
        // Resolve the contribution model itself
        ModelResolver contributionResolver = contribution.getModelResolver();
        contribution.setUnresolved(false);
        contributionResolver.addModel(contribution, context);

        // Resolve Exports
        resolveExports(contribution, contributionResolver, context);
        // Resolve Imports
        resolveImports(contribution, contributionResolver, context);
View Full Code Here

        try {
            monitor.pushContext("Contribution: " + contribution.getURI());

            if (!preResolved)
                preResolve(contribution, resolver, context);
            ModelResolver contributionResolver = contribution.getModelResolver();

            // Validate Java Exports: [JCI100007] A Java package that is specified on an export
            // element MUST be contained within the contribution containing the export element.
            for (Export export : contribution.getExports()) {
                if (export instanceof JavaExport) {
                    boolean available = false;
                    String packageName = ((JavaExport)export).getPackage();
                    for (Artifact artifact : contribution.getArtifacts()) {
                        if (packageName.equals(artifact.getURI().replace("/", ".")))
                            available = true;
                    }
                    if (!available) {
                        String message = context.getMonitor().getMessageString(ContributionContentProcessor.class.getName(),
                                                                               "contribution-xml-validation-messages",
                                                                               "ExportedPackageNotFound");
                        message = message.replace("{0}", packageName);

                        throw new ContributionResolveException(message);
                    }
                }
            }

            // Resolve all artifact models
            for (Artifact artifact : contribution.getArtifacts()) {
                Object model = artifact.getModel();
                if (model != null) {
                    Artifact oldArtifact = context.setArtifact(artifact);
                    try {
                        artifactProcessor.resolve(model, contributionResolver, context);
                    } catch (Throwable e) {
                        throw new ContributionResolveException(e);
                    } finally {
                        context.setArtifact(oldArtifact);
                    }
                }
            }

            // Resolve deployable composites
            List<Composite> deployables = contribution.getDeployables();
            Artifact oldArtifact = context.setArtifact(contribution);
            try {
                for (int i = 0, n = deployables.size(); i < n; i++) {
                    Composite deployable = deployables.get(i);
                    Composite resolved =
                        (Composite)contributionResolver.resolveModel(Composite.class, deployable, context);
                    if (resolved != deployable) {
                        deployables.set(i, resolved);
                    }
                } // end for
            } finally {
View Full Code Here

            ContributionFactory contributionFactory = modelFactories.getFactory(ContributionFactory.class);
            final org.apache.tuscany.sca.contribution.Contribution contribution = contributionFactory.createContribution();
            ProcessorContext processorContext = new ProcessorContext();
           
            ExtensibleModelResolver extensibleResolver = new ExtensibleModelResolver(contribution, registry.getExtensionPoint(ModelResolverExtensionPoint.class), modelFactories);
            ModelResolver wsdlResolver = (ModelResolver)extensibleResolver.getModelResolverInstance(WSDLDefinition.class);
            XSDModelResolver xsdResolver = (XSDModelResolver)extensibleResolver.getModelResolverInstance(XSDefinition.class);
            contribution.setURI("temp");
            contribution.setLocation(topWSDLLocation);
            contribution.setModelResolver(extensibleResolver);
   
            // read
            for (XMLString xmlString : xmlMap.values()){
                if (xmlString instanceof WSDLInfo){
                    WSDLReader reader;
                    try {
                        reader =  AccessController.doPrivileged(new PrivilegedExceptionAction<WSDLReader>() {
                            public WSDLReader run() throws WSDLException {
                                return javax.wsdl.factory.WSDLFactory.newInstance().newWSDLReader();                        
                            }
                        });
                    } catch (PrivilegedActionException e){
                        throw (WSDLException)e.getException();
                    }
                    reader.setFeature("javax.wsdl.verbose", false);
                    reader.setFeature("javax.wsdl.importDocuments", true);
                    final WSDLLocatorImpl locator = new WSDLLocatorImpl(xmlString.getBaseURI(), xmlMap);
                    final WSDLReader freader = reader;
                    Definition readDefinition;
                    try {
                        readDefinition = AccessController.doPrivileged(new PrivilegedExceptionAction<Definition>() {
                            public Definition run() throws WSDLException {
                                return freader.readWSDL(locator);                       
                            }
                        });
                    } catch (PrivilegedActionException e){
                        throw (WSDLException)e.getException();
                    }
                   
                    WSDLDefinition wsdlDefinition = wsdlFactory.createWSDLDefinition();
                    wsdlDefinition.setDefinition(readDefinition);
                    wsdlDefinition.setLocation(new URI(xmlString.getBaseURI()));
                   
                    ((WSDLInfo)xmlString).setWsdlDefintion(wsdlDefinition);
                    wsdlResolver.addModel(wsdlDefinition, processorContext);
                   
                } else {
                    InputStream inputStream = new ByteArrayInputStream(xmlString.getXmlString().getBytes());
                    InputSource inputSource = new InputSource(inputStream);
                    inputSource.setSystemId(xmlString.getBaseURI());
View Full Code Here

        InterfaceContract icontract = wsBinding.getBindingInterfaceContract();
        if (icontract == null) {
            icontract = ((Contract)contract).getInterfaceContract(wsBinding).makeUnidirectional(false);
            if (icontract instanceof JavaInterfaceContract) {
                ModelResolver resolver = component instanceof ResolverExtension ?
                                             ((ResolverExtension)component).getModelResolver() : null;
                icontract = createWSDLInterfaceContract(
                                    (JavaInterfaceContract)icontract,
                                    requiresSOAP12(wsBinding),
                                    resolver,
View Full Code Here

        ImplementationType javaImplType = implTypesTable.get(javaImpl);
        assertNull(javaImplType.getAlwaysProvidedIntents().get(0).getDescription());
        assertNull(javaImplType.getMayProvidedIntents().get(0).getDescription());

        ModelResolver resolver = new DefaultModelResolver();
        policyDefinitionsProcessor.resolve(definitions, resolver, context);
        //builder.build(scaDefinitions);

        //testing if policy intents have been linked have property been linked up
        assertNotNull(i1.getRequiredIntents().get(0).getDescription());
View Full Code Here

        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, context);
        resolver.addModel(componentType, context);

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

        XMLStreamReader reader = getReader(xml);
        assertFalse(inited);
        ProcessorContext context = new ProcessorContext(registry);
        ImportSDO importSDO = loader.read(reader, context);
        assertNotNull(importSDO);
        ModelResolver resolver = new TestModelResolver();
        resolver.addModel(new ClassReference(MockFactory.class), context);
        loader.resolve(importSDO, resolver, context);
        assertTrue(inited);
    }
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

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.