Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.virgo.kernel.artifact/.classpath4
-rwxr-xr-xorg.eclipse.virgo.shell.command/src/main/java/org/eclipse/virgo/shell/osgicommand/Activator.java58
2 files changed, 15 insertions, 47 deletions
diff --git a/org.eclipse.virgo.kernel.artifact/.classpath b/org.eclipse.virgo.kernel.artifact/.classpath
index ec8f1bbf..3f18dc22 100644
--- a/org.eclipse.virgo.kernel.artifact/.classpath
+++ b/org.eclipse.virgo.kernel.artifact/.classpath
@@ -23,10 +23,10 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var" path="IVY_CACHE/org.junit/com.springsource.org.junit/4.7.0/com.springsource.org.junit-4.7.0.jar" sourcepath="/IVY_CACHE/org.junit/com.springsource.org.junit/4.7.0/com.springsource.org.junit-sources-4.7.0.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.repository/org.eclipse.virgo.repository/3.6.0.M05/org.eclipse.virgo.repository-3.6.0.M05.jar" sourcepath="/IVY_CACHE/org.eclipse.virgo.repository/org.eclipse.virgo.repository/3.5.0.D-20120615071313/org.eclipse.virgo.repository-sources-3.5.0.D-20120615071313.jar"/>
- <classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.io/3.6.0.M05/org.eclipse.virgo.util.io-3.6.0.M05.jar" sourcepath="/IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.io/3.6.0.D-20120711093140/org.eclipse.virgo.util.io-sources-3.6.0.D-20120711093140.jar"/>
+ <classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.io/3.6.0.M05/org.eclipse.virgo.util.io-3.6.0.M05.jar" sourcepath="/IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.io/3.6.0.M05/org.eclipse.virgo.util.io-sources-3.6.0.M05.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.osgi.manifest/3.6.0.M05/org.eclipse.virgo.util.osgi.manifest-3.6.0.M05.jar" sourcepath="/IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.osgi.manifest/3.5.0.D-20120615065828/org.eclipse.virgo.util.osgi.manifest-sources-3.5.0.D-20120615065828.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.parser.manifest/3.6.0.M05/org.eclipse.virgo.util.parser.manifest-3.6.0.M05.jar" sourcepath="/IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.parser.manifest/3.5.0.D-20120615065828/org.eclipse.virgo.util.parser.manifest-sources-3.5.0.D-20120615065828.jar"/>
- <classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.common/3.6.0.M05/org.eclipse.virgo.util.common-3.6.0.M05.jar" sourcepath="/IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.common/3.5.0.D-20120615065828/org.eclipse.virgo.util.common-sources-2.0019103807.jar"/>
+ <classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.common/3.6.0.M05/org.eclipse.virgo.util.common-3.6.0.M05.jar" sourcepath="/IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.common/3.6.0.M05/org.eclipse.virgo.util.common-sources-3.6.0.M05.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.mirrored/org.slf4j.api/1.7.2.v20121108-1250/org.slf4j.api-1.7.2.v20121108-1250.jar" sourcepath="/IVY_CACHE/org.eclipse.virgo.mirrored/org.slf4j.api/1.7.2.v20121108-1250/org.slf4j.api.source-1.7.2.v20121108-1250.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.mirrored/org.slf4j.nop/1.7.2.v201212060727/org.slf4j.nop-1.7.2.v201212060727.jar" sourcepath="/IVY_CACHE/org.eclipse.virgo.mirrored/org.slf4j.nop/1.7.2.v201212060727/org.slf4j.nop.source-1.7.2.v201212060727.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.mirrored/org.eclipse.osgi/3.8.1.v20120830-144521/org.eclipse.osgi-3.8.1.v20120830-144521.jar" sourcepath="/IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi/3.7.1.R37x_v20110808-1106/org.eclipse.osgi-sources-3.7.1.R37x_v20110808-1106.jar"/>
diff --git a/org.eclipse.virgo.shell.command/src/main/java/org/eclipse/virgo/shell/osgicommand/Activator.java b/org.eclipse.virgo.shell.command/src/main/java/org/eclipse/virgo/shell/osgicommand/Activator.java
index 43df9cea..799ba511 100755
--- a/org.eclipse.virgo.shell.command/src/main/java/org/eclipse/virgo/shell/osgicommand/Activator.java
+++ b/org.eclipse.virgo.shell.command/src/main/java/org/eclipse/virgo/shell/osgicommand/Activator.java
@@ -16,13 +16,14 @@ package org.eclipse.virgo.shell.osgicommand;
import java.lang.management.ManagementFactory;
import java.util.Dictionary;
import java.util.Hashtable;
+import java.util.concurrent.TimeoutException;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
-import org.eclipse.virgo.kernel.osgi.framework.OsgiFrameworkUtils;
-import org.eclipse.virgo.kernel.osgi.framework.OsgiServiceHolder;
+import org.eclipse.virgo.kernel.osgi.framework.ServiceUtils;
+
import org.eclipse.virgo.shell.CommandExecutor;
import org.eclipse.virgo.shell.osgicommand.internal.GogoClassLoadingCommand;
import org.eclipse.virgo.shell.osgicommand.internal.GogoKernelShellCommand;
@@ -42,15 +43,10 @@ public class Activator implements BundleActivator {
private static final String KERNEL_SHELL_COMMAND = "vsh";
- private static final String[] KERNEL_SHELL_SUBCOMMANDS = new String[] { "bundle", "config", "install", "packages", "par", "plan", "service",
- "shutdown" };
+ private static final String[] KERNEL_SHELL_SUBCOMMANDS = new String[] { "bundle", "config", "install", "packages", "par", "plan", "service", "shutdown" };
private static final String[] CLASS_LOADING_SUBCOMMANDS = new String[] { "clhas", "clload", "clexport" };
- private static final int COMMAND_EXECUTOR_SERVICE_WAIT = 20 * 1000; // 20 seconds
-
- private static final int SERVICE_WAIT_PAUSE = 100; // 100 milliseconds
-
private final ServiceRegistrationTracker registrationTracker = new ServiceRegistrationTracker();
private final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
@@ -93,40 +89,6 @@ public class Activator implements BundleActivator {
this.server.unregisterMBean(this.classLoadingObjectName);
}
- /**
- * Get a service which might not be immediately available
- *
- * @param <T> type of service to get
- * @param context in which to search for service
- * @param serviceClass of service to locate
- * @param millis maximum time to delay in milliseconds
- * @return null if timeout before getting service, otherwise service
- */
- private static <T> T getPotentiallyDelayedService(BundleContext context, Class<T> serviceClass, long millis) {
- T service = null;
-
- while (service == null) {
- try {
- OsgiServiceHolder<T> serviceHolder = OsgiFrameworkUtils.getService(context, serviceClass);
- if (serviceHolder != null) {
- service = serviceHolder.getService();
- }
- } catch (IllegalStateException e) {
- try {
- millis -= SERVICE_WAIT_PAUSE;
- if (millis > 0) {
- Thread.sleep(SERVICE_WAIT_PAUSE);
- } else {
- return null;
- }
- } catch (InterruptedException ie) {
- }
- }
- }
-
- return service;
- }
-
private static final class PostStartInitialisationRunnable implements Runnable {
private final BundleContext context;
@@ -143,7 +105,14 @@ public class Activator implements BundleActivator {
*/
@Override
public void run() {
- CommandExecutor commandExecutor = getPotentiallyDelayedService(this.context, CommandExecutor.class, COMMAND_EXECUTOR_SERVICE_WAIT);
+ CommandExecutor commandExecutor = null;
+ try {
+ commandExecutor = ServiceUtils.getPotentiallyDelayedService(this.context, CommandExecutor.class);
+ } catch (TimeoutException e) {
+ // no-op
+ } catch (InterruptedException e) {
+ // no-op
+ }
if (commandExecutor == null) {
return; // TODO: report this failure -- but where?
}
@@ -152,8 +121,7 @@ public class Activator implements BundleActivator {
Dictionary<String, Object> properties = new Hashtable<String, Object>();
properties.put(org.apache.felix.service.command.CommandProcessor.COMMAND_SCOPE, KERNEL_SHELL_COMMAND);
properties.put(org.apache.felix.service.command.CommandProcessor.COMMAND_FUNCTION, KERNEL_SHELL_SUBCOMMANDS);
- this.registrationTracker.track(context.registerService(GogoKernelShellCommand.class, new GogoKernelShellCommand(commandExecutor),
- properties));
+ this.registrationTracker.track(context.registerService(GogoKernelShellCommand.class, new GogoKernelShellCommand(commandExecutor), properties));
}
}
}

Back to the top