incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1221163 - in /sling/trunk/bundles/extensions/threaddump: pom.xml src/main/java/org/apache/sling/extensions/threaddump/internal/Activator.java
Date Tue, 20 Dec 2011 09:31:11 GMT
Author: cziegeler
Date: Tue Dec 20 09:31:11 2011
New Revision: 1221163

URL: http://svn.apache.org/viewvc?rev=1221163&view=rev
Log:
SLING-2334 : Register shell command through service factory

Modified:
    sling/trunk/bundles/extensions/threaddump/pom.xml
    sling/trunk/bundles/extensions/threaddump/src/main/java/org/apache/sling/extensions/threaddump/internal/Activator.java

Modified: sling/trunk/bundles/extensions/threaddump/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/threaddump/pom.xml?rev=1221163&r1=1221162&r2=1221163&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/threaddump/pom.xml (original)
+++ sling/trunk/bundles/extensions/threaddump/pom.xml Tue Dec 20 09:31:11 2011
@@ -57,10 +57,9 @@
                 <extensions>true</extensions>
                 <configuration>
                     <instructions>
-                        <Import-Package>
-                            org.apache.felix.shell;resolution:=optional,
-                            *
-                        </Import-Package>
+                        <DynamicImport-Package>
+                            org.apache.felix.shell;version="[1.0,2)"
+                        </DynamicImport-Package>
                         <Private-Package>
                             org.apache.sling.extensions.threaddump.*
                         </Private-Package>

Modified: sling/trunk/bundles/extensions/threaddump/src/main/java/org/apache/sling/extensions/threaddump/internal/Activator.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/threaddump/src/main/java/org/apache/sling/extensions/threaddump/internal/Activator.java?rev=1221163&r1=1221162&r2=1221163&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/threaddump/src/main/java/org/apache/sling/extensions/threaddump/internal/Activator.java
(original)
+++ sling/trunk/bundles/extensions/threaddump/src/main/java/org/apache/sling/extensions/threaddump/internal/Activator.java
Tue Dec 20 09:31:11 2011
@@ -22,9 +22,12 @@ import java.lang.Thread.UncaughtExceptio
 import java.util.Dictionary;
 import java.util.Hashtable;
 
+import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceRegistration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -42,13 +45,21 @@ public class Activator implements Bundle
         Thread.setDefaultUncaughtExceptionHandler(this);
 
         // install thread handler shell command
-        try {
-            register(bundleContext,
-                new String[] { "org.apache.felix.shell.Command" },
-                new ThreadDumpCommand(), null);
-        } catch (Throwable t) {
-            // shell service might not be available, don't care
-        }
+        register(bundleContext,
+            new String[] { "org.apache.felix.shell.Command" },
+            new ServiceFactory() {
+
+                public void ungetService(final Bundle bundle,
+                    final ServiceRegistration reg,
+                    final Object consoleObject) {
+                    // nothing to do
+                }
+
+                public Object getService(final Bundle bundle,
+                    final ServiceRegistration reg) {
+                     return new ThreadDumpCommand();
+                }
+            }, null);
 
         // install Web Console configuration printer
         final Dictionary<String, Object> props = new Hashtable<String, Object>();
@@ -59,7 +70,7 @@ public class Activator implements Bundle
         final ThreadDumperPanel tdp = new ThreadDumperPanel();
 
         register(bundleContext, new String[] {
-            "org.apache.felix.webconsole.ConfigurationPrinter" }, tdp, props);
+            tdp.getClass().getName() }, tdp, props);
     }
 
     public void stop(BundleContext bundleContext) {



Mime
View raw message