make diagnostics engine usable outside of webconsole (TODO, split in separate bundles)

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1504410 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole-plugins/servicediagnostics/core/pom.xml b/webconsole-plugins/servicediagnostics/core/pom.xml
index f4c3c3f..902c7de 100644
--- a/webconsole-plugins/servicediagnostics/core/pom.xml
+++ b/webconsole-plugins/servicediagnostics/core/pom.xml
@@ -74,7 +74,8 @@
               org.apache.felix.servicediagnostics;version=0.1
             </Export-Package>
             <Import-Package>
-              sun.misc*;resolution:=optional, *
+            <!-- make imports on webconsole optional, so that core diagnostics engine can be used independently -->
+              *;resolution:=optional
             </Import-Package>
             <Private-Package>
               org.apache.felix.servicediagnostics.impl,
diff --git a/webconsole-plugins/servicediagnostics/core/src/main/scala/servicediagnostics/impl/Activator.scala b/webconsole-plugins/servicediagnostics/core/src/main/scala/servicediagnostics/impl/Activator.scala
index 4410280..88cb00e 100644
--- a/webconsole-plugins/servicediagnostics/core/src/main/scala/servicediagnostics/impl/Activator.scala
+++ b/webconsole-plugins/servicediagnostics/core/src/main/scala/servicediagnostics/impl/Activator.scala
@@ -63,28 +63,42 @@
                 .setCallbacks("addPlugin", null, null)
                 .setRequired(false)))
 
-        // register the webconsole plugin 
-        dm.add(createComponent
-            .setInterface(classOf[javax.servlet.Servlet].getName, new jHT[String,String]() {{
-                  put("felix.webconsole.label", "servicegraph")
-              }})
-            .setImplementation(classOf[WebConsolePlugin])
-            .add(createServiceDependency
-                .setService(classOf[ServiceDiagnostics])
-                .setRequired(true)
-                .setAutoConfig("engine")))
+        try // if the engine is used alone, the webconsole may just not be there 
+        { 
+            // register the webconsole plugin 
+            dm.add(createComponent
+                .setInterface(classOf[javax.servlet.Servlet].getName, new jHT[String,String]() {{
+                      put("felix.webconsole.label", "servicegraph")
+                  }})
+                .setImplementation(classOf[WebConsolePlugin])
+                .add(createServiceDependency
+                    .setService(classOf[ServiceDiagnostics])
+                    .setRequired(true)
+                    .setAutoConfig("engine")))
+        }
+        catch 
+        {
+            case t:Throwable => println("failed to register the servicediagnostics webconsole plugin")
+        }
 
-        // register the shell command
-        dm.add(createComponent
-            .setInterface(classOf[Command].getName, new jHT[String,Any]() {{
-                  put(CommandProcessor.COMMAND_FUNCTION, CLI.usage.split("|"))
-                  put(CommandProcessor.COMMAND_SCOPE, CLI.scope)
-              }})
-            .setImplementation(classOf[CLI])
-            .add(createServiceDependency
-                .setService(classOf[ServiceDiagnostics])
-                .setRequired(true)
-                .setAutoConfig("engine")))
+        try // if the engine is used alone, the shell may just not be there 
+        { 
+            // register the shell command
+            dm.add(createComponent
+                .setInterface(classOf[Command].getName, new jHT[String,Any]() {{
+                      put(CommandProcessor.COMMAND_FUNCTION, CLI.usage.split("|"))
+                      put(CommandProcessor.COMMAND_SCOPE, CLI.scope)
+                  }})
+                .setImplementation(classOf[CLI])
+                .add(createServiceDependency
+                    .setService(classOf[ServiceDiagnostics])
+                    .setRequired(true)
+                    .setAutoConfig("engine")))
+        }
+        catch 
+        {
+            case t:Throwable => println("failed to register the servicediagnostics shell plugin")
+        }
     }
 
     override def destroy(bc:BundleContext, dm:DependencyManager) = {}