Package org.apache.tuscany.sca.contribution.namespace

Examples of org.apache.tuscany.sca.contribution.namespace.NamespaceImport


                unresolved.setLocation(new URI(schemaLocation));
                unresolved.setNamespace(targetNamespace);
                               
                for (Import import_ : this.contribution.getImports()) {
                    if (import_ instanceof NamespaceImport) {
                        NamespaceImport namespaceImport = (NamespaceImport)import_;
                        if (namespaceImport.getNamespace().equals(targetNamespace)) {                         
                          // Delegate the resolution to the namespace import resolver
                          resolved =
                              namespaceImport.getModelResolver().resolveModel(XSDefinition.class, (XSDefinition)unresolved, context);
                          if (!resolved.isUnresolved()) {
                            return XMLDocumentHelper.getInputSource(resolved.getLocation().toURL());
                          }
                        }
                    } else if (import_ instanceof DefaultImport) {
View Full Code Here


      List<String> locations = new ArrayList<String>();
        // Collection of namespace imports with location
        Map<String, NamespaceImport> locationMap = new HashMap<String, NamespaceImport>();
        for (Import import_ : this.contribution.getImports()) {
            if (import_ instanceof NamespaceImport) {
                NamespaceImport namespaceImport = (NamespaceImport)import_;
                if (namespaceImport.getNamespace().equals(qname.getNamespaceURI())) {
                    if (namespaceImport.getLocation() == null) {
                      // Delegate the resolution to the import resolver
                      resolved = namespaceImport.getModelResolver().resolveModel(BPELProcessDefinition.class, (BPELProcessDefinition)unresolved, context);
                      if (!resolved.isUnresolved()) {
                          return modelClass.cast(resolved);
                      }
                    } else {
                      // We might have multiple imports for the same namespace,
                    // need to search them in lexical order.
                    locations.add(namespaceImport.getLocation());
                    }
                }
            }
        }
        // Search namespace imports with locations in lexical order
        Collections.sort(locations);
        for (String location : locations) {
          NamespaceImport namespaceImport = (NamespaceImport)locationMap.get(location);
          // Delegate the resolution to the namespace import resolver
            resolved = namespaceImport.getModelResolver().resolveModel(BPELProcessDefinition.class, (BPELProcessDefinition)unresolved, context);
            if (!resolved.isUnresolved()) {
                return modelClass.cast(resolved);
            }
        }
       
View Full Code Here

     * @throws Exception
     */
    @Test
    public void testLoad() throws Exception {
        XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(VALID_XML));
        NamespaceImport namespaceImport = (NamespaceImport)staxProcessor.read(reader, context);

        assertEquals("http://foo", namespaceImport.getNamespace());
        assertEquals("sca://contributions/001", namespaceImport.getLocation());
        assertEquals(1, namespaceImport.getAttributeExtensions().size());
        assertEquals(1, namespaceImport.getExtensions().size());
    }
View Full Code Here

        }

        // No definition found, delegate the resolution to the imports
        for (Import import_ : this.contribution.getImports()) {
            if (import_ instanceof NamespaceImport) {
                NamespaceImport namespaceImport = (NamespaceImport)import_;
                if (namespaceImport.getNamespace().equals(namespace)) {

                    // Delegate the resolution to the import resolver
                    resolved =
                        namespaceImport.getModelResolver().resolveModel(XSDefinition.class, (XSDefinition)unresolved);
                    if (!resolved.isUnresolved()) {
                        return modelClass.cast(resolved);
                    }
                }
            }
View Full Code Here

        }

        // No definition found, delegate the resolution to the imports
        for (Import import_ : this.contribution.getImports()) {
            if (import_ instanceof NamespaceImport) {
                NamespaceImport namespaceImport = (NamespaceImport)import_;
                if (namespaceImport.getNamespace().equals(namespace)) {

                    // Delegate the resolution to the import resolver
                    resolved =
                        namespaceImport.getModelResolver().resolveModel(WSDLDefinition.class,
                                                                        (WSDLDefinition)unresolved);
                    if (!resolved.isUnresolved()) {
                        return modelClass.cast(resolved);
                    }
                }
View Full Code Here

        for (Import import_: contribution.getImports()) {
            boolean initialized = false;

           
            if (import_ instanceof NamespaceImport) {
                NamespaceImport namespaceImport = (NamespaceImport)import_;
               
                // Find a matching contribution
                if (namespaceImport.getLocation() != null) {
                    Contribution targetContribution = repository.getContribution(namespaceImport.getLocation());
                    if (targetContribution != null) {
                   
                        // Find a matching contribution export
                        for (Export export: targetContribution.getExports()) {
                            if (export instanceof NamespaceExport) {
                                NamespaceExport namespaceExport = (NamespaceExport)export;
                                if (namespaceImport.getNamespace().equals(namespaceExport.getNamespace())) {
                                    namespaceImport.setModelResolver(namespaceExport.getModelResolver());
                                   
                                    List<Contribution> exportingContributions = new ArrayList<Contribution>();
                                    exportingContributions.add(namespaceExport.getContribution());
                                    import_.setExportContributions(exportingContributions);
                                   
View Full Code Here

     
     
      // Lookup a definition for the given namespace, from imports       
        for (Import import_ : this.contribution.getImports()) {
            if (import_ instanceof NamespaceImport) {
                NamespaceImport namespaceImport = (NamespaceImport)import_;
                if (namespaceImport.getNamespace().equals(namespace)) {
                  // Delegate the resolution to the namespace import resolver
                  resolved =
                    namespaceImport.getModelResolver().resolveModel(WSDLDefinition.class,
                                                                          (WSDLDefinition)unresolved, context);
                  if (!resolved.isUnresolved()) {
                    return modelClass.cast(resolved);
                  }
                }
View Full Code Here

        // Initialize the contribution imports
        for (Import import_: contribution.getImports()) {
            boolean initialized = false;
           
            if (import_ instanceof NamespaceImport) {
                NamespaceImport namespaceImport = (NamespaceImport)import_;
               
                // Find a matching contribution
                if (namespaceImport.getLocation() != null) {
                    Contribution targetContribution = repository.getContribution(namespaceImport.getLocation());
                    if (targetContribution != null) {
                   
                        // Find a matching contribution export
                        for (Export export: targetContribution.getExports()) {
                            if (export instanceof NamespaceExport) {
                                NamespaceExport namespaceExport = (NamespaceExport)export;
                                if (namespaceImport.getNamespace().equals(namespaceExport.getNamespace())) {
                                    namespaceImport.setModelResolver(namespaceExport.getModelResolver());
                                    initialized = true;
                                    break;
                                }
                            }
                        }
View Full Code Here

    /**
     * Process <import namespace="" location=""/>
     */
    public NamespaceImport read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
        NamespaceImport namespaceImport = this.factory.createNamespaceImport();
        QName element;
       
        while (reader.hasNext()) {
            int event = reader.getEventType();
            switch (event) {
                case START_ELEMENT:
                    element = reader.getName();

                    // Read <import>
                    if (IMPORT.equals(element)) {
                        String ns = reader.getAttributeValue(null, NAMESPACE);
                        if (ns == null) {
                            throw new ContributionReadException("Attribute 'namespace' is missing");
                        }
                        namespaceImport.setNamespace(ns);

                        String location = reader.getAttributeValue(null, LOCATION);
                        if (location != null) {
                            namespaceImport.setLocation(location);
                        }
                    }
                    break;
                case XMLStreamConstants.END_ELEMENT:
                    if (IMPORT.equals(reader.getName())) {
View Full Code Here

        }

        // No definition found, delegate the resolution to the imports
        for (Import import_ : this.contribution.getImports()) {
            if (import_ instanceof NamespaceImport) {
                NamespaceImport namespaceImport = (NamespaceImport)import_;
                if (namespaceImport.getNamespace().equals(namespace)) {

                    // Delegate the resolution to the import resolver
                    resolved =
                        namespaceImport.getModelResolver().resolveModel(XSDefinition.class, (XSDefinition)unresolved);
                    if (!resolved.isUnresolved()) {
                        return modelClass.cast(resolved);
                    }
                }
            }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.contribution.namespace.NamespaceImport

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.