Improvements for new shell commands. (FELIX-1006, FELIX-1009)


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@760200 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java b/framework/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java
index 02cd2f7..30b0d0e 100644
--- a/framework/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java
@@ -30,8 +30,8 @@
     private final BundleImpl m_exportingBundle;
     private final IModule m_exportingModule;
     private final Capability m_export;
-    private String m_toString = null;
-    private String m_versionString = null;
+    private volatile String m_toString = null;
+    private volatile String m_versionString = null;
 
     public ExportedPackageImpl(
         Felix felix, BundleImpl exporter, IModule module, Capability export)
diff --git a/framework/src/main/java/org/apache/felix/framework/RequiredBundleImpl.java b/framework/src/main/java/org/apache/felix/framework/RequiredBundleImpl.java
index 970b0ef..8b77274 100644
--- a/framework/src/main/java/org/apache/felix/framework/RequiredBundleImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/RequiredBundleImpl.java
@@ -35,6 +35,8 @@
 {
     private final Felix m_felix;
     private final BundleImpl m_bundle;
+    private volatile String m_toString = null;
+    private volatile String m_versionString = null;
 
     public RequiredBundleImpl(Felix felix, BundleImpl bundle)
     {
@@ -91,18 +93,21 @@
 
     public Version getVersion()
     {
-        ICapability[] caps = 
-            Util.getCapabilityByNamespace(
-                m_bundle.getCurrentModule(), ICapability.MODULE_NAMESPACE);
-        if ((caps != null) && (caps.length > 0))
-        {
-            return (Version) caps[0].getProperties().get(Constants.BUNDLE_VERSION_ATTRIBUTE);
-        }
-        return null;
+        return m_bundle.getCurrentModule().getVersion();
     }
 
     public boolean isRemovalPending()
     {
         return m_bundle.isRemovalPending();
     }
+
+    public String toString()
+    {
+        if (m_toString == null)
+        {
+            m_toString = m_bundle.getSymbolicName()
+                + "; version=" + m_bundle.getCurrentModule().getVersion();
+        }
+        return m_toString;
+    }
 }
\ No newline at end of file