Examples of ResourceImport


Examples of org.apache.tuscany.sca.contribution.resource.ResourceImport

     * @throws Exception
     */
    @Test
    public void testLoad() throws Exception {
        XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(VALID_XML));
        ResourceImport namespaceImport = (ResourceImport)staxProcessor.read(reader, context);
        assertEquals("helloworld/HelloWorldService.componentType", namespaceImport.getURI());
        assertEquals("sca://contributions/001", namespaceImport.getLocation());
    }
View Full Code Here

Examples of org.apache.tuscany.sca.contribution.resource.ResourceImport

    /**
     * Process <import.resource uri="" location=""/>
     */
    public ResourceImport read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException {
      ResourceImport resourceImport = this.factory.createResourceImport();
        QName element;

        try {
            while (reader.hasNext()) {
                int event = reader.getEventType();
                switch (event) {
                    case START_ELEMENT:
                        element = reader.getName();

                        // Read <import>
                        if (ResourceImport.TYPE.equals(element)) {
                            String uri = reader.getAttributeValue(null, URI);
                            if (uri == null) {
                              error(context.getMonitor(), "AttributeURIMissing", reader);
                                //throw new ContributionReadException("Attribute 'uri' is missing");
                            } else
                                resourceImport.setURI(uri);

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

Examples of org.apache.tuscany.sca.contribution.resource.ResourceImport

        }

        // If not found, delegate the resolution to the imports (in this case based on the resource imports)
        for (Import import_ : this.contribution.getImports()) {
            if (import_ instanceof ResourceImport) {
              ResourceImport resourceImport = (ResourceImport)import_;
              //check the import location against the computed package name from the componentType URI
                if ((resourceImport.getURI().equals(uri)) &&
                    (resourceImport.getModelResolver() != null)){
                    // Delegate the resolution to the import resolver
                    resolved = resourceImport.getModelResolver().resolveModel(Artifact.class, (Artifact)unresolved, context);
                    if (!resolved.isUnresolved()) {
                        return modelClass.cast(resolved);
                    }
                }
            }
View Full Code Here

Examples of org.apache.tuscany.sca.contribution.resource.ResourceImport

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

                    // Read <import>
                    if (IMPORT_RESOURCE.equals(element)) {
                        String uri = reader.getAttributeValue(null, URI);
                        if (uri == null) {
                            throw new ContributionReadException("Attribute 'namespace' is missing");
                        }
                        resourceImport.setURI(uri);

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

Examples of org.apache.tuscany.sca.contribution.resource.ResourceImport

       
        //If not found, delegate the resolution to the imports (in this case based on the resource imports)

        for (Import import_ : this.contribution.getImports()) {
            if (import_ instanceof ResourceImport) {
              ResourceImport resourceImport = (ResourceImport)import_;
              //check the import location against the computed package name from the componentType URI
                if (resourceImport.getURI().equals(uri)) {
                    // Delegate the resolution to the import resolver
                    resolved = resourceImport.getModelResolver().resolveModel(Artifact.class, (Artifact)unresolved);
                    if (!resolved.isUnresolved()) {
                        return modelClass.cast(resolved);
                    }
                }
            }
View Full Code Here

Examples of org.apache.tuscany.sca.contribution.resource.ResourceImport

        // Initialize the contribution imports
        for (Import import_: contribution.getImports()) {
            boolean initialized = false;

            if (import_ instanceof ResourceImport) {
                ResourceImport resourceImport = (ResourceImport)import_;
               
                // Find a matching contribution
                if (resourceImport.getLocation() != null) {
                    Contribution targetContribution = repository.getContribution(resourceImport.getLocation());
                    if (targetContribution != null) {
                   
                        // Find a matching contribution export
                        for (Export export: targetContribution.getExports()) {
                            if (export instanceof ResourceExport) {
                                ResourceExport resourceExport = (ResourceExport)export;
                                if (resourceImport.getURI().equals(resourceExport.getURI())) {
                                  resourceImport.setModelResolver(resourceExport.getModelResolver());
                                    initialized = true;
                                    break;
                                }
                            }
                        }
View Full Code Here

Examples of org.apache.tuscany.sca.contribution.resource.ResourceImport

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

        ModelFactoryExtensionPoint factories = new DefaultModelFactoryExtensionPoint();
        factories.addFactory(new ResourceImportExportFactoryImpl());
        ResourceImportProcessor importProcessor = new ResourceImportProcessor(factories);
        ResourceImport namespaceImport = importProcessor.read(reader);
       
        assertEquals("helloworld/HelloWorldService.componentType", namespaceImport.getURI());
        assertEquals("sca://contributions/001", namespaceImport.getLocation());
    }
View Full Code Here

Examples of org.apache.tuscany.sca.contribution.resource.ResourceImport

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

        ModelFactoryExtensionPoint factories = new DefaultModelFactoryExtensionPoint();
        factories.addFactory(new ResourceImportExportFactoryImpl());
        ResourceImportProcessor importProcessor = new ResourceImportProcessor(factories);
        ResourceImport namespaceImport = importProcessor.read(reader);
       
        assertEquals("helloworld/HelloWorldService.componentType", namespaceImport.getURI());
        assertEquals("sca://contributions/001", namespaceImport.getLocation());
    }
View Full Code Here

Examples of org.apache.tuscany.sca.contribution.resource.ResourceImport

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

                    // Read <import>
                    if (IMPORT_RESOURCE.equals(element)) {
                        String uri = reader.getAttributeValue(null, URI);
                        if (uri == null) {
                            throw new ContributionReadException("Attribute 'namespace' is missing");
                        }
                        resourceImport.setURI(uri);

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

Examples of org.apache.tuscany.sca.contribution.resource.ResourceImport

       
        //If not found, delegate the resolution to the imports (in this case based on the resource imports)

        for (Import import_ : this.contribution.getImports()) {
            if (import_ instanceof ResourceImport) {
              ResourceImport resourceImport = (ResourceImport)import_;
              //check the import location against the computed package name from the componentType URI
                if (resourceImport.getURI().equals(uri)) {
                    // Delegate the resolution to the import resolver
                    resolved = resourceImport.getModelResolver().resolveModel(Artifact.class, (Artifact)unresolved);
                    if (!resolved.isUnresolved()) {
                        return modelClass.cast(resolved);
                    }
                }
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.