Package org.apache.tuscany.sca.contribution.scanner

Examples of org.apache.tuscany.sca.contribution.scanner.ContributionScanner


        Contribution old = context.setContribution(contribution);
        try {
            if (contributionURL != null) {
                // Create a contribution scanner
                ContributionScanner scanner = scanners.getContributionScanner(contributionURL.getProtocol());
                if (scanner == null) {
                    File file = toFile(contributionURL);
                    if (file != null && file.isDirectory()) {
                        scanner = new DirectoryContributionScanner(contributionFactory);
                    } else {
                        scanner = new JarContributionScanner(contributionFactory);
                    }
                }

                // Scan the contribution and list the artifacts contained in it
                boolean contributionMetadata = false;
                List<Artifact> artifacts = scanner.scan(contribution);
                for (Artifact artifact : artifacts) {
                    // Add the deployed artifact model to the contribution
                    modelResolver.addModel(artifact, context);

                    monitor.pushContext("Artifact: " + artifact.getURI());
View Full Code Here


        ModelResolver modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories);
        contribution.setModelResolver(modelResolver);
        contribution.setUnresolved(true);

        // Create a contribution scanner
        ContributionScanner scanner;
        if ("file".equals(contributionURL.getProtocol()) && new File(contributionURL.getFile()).isDirectory()) {
            scanner = new DirectoryContributionScanner();
        } else {
            scanner = new JarContributionScanner();
        }
       
        // Scan the contribution and list the artifacts contained in it
        List<Artifact> artifacts = contribution.getArtifacts();
        boolean contributionMetadata = false;
        for (String artifactURI: scanner.getArtifacts(contributionURL)) {
            URL artifactURL = scanner.getArtifactURL(contributionURL, artifactURI);

            // Add the deployed artifact model to the contribution
            Artifact artifact = this.contributionFactory.createArtifact();
            artifact.setURI(artifactURI);
            artifact.setLocation(artifactURL.toString());
View Full Code Here

        ModelResolver modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories);
        contribution.setModelResolver(modelResolver);
        contribution.setUnresolved(true);

        // Create a contribution scanner
        ContributionScanner scanner;
        if ("file".equals(contributionURL.getProtocol()) && new File(contributionURL.getFile()).isDirectory()) {
            scanner = new DirectoryContributionScanner();
        } else {
            scanner = new JarContributionScanner();
        }
       
        // Read generated and user sca-contribution.xml files
        boolean contributionMetadata = false;
        for (String path: new String[]{
                                       Contribution.SCA_CONTRIBUTION_GENERATED_META,
                                       Contribution.SCA_CONTRIBUTION_META}) {
            URL url = scanner.getArtifactURL(contributionURL, path);
            try {
                // Check if the file actually exists before trying to read it
                URLConnection connection = url.openConnection();
                connection.setUseCaches(false);
                InputStream is = connection.getInputStream();
                is.close();
            } catch (IOException e) {
                continue;
            }
            contributionMetadata = true;
           
            // Read the sca-contribution.xml file
            Contribution c = (Contribution)artifactProcessor.read(contributionURL, URI.create(path), url);
            contribution.getImports().addAll(c.getImports());
            contribution.getExports().addAll(c.getExports());
            contribution.getDeployables().addAll(c.getDeployables());
        }
       
        // If no sca-contribution.xml file was provided then just consider
        // all composites in the contribution as deployables
        if (!contributionMetadata) {
            List<String> artifactURIs;
            try {
                artifactURIs = scanner.getArtifacts(contributionURL);
            } catch (ContributionReadException e) {
                artifactURIs = null;
            }
            if (artifactURIs != null) {
                for (String artifactURI: artifactURIs) {
                    if (!artifactURI.endsWith(".composite")) {
                        continue;
                    }
                    URL artifactURL = scanner.getArtifactURL(contributionURL, artifactURI);
   
                    // Read each artifact
                    Object model = artifactProcessor.read(contributionURL, URI.create(artifactURI), artifactURL);
                    if (model instanceof Composite) {
                        contribution.getDeployables().add((Composite)model);
View Full Code Here

        ModelResolver modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories);
        contribution.setModelResolver(modelResolver);
        contribution.setUnresolved(true);

        // Create a contribution scanner
        ContributionScanner scanner;
        if ("file".equals(contributionURL.getProtocol()) && new File(contributionURL.getFile()).isDirectory()) {
            scanner = new DirectoryContributionScanner();
        } else {
            scanner = new JarContributionScanner();
        }
       
        // Scan the contribution and list the artifacts contained in it
        List<Artifact> artifacts = contribution.getArtifacts();
        boolean contributionMetadata = false;
        List<String> artifactURIs = scanner.getArtifacts(contributionURL);
        for (String artifactURI: artifactURIs) {
            URL artifactURL = scanner.getArtifactURL(contributionURL, artifactURI);

            // Add the deployed artifact model to the contribution
            Artifact artifact = this.contributionFactory.createArtifact();
            artifact.setURI(artifactURI);
            artifact.setLocation(artifactURL.toString());
View Full Code Here

        ModelResolver modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories);
        contribution.setModelResolver(modelResolver);
        contribution.setUnresolved(true);

        // Create a contribution scanner
        ContributionScanner scanner;
        if ("file".equals(contributionURL.getProtocol()) && new File(contributionURL.getFile()).isDirectory()) {
            scanner = new DirectoryContributionScanner();
        } else {
            scanner = new JarContributionScanner();
        }
       
        // Read generated and user sca-contribution.xml files
        boolean contributionMetadata = false;
        for (String path: new String[]{
                                       Contribution.SCA_CONTRIBUTION_GENERATED_META,
                                       Contribution.SCA_CONTRIBUTION_META}) {
            URL url = scanner.getArtifactURL(contributionURL, path);
            try {
                // Check if the file actually exists before trying to read it
                URLConnection connection = url.openConnection();
                connection.setUseCaches(false);
                InputStream is = connection.getInputStream();
                is.close();
            } catch (IOException e) {
                continue;
            }
            contributionMetadata = true;
           
            // Read the sca-contribution.xml file
            ContributionMetadata c = (ContributionMetadata)artifactProcessor.read(contributionURL, URI.create(path), url);
            contribution.getImports().addAll(c.getImports());
            contribution.getExports().addAll(c.getExports());
            contribution.getDeployables().addAll(c.getDeployables());
        }
       
        // If no sca-contribution.xml file was provided then consider
        // all composites in the contribution as deployables, and also
        // read any files that are explicitly asssigned artifact processors
        // as they are likely to provide relevant metadata info
        if (!contributionMetadata) {
            List<String> artifactURIs;
            try {
                artifactURIs = scanner.getArtifacts(contributionURL);
            } catch (ContributionReadException e) {
                artifactURIs = null;
            }
            if (artifactURIs != null) {
                for (String artifactURI: artifactURIs) {
                    boolean read = false;
                    if (artifactURI.endsWith(".composite")) {
                        read = true;
                    } else {
                        int s= artifactURI.lastIndexOf("/");
                        String fileName = artifactURI.substring(s + 1);
                        if (artifactProcessors.getProcessor(fileName) != null) {
                            read = true;
                        }
                    }
                    if (read) {
                        URL artifactURL = scanner.getArtifactURL(contributionURL, artifactURI);
       
                        // Read each artifact
                        Object model = artifactProcessor.read(contributionURL, URI.create(artifactURI), artifactURL);
                       
                        // In the absence of more info, consider all composites as deployable
View Full Code Here

        ModelResolver modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories);
        contribution.setModelResolver(modelResolver);
        contribution.setUnresolved(true);

        // Create a contribution scanner
        ContributionScanner scanner;
        if ("file".equals(contributionURL.getProtocol()) && new File(contributionURL.getFile()).isDirectory()) {
            scanner = new DirectoryContributionScanner();
        } else {
            scanner = new JarContributionScanner();
        }
       
        // Read generated and user sca-contribution.xml files
        boolean contributionMetadata = false;
        for (String path: new String[]{
                                       Contribution.SCA_CONTRIBUTION_GENERATED_META,
                                       Contribution.SCA_CONTRIBUTION_META}) {
            URL url = scanner.getArtifactURL(contributionURL, path);
            try {
                // Check if the file actually exists before trying to read it
                URLConnection connection = url.openConnection();
                connection.setUseCaches(false);
                InputStream is = connection.getInputStream();
                is.close();
            } catch (IOException e) {
                continue;
            }
            contributionMetadata = true;
           
            // Read the sca-contribution.xml file
            ContributionMetadata c = (ContributionMetadata)artifactProcessor.read(contributionURL, URI.create(path), url);
            contribution.getImports().addAll(c.getImports());
            contribution.getExports().addAll(c.getExports());
            contribution.getDeployables().addAll(c.getDeployables());
        }
       
        // If no sca-contribution.xml file was provided then consider
        // all composites in the contribution as deployables, and also
        // read any files that are explicitly asssigned artifact processors
        // as they are likely to provide relevant metadata info
        if (!contributionMetadata) {
            List<String> artifactURIs;
            try {
                artifactURIs = scanner.getArtifacts(contributionURL);
            } catch (ContributionReadException e) {
                artifactURIs = null;
            }
            if (artifactURIs != null) {
                for (String artifactURI: artifactURIs) {
                    boolean read = false;
                    if (artifactURI.endsWith(".composite")) {
                        read = true;
                    } else {
                        int s= artifactURI.lastIndexOf("/");
                        String fileName = artifactURI.substring(s + 1);
                        if (artifactProcessors.getProcessor(fileName) != null) {
                            read = true;
                        }
                    }
                    if (read) {
                        URL artifactURL = scanner.getArtifactURL(contributionURL, artifactURI);
       
                        // Read each artifact
                        Object model = artifactProcessor.read(contributionURL, URI.create(artifactURI), artifactURL);
                       
                        // In the absence of more info, consider all composites as deployable
View Full Code Here

        ModelResolver modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories);
        contribution.setModelResolver(modelResolver);
        contribution.setUnresolved(true);

        // Create a contribution scanner
        ContributionScanner scanner = scanners.getContributionScanner(contributionURL.getProtocol());
        if (scanner == null) {
            if ("file".equals(contributionURL.getProtocol()) && new File(contributionURL.getFile()).isDirectory()) {
                scanner = new DirectoryContributionScanner();
            } else {
                scanner = new JarContributionScanner();
            }
        }
       
        // Scan the contribution and list the artifacts contained in it
        List<Artifact> artifacts = contribution.getArtifacts();
        boolean contributionMetadata = false;
        List<String> artifactURIs = scanner.getArtifacts(contributionURL);
        for (String artifactURI: artifactURIs) {
            URL artifactURL = scanner.getArtifactURL(contributionURL, artifactURI);

            // Add the deployed artifact model to the contribution
            Artifact artifact = this.contributionFactory.createArtifact();
            artifact.setURI(artifactURI);
            artifact.setLocation(artifactURL.toString());
View Full Code Here

        monitor.pushContext("Contribution: " + contribution.getURI());

        Contribution old = context.setContribution(contribution);
        try {
            // Create a contribution scanner
            ContributionScanner scanner = scanners.getContributionScanner(contributionURL.getProtocol());
            if (scanner == null) {
                File file = toFile(contributionURL);
                if (file != null && file.isDirectory()) {
                    scanner = new DirectoryContributionScanner(contributionFactory);
                } else {
                    scanner = new JarContributionScanner(contributionFactory);
                }
            }
   
            // Scan the contribution and list the artifacts contained in it
            boolean contributionMetadata = false;
            List<Artifact> artifacts = scanner.scan(contribution);
            for (Artifact artifact : artifacts) {
                // Add the deployed artifact model to the contribution
                modelResolver.addModel(artifact, context);
               
                monitor.pushContext("Artifact: " + artifact.getURI());
View Full Code Here

        ModelResolver modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories);
        contribution.setModelResolver(modelResolver);
        contribution.setUnresolved(true);

        // Create a contribution scanner
        ContributionScanner scanner;
        if ("file".equals(contributionURL.getProtocol()) && new File(contributionURL.getFile()).isDirectory()) {
            scanner = new DirectoryContributionScanner();
        } else {
            scanner = new JarContributionScanner();
        }
       
        // Scan the contribution and list the artifacts contained in it
        List<Artifact> artifacts = contribution.getArtifacts();
        boolean contributionMetadata = false;
        for (String artifactURI: scanner.getArtifacts(contributionURL)) {
            URL artifactURL = scanner.getArtifactURL(contributionURL, artifactURI);

            // Add the deployed artifact model to the contribution
            Artifact artifact = this.contributionFactory.createArtifact();
            artifact.setURI(artifactURI);
            artifact.setLocation(artifactURL.toString());
View Full Code Here

        ModelResolver modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories);
        contribution.setModelResolver(modelResolver);
        contribution.setUnresolved(true);

        // Create a contribution scanner
        ContributionScanner scanner;
        if ("file".equals(contributionURL.getProtocol()) && new File(contributionURL.getFile()).isDirectory()) {
            scanner = new DirectoryContributionScanner();
        } else {
            scanner = new JarContributionScanner();
        }
       
        // Read generated and user sca-contribution.xml files
        boolean contributionMetadata = false;
        for (String path: new String[]{
                                       Contribution.SCA_CONTRIBUTION_GENERATED_META,
                                       Contribution.SCA_CONTRIBUTION_META}) {
            URL url = scanner.getArtifactURL(contributionURL, path);
            try {
                // Check if the file actually exists before trying to read it
                URLConnection connection = url.openConnection();
                connection.setUseCaches(false);
                InputStream is = connection.getInputStream();
                is.close();
            } catch (IOException e) {
                continue;
            }
            contributionMetadata = true;
           
            // Read the sca-contribution.xml file
            Contribution c = (Contribution)artifactProcessor.read(contributionURL, URI.create(path), url);
            contribution.getImports().addAll(c.getImports());
            contribution.getExports().addAll(c.getExports());
            contribution.getDeployables().addAll(c.getDeployables());
        }
       
        // If no sca-contribution.xml file was provided then just consider
        // all composites in the contribution as deployables
        if (!contributionMetadata) {
            List<String> artifactURIs;
            try {
                artifactURIs = scanner.getArtifacts(contributionURL);
            } catch (ContributionReadException e) {
                artifactURIs = null;
            }
            if (artifactURIs != null) {
                for (String artifactURI: artifactURIs) {
                    if (!artifactURI.endsWith(".composite")) {
                        continue;
                    }
                    URL artifactURL = scanner.getArtifactURL(contributionURL, artifactURI);
   
                    // Read each artifact
                    Object model = artifactProcessor.read(contributionURL, URI.create(artifactURI), artifactURL);
                    if (model instanceof Composite) {
                        contribution.getDeployables().add((Composite)model);
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.contribution.scanner.ContributionScanner

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.