Package com.sun.enterprise.tools.verifier.hk2

Examples of com.sun.enterprise.tools.verifier.hk2.PackageAnalyser$Bundle


                if (!location.exists()) {
                    throw new MojoExecutionException(location + " does not exist, so can't execute. Package the artifact first.");
                }
            }
            ModuleDefinition moduleDef = new MavenModuleDefinition(repo, location);
            ModuleDependencyAnalyser analyser = new ModuleDependencyAnalyser(moduleDef, repo);
            if (excludedPatterns!=null) {
                analyser.excludePatterns(excludedPatterns);
            }
            if (!analyser.analyse()) {
                String msg = "Missing dependency. See details below:\n" + analyser.getResultAsString();
                if (failOnVerificationError) {
                    throw new MojoExecutionException(msg);
                } else {
                    logger.logp(Level.WARNING, "DependencyAnalyserMojo", "execute", msg);
                }
View Full Code Here


        try {
            HK2Factory.initialize();
            MavenProjectRepository repo = new MavenProjectRepository(
                    project, artifactResolver, localRepository, artifactFactory);
            repo.initialize();
            PackageAnalyser analyser = new PackageAnalyser(repo, logger);
            Collection<PackageAnalyser.Wire> wires = analyser.analyseWirings();
            StringBuilder sb = new StringBuilder("Wiring details are given below:\n");
            for (PackageAnalyser.Wire w : wires) {
                sb.append(w + "\n");
            }
            sb.append("Total number of wires = " + wires.size() + "\n");
            sb.append("Split-Package details are given below:\n");
            Collection<PackageAnalyser.SplitPackage> splitPkgs = analyser.findDuplicatePackages();
            for (PackageAnalyser.SplitPackage p : splitPkgs) sb.append(p+"\n");
            sb.append("Total number of Split Packages = " + splitPkgs.size() + "\n");

            int totalUnusedPkgs = 0;
            for (PackageAnalyser.Bundle b : analyser.bundles) {
                Collection<PackageAnalyser.PackageCapability> unusedPackages = analyser.findUnusedExports(b);
                if (!unusedPackages.isEmpty()) {
                    sb.append("<Bundle name=" + b.getName()+", totalUnusedPkgs = " + unusedPackages.size() + "> \n" );
                    for (PackageAnalyser.PackageCapability p : unusedPackages) sb.append("\t" + p + "\n");
                    sb.append("</Bundle>\n");
                }
                totalUnusedPkgs += unusedPackages.size();
            }
            sb.append("Total number of Unused Packages = " + totalUnusedPkgs);

            sb.append("******** GROSS STATISTICS *********\n");
            sb.append("Total number of bundles in this repository: " + analyser.findAllBundles().size()+"\n");
            sb.append("Total number of wires = " + wires.size() + "\n");
            Collection<String> exportedPkgs = analyser.findAllExportedPackageNames();
            sb.append("Total number of exported packages = " + exportedPkgs.size() + "\n");
            sb.append("Total number of split-packages = " + splitPkgs.size()+"\n");
            sb.append("Total number of unused-packages = " + totalUnusedPkgs +"\n");

            logger.logp(Level.INFO, "PackageAnalyserMojo", "execute", "{0}", new Object[]{sb});
            String reportFilePath =
                    System.getProperty("WiringReportPath",
                            System.getProperty("java.io.tmpdir")+ File.separator + "wires.xml");
            analyser.generateWiringReport(exportedPkgs, wires, new PrintStream(new FileOutputStream(new File(reportFilePath))));
            System.out.println("Wiring reported can be found at " + reportFilePath);
        } catch (IOException e) {
            throw new MojoExecutionException("Unexpected exception", e);
        }
    }
View Full Code Here

    public List<Bundle> toBundleList() {
        ArrayList<Bundle> bundleList = new ArrayList<Bundle>();

        if (bundles == null) {
            Bundle bnd = new Bundle();
            bnd.setArtifactId(artifactId);
            bnd.setGroupId(groupId);
            bnd.setVersion(version);
            if (type != null) {
                bnd.setType(type);
            }
            bnd.setClassifier(classifier);
            bnd.setStartLevel(startLevel);
            bundleList.add(bnd);
        } else {
            for (ArtifactDefinition bundle : bundles) {
                bundleList.addAll(bundle.toBundleList());
            }
View Full Code Here

    public abstract List<StartLevel> getStartLevels();

    public Bundle get(Bundle bundle, boolean compareVersions) {
        for (StartLevel sl : getStartLevels()) {
            Bundle foundBundle = sl.getBundle(bundle, compareVersions);
            if (foundBundle != null) {
                return foundBundle;
            }
        }
        return null;
View Full Code Here

     * Merge bundle into a start level using the supplied level if present.
     * @param mergeStartLevel
     * @param newBnd
     */
    private void add(StartLevel mergeStartLevel, Bundle newBnd) {
        Bundle current = get(newBnd, false);
        if (current != null) {
            final Maven2OsgiConverter converter = new DefaultMaven2OsgiConverter();

            // compare versions, the highest will be used
            final Version newVersion = new Version(converter.getVersion(newBnd.getVersion()));
            final Version oldVersion = new Version(converter.getVersion(current.getVersion()));
            if ( newVersion.compareTo(oldVersion) > 0 ) {
                current.setVersion(newBnd.getVersion());
            }
        } else {
            StartLevel startLevel = null;
            if ( mergeStartLevel == null || newBnd.getStartLevel() != 0) {
                startLevel = getOrCreateStartLevel(newBnd.getStartLevel());
View Full Code Here

TOP

Related Classes of com.sun.enterprise.tools.verifier.hk2.PackageAnalyser$Bundle

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.