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

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


                if (javaImport.getPackage() == null)
                    return false;
                else
                    return packageName.equals(javaImport.getPackage().replaceAll("\\.", "/"));
            } else if (import_ instanceof NamespaceImport) {
                NamespaceImport namespaceImport = (NamespaceImport) import_;
                String namespace = name.substring(0, name.lastIndexOf('/'));
                if (namespaceImport.getNamespace() == null)
                    return false;
                else
                    return namespaceImport.getNamespace().equals(namespace);
            }
        }
        return false;
    }
View Full Code Here


       
        JavaImport import_ = javaImportExportFactory.createJavaImport();
        import_.setPackage(this.getClass().getPackage().getName());
        import_.setExportContributions(exportContribList);
        contribB.getImports().add(import_);
        NamespaceImport import1_ = namespaceImportExportFactory.createNamespaceImport();
        import1_.setNamespace("calculator");
        import1_.setExportContributions(exportContribList);
        contribB.getImports().add(import1_);
       
        JavaExport export = javaImportExportFactory.createJavaExport();
        export.setPackage(this.getClass().getPackage().getName());
        contribA.getExports().add(export);
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

    /**
     * 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

    /**
     * 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

        // 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(qname.getNamespaceURI())) {
                   
                    // Delegate the resolution to the import resolver
                    resolved = namespaceImport.getModelResolver().resolveModel(Composite.class, (Composite)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(qname.getNamespaceURI())) {
                   
                    // Delegate the resolution to the import resolver
                    resolved = namespaceImport.getModelResolver().resolveModel(ConstrainingType.class, (ConstrainingType)unresolved);
                    if (!resolved.isUnresolved()) {
                        return modelClass.cast(resolved);
                    }
                }
            }
View Full Code Here

        XMLStreamReader reader = xmlFactory.createXMLStreamReader(new StringReader(VALID_XML));

        ModelFactoryExtensionPoint factories = new DefaultModelFactoryExtensionPoint();
        factories.addFactory(new NamespaceImportExportFactoryImpl());
        NamespaceImportProcessor importProcessor = new NamespaceImportProcessor(factories);
        NamespaceImport namespaceImport = importProcessor.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.