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

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


        unresolved.setUnresolved(true);
        unresolved.setNamespace(namespace);
                       
        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(XSDefinition.class, (XSDefinition)unresolved, context);
                    if (!resolved.isUnresolved()) {
                        return resolved;
                    }
                }
            } 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

                // When a contribution contains a reference to an artifact from a namespace that
                // is declared in an import statement of the contribution, if the SCA artifact
                // resolution mechanism is used to resolve the artifact, the SCA runtime MUST resolve
                // artifacts from the locations identified by the import statement(s) for the namespace.
                if (import_ instanceof NamespaceImport) {
                  NamespaceImport namespaceImport = (NamespaceImport)import_;
                  if (namespaceImport.getLocation() != null)
                    if (!namespaceImport.getLocation().equals(dependency.getURI()))
                      continue;
                }               
                if (import_ instanceof JavaImport) {
                  JavaImport javaImport = (JavaImport)import_;
                  if (javaImport.getLocation() != null)
View Full Code Here

    /**
     * Process <import namespace="" location=""/>
     */
    public NamespaceImport read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException {
        NamespaceImport namespaceImport = this.factory.createNamespaceImport();
        QName element;

        try {
            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) {
                              error(context.getMonitor(), "AttributeNameSpaceMissing", reader);
                                //throw new ContributionReadException("Attribute 'namespace' is missing");
                            } else {
                                namespaceImport.setNamespace(ns);
                            }

                            String location = getURIString(reader, LOCATION);
                            if (location != null) {
                                namespaceImport.setLocation(location);
                            }
                            readExtendedAttributes(reader, namespaceImport, attributeProcessor, extensionFactory, context);
                        } else {
                            // handle extended elements
                            Object ext = extensionProcessor.read(reader, context);
                            if (namespaceImport != null) {
                                namespaceImport.getExtensions().add(ext);
                            }
                        }
                        break;
                    case XMLStreamConstants.END_ELEMENT:
                        if (IMPORT.equals(reader.getName())) {
View Full Code Here

                unresolved.setNamespace(targetNamespace);
                               
                for (Import import_ : this.contribution.getImports()) {
                    URL resolvedURL;
                    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()) {
                                resolvedURL = resolved.getLocation().toURL();
                                return xmlDocumentHelperGetInputSource(resolvedURL);
                          }
                        }
View Full Code Here

    public void testAnalyze() throws Exception {
        Workspace workspace = workspaceFactory.createWorkspace();
        Contribution importer = contributionFactory.createContribution();
        importer.setURI("importer");
        workspace.getContributions().add(importer);
        NamespaceImport import_ = importExportFactory.createNamespaceImport();
        import_.setNamespace("http://foo");
        importer.getImports().add(import_);

        Contribution imported = contributionFactory.createContribution();
        imported.setURI("imported");
        workspace.getContributions().add(imported);
        NamespaceExport export = importExportFactory.createNamespaceExport();
        export.setNamespace("http://foo");
        imported.getExports().add(export);
        import_ = importExportFactory.createNamespaceImport();
        import_.setNamespace("http://bar");
        imported.getImports().add(import_);
       
        Contribution imported2 = contributionFactory.createContribution();
        imported2.setURI("imported2");
        workspace.getContributions().add(imported2);
View Full Code Here

    public void testAnalyze() {
        Workspace workspace = workspaceFactory.createWorkspace();
        Contribution importer = contributionFactory.createContribution();
        importer.setURI("importer");
        workspace.getContributions().add(importer);
        NamespaceImport import_ = importExportFactory.createNamespaceImport();
        import_.setNamespace("http://foo");
        importer.getImports().add(import_);

        Contribution imported = contributionFactory.createContribution();
        imported.setURI("imported");
        workspace.getContributions().add(imported);
        NamespaceExport export = importExportFactory.createNamespaceExport();
        export.setNamespace("http://foo");
        imported.getExports().add(export);
        import_ = importExportFactory.createNamespaceImport();
        import_.setNamespace("http://bar");
        imported.getImports().add(import_);
       
        Contribution imported2 = contributionFactory.createContribution();
        imported2.setURI("imported2");
        workspace.getContributions().add(imported2);
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 namespace import resolver
                    resolved =
                        namespaceImport.getModelResolver().resolveModel(WSDLDefinition.class,
                                                                        (WSDLDefinition)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 namespace import resolver
                    resolved =
                        namespaceImport.getModelResolver().resolveModel(XSDefinition.class, (XSDefinition)unresolved);
                    if (!resolved.isUnresolved()) {
                        return modelClass.cast(resolved);
                    }
                }
            } else if (import_ instanceof DefaultImport) {
View Full Code Here

     * Test loading a valid import element from a contribution metadata stream
     * @throws Exception
     */
    public void testLoad() throws Exception {
        XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(VALID_XML));
        NamespaceImport namespaceImport = (NamespaceImport)staxProcessor.read(reader);
       
        assertEquals("http://foo", namespaceImport.getNamespace());
        assertEquals("sca://contributions/001", namespaceImport.getLocation());
    }
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.