Package org.apache.tuscany.sca.contribution.java

Examples of org.apache.tuscany.sca.contribution.java.JavaImport


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

            if (import_ instanceof JavaImport) {
                JavaImport javaImport = (JavaImport)import_;
                String packageName = javaImport.getPackage();

                //Find a matching contribution
                if (javaImport.getLocation() != null) {
                    Contribution targetContribution = repository.getContribution(javaImport.getLocation());
                    if (targetContribution != null) {

                        // Find a matching contribution export
                        for (Export export : targetContribution.getExports()) {
                            if (export instanceof JavaExport) {
View Full Code Here


        ClassReference resolved = unresolved;

        if (this.contribution != null) {
            for (Import import_ : this.contribution.getImports()) {
                if (import_ instanceof JavaImport) {
                    JavaImport javaImport = (JavaImport)import_;
                    String packageName = javaImport.getPackage();
                    if (javaImport.getPackage().equals(packageName)) {
                        // Delegate the resolution to the import resolver
                        resolved = import_.getModelResolver().resolveModel(ClassReference.class, unresolved);
                    }
                }
            }
View Full Code Here

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

        ModelFactoryExtensionPoint factories = new DefaultModelFactoryExtensionPoint();
        factories.addFactory(new JavaImportExportFactoryImpl());
        JavaImportProcessor importProcessor = new JavaImportProcessor(factories);
        JavaImport javaImport = importProcessor.read(reader);
       
        assertEquals("org.apache.tuscany.sca.contribution.java", javaImport.getPackage());
        assertEquals("sca://contributions/001", javaImport.getLocation());
    }
View Full Code Here

    /**
     * Process <import.java package="" location=""/>
     */
    public JavaImport read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
        JavaImport javaImport = this.factory.createJavaImport();
        QName element = null;
       
        while (reader.hasNext()) {
            int event = reader.getEventType();
            switch (event) {
                case START_ELEMENT:
                    element = reader.getName();

                    // Read <import.java>
                    if (IMPORT_JAVA.equals(element)) {
                        String packageName = reader.getAttributeValue(null, PACKAGE);
                        if (packageName == null) {
                            throw new ContributionReadException("Attribute 'package' is missing");
                        }
                       
                        String location = reader.getAttributeValue(null, LOCATION);
                        javaImport.setPackage(packageName);
                        javaImport.setLocation(location);
                    }
                    break;
                case XMLStreamConstants.END_ELEMENT:
                    if (IMPORT_JAVA.equals(reader.getName())) {
                        return javaImport;
View Full Code Here

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

    /**
     * Process <import.java package="" location=""/>
     */
    public JavaImport read(XMLStreamReader reader) throws ContributionReadException {
        JavaImport javaImport = this.factory.createJavaImport();
        QName element = null;
       
        try {
            while (reader.hasNext()) {
                int event = reader.getEventType();
                switch (event) {
                    case START_ELEMENT:
                        element = reader.getName();
   
                        // Read <import.java>
                        if (IMPORT_JAVA.equals(element)) {
                            String packageName = reader.getAttributeValue(null, PACKAGE);
                            if (packageName == null) {
                              error("AttributePackageMissing", reader);
                                //throw new ContributionReadException("Attribute 'package' is missing");
                            } else
                              javaImport.setPackage(packageName);
                           
                            String location = reader.getAttributeValue(null, LOCATION);                       
                            javaImport.setLocation(location);
                        }
                        break;
                    case XMLStreamConstants.END_ELEMENT:
                        if (IMPORT_JAVA.equals(reader.getName())) {
                            return javaImport;
View Full Code Here

        // Index Java import resolvers by package name
        Map<String, List<ModelResolver>> resolverMap = new HashMap<String, List<ModelResolver>>();
        for (Import import_: this.contribution.getImports()) {
            if (import_ instanceof JavaImport) {
                JavaImport javaImport = (JavaImport)import_;
                List<ModelResolver> resolvers = resolverMap.get(javaImport.getPackage());
                if (resolvers == null) {
                    resolvers = new ArrayList<ModelResolver>();
                    resolverMap.put(javaImport.getPackage(), resolvers);
                }
                resolvers.add(javaImport.getModelResolver());
            }
        }

        // Create a delegating model resolver for each imported package
        for (Map.Entry<String, List<ModelResolver>> entry: resolverMap.entrySet()) {
View Full Code Here

    /**
     * Process <import.java package="" location=""/>
     */
    public JavaImport read(XMLStreamReader reader) throws ContributionReadException {
        JavaImport javaImport = this.factory.createJavaImport();
        QName element = null;
       
        try {
            while (reader.hasNext()) {
                int event = reader.getEventType();
                switch (event) {
                    case START_ELEMENT:
                        element = reader.getName();
   
                        // Read <import.java>
                        if (IMPORT_JAVA.equals(element)) {
                            String packageName = reader.getAttributeValue(null, PACKAGE);
                            if (packageName == null) {
                              error("AttributePackageMissing", reader);
                                //throw new ContributionReadException("Attribute 'package' is missing");
                            } else
                              javaImport.setPackage(packageName);
                           
                            String location = getURIString(reader, LOCATION);                       
                            javaImport.setLocation(location);
                        }
                        break;
                    case XMLStreamConstants.END_ELEMENT:
                        if (IMPORT_JAVA.equals(reader.getName())) {
                            return javaImport;
View Full Code Here

        this.contribution = new WeakReference<Contribution>(contribution);
        // Index Java import resolvers by package name
        Map<String, List<ModelResolver>> resolverMap = new HashMap<String, List<ModelResolver>>();
        for (Import import_: this.contribution.get().getImports()) {
            if (import_ instanceof JavaImport) {
                JavaImport javaImport = (JavaImport)import_;
                List<ModelResolver> resolvers = resolverMap.get(javaImport.getPackage());
                if (resolvers == null) {
                    resolvers = new ArrayList<ModelResolver>();
                    resolverMap.put(javaImport.getPackage(), resolvers);
                }
                resolvers.add(javaImport.getModelResolver());
            }
        }

        // Create a delegating model resolver for each imported package
        for (Map.Entry<String, List<ModelResolver>> entry: resolverMap.entrySet()) {
View Full Code Here

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

            if (import_ instanceof JavaImport) {
                JavaImport javaImport = (JavaImport)import_;
                String packageName = javaImport.getPackage();

                //Find a matching contribution
                if (javaImport.getLocation() != null) {
                    Contribution targetContribution = repository.getContribution(javaImport.getLocation());
                    if (targetContribution != null) {

                        // Find a matching contribution export
                        for (Export export : targetContribution.getExports()) {
                            if (export instanceof JavaExport) {
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.contribution.java.JavaImport

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.