geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r880591 - /geronimo/server/trunk/framework/buildsupport/geronimo-osgi-plugin/src/main/java/org/apache/geronimo/mavenplugins/osgi/DisplayManifestMojo.java
Date Mon, 16 Nov 2009 05:34:24 GMT
Author: gawor
Date: Mon Nov 16 05:34:24 2009
New Revision: 880591

URL: http://svn.apache.org/viewvc?rev=880591&view=rev
Log:
display more info about imports and exports

Modified:
    geronimo/server/trunk/framework/buildsupport/geronimo-osgi-plugin/src/main/java/org/apache/geronimo/mavenplugins/osgi/DisplayManifestMojo.java

Modified: geronimo/server/trunk/framework/buildsupport/geronimo-osgi-plugin/src/main/java/org/apache/geronimo/mavenplugins/osgi/DisplayManifestMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/buildsupport/geronimo-osgi-plugin/src/main/java/org/apache/geronimo/mavenplugins/osgi/DisplayManifestMojo.java?rev=880591&r1=880590&r2=880591&view=diff
==============================================================================
--- geronimo/server/trunk/framework/buildsupport/geronimo-osgi-plugin/src/main/java/org/apache/geronimo/mavenplugins/osgi/DisplayManifestMojo.java
(original)
+++ geronimo/server/trunk/framework/buildsupport/geronimo-osgi-plugin/src/main/java/org/apache/geronimo/mavenplugins/osgi/DisplayManifestMojo.java
Mon Nov 16 05:34:24 2009
@@ -20,6 +20,9 @@
 package org.apache.geronimo.mavenplugins.osgi;
 
 import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 
 import org.apache.geronimo.mavenplugins.osgi.utils.BundleResolver;
 import org.apache.maven.plugin.Mojo;
@@ -38,6 +41,8 @@
  * @goal display-manifest
  */
 public class DisplayManifestMojo extends AbstractLogEnabled implements Mojo {
+    
+    private final String TAB = "  ";
 
     private Log log;
 
@@ -80,23 +85,52 @@
 
     private void displayImportExports(BundleDescription b) {
         System.out.println("Bundle: " + b.getSymbolicName());
-        System.out.println();
-        System.out.println("Imports:");
-        ImportPackageSpecification[] importPackages = b.getImportPackages();
-        if (importPackages != null) {
-            for (ImportPackageSpecification importPackage : importPackages) {
-                System.out.println(importPackage);
-            }
-        }
+        displayImports(b, ImportPackageSpecification.RESOLUTION_STATIC, "Imports:");
+        displayImports(b, ImportPackageSpecification.RESOLUTION_OPTIONAL, "Optional Imports:");
+        displayImports(b, ImportPackageSpecification.RESOLUTION_DYNAMIC, "Dynamic Imports:");
                     
-        System.out.println();       
-        System.out.println("Exports:");
+        displayExports(b);
+    }
+    
+    
+    private void displayExports(BundleDescription b) {
         ExportPackageDescription[] exportPackages = b.getExportPackages();
-        if (exportPackages != null) {
+        if (exportPackages != null && exportPackages.length > 0) {
+            System.out.println("Exports:");
             for (ExportPackageDescription exportPackage : exportPackages) {
-                System.out.println(exportPackage);
+                System.out.println(TAB + exportPackage); 
+                String [] list = (String[])exportPackage.getDirective("uses");
+                if (list != null) {
+                    System.out.println(TAB + TAB + "Uses: " + Arrays.asList(list));
+                }
+            }
+            System.out.println();
+        }
+    }
+    
+    private void displayImports(BundleDescription b, String resolution, String header) {
+        List<ImportPackageSpecification> imports = getImports(b, resolution);     
  
+        if (!imports.isEmpty()) {
+            System.out.println(header);
+            for (ImportPackageSpecification importPackage : imports) {
+                System.out.println(TAB + importPackage);
+            }
+            System.out.println();
+        }
+    }
+    
+    private List<ImportPackageSpecification> getImports(BundleDescription b, String
resolution) {
+        List<ImportPackageSpecification> imports = new ArrayList<ImportPackageSpecification>();
      
+        ImportPackageSpecification[] importPackages = b.getImportPackages();
+        if (importPackages != null) {
+            for (ImportPackageSpecification importPackage : importPackages) {
+                String res = (String) importPackage.getDirective("resolution");
+                if (resolution.equals(res)) {
+                    imports.add(importPackage);
+                }
             }
         }
+        return imports;
     }
     
     public void setLog(Log log) {



Mime
View raw message