Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2011-10-03 13:56:58 +0000
committerThomas Watson2011-10-03 13:56:58 +0000
commit65bf03fd1534709f0409805929fc34041c2683f9 (patch)
treedbb936e2bbad2f1d5963b791725270eca33fc4b0
parentb7a97f38568ef2e44dd757a5e99135811f65e2f2 (diff)
downloadrt.equinox.framework-65bf03fd1534709f0409805929fc34041c2683f9.tar.gz
rt.equinox.framework-65bf03fd1534709f0409805929fc34041c2683f9.tar.xz
rt.equinox.framework-65bf03fd1534709f0409805929fc34041c2683f9.zip
Bug 359709 - enhance osgi.console.enable.builtin to specify the consolev20111003-1644
bundle and activate it.
-rw-r--r--bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/ConsoleManager.java49
-rw-r--r--bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java10
2 files changed, 46 insertions, 13 deletions
diff --git a/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/ConsoleManager.java b/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/ConsoleManager.java
index 815e138b5..6efd58ef0 100644
--- a/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/ConsoleManager.java
+++ b/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/ConsoleManager.java
@@ -18,8 +18,7 @@ import java.util.Hashtable;
import org.eclipse.osgi.framework.console.CommandProvider;
import org.eclipse.osgi.framework.console.ConsoleSession;
import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.*;
import org.osgi.util.tracker.ServiceTracker;
import org.osgi.util.tracker.ServiceTrackerCustomizer;
@@ -86,8 +85,9 @@ public class ConsoleManager implements ServiceTrackerCustomizer<ConsoleSession,
public static final String PROP_CONSOLE = "osgi.console"; //$NON-NLS-1$
private static final String PROP_SYSTEM_IN_OUT = "console.systemInOut"; //$NON-NLS-1$
private static final String CONSOLE_NAME = "OSGi Console"; //$NON-NLS-1$
- private static final String PROP_CONSOLE_ENABLED = "osgi.console.enable.builtin"; //$NON-NLS-1$
- private final Framework framework;
+ private static final String CONSOLE_BUNDLE = "org.eclipse.equinox.console.supportability"; //$NON-NLS-1$
+ public static final String PROP_CONSOLE_ENABLED = "osgi.console.enable.builtin"; //$NON-NLS-1$
+ final Framework framework;
private final ServiceTracker<CommandProvider, CommandProvider> cpTracker;
private final ServiceTracker<ConsoleSession, FrameworkConsole> sessions;
private final String consolePort;
@@ -98,6 +98,7 @@ public class ConsoleManager implements ServiceTrackerCustomizer<ConsoleSession,
private ServiceRegistration<?> builtinSession;
private ConsoleSocketGetter socketGetter;
private final boolean isEnabled;
+ private final String consoleBundle;
public ConsoleManager(Framework framework, String consolePropValue) {
String port = null;
@@ -109,22 +110,21 @@ public class ConsoleManager implements ServiceTrackerCustomizer<ConsoleSession,
}
port = consolePropValue.substring(index + 1);
}
-
- if ("false".equals(FrameworkProperties.getProperty(PROP_CONSOLE_ENABLED)) || "none".equals(port)) { //$NON-NLS-1$ //$NON-NLS-2$
+ this.framework = framework;
+ this.consoleHost = host != null ? host.trim() : host;
+ this.consolePort = port != null ? port.trim() : port;
+ String enabled = FrameworkProperties.getProperty(PROP_CONSOLE_ENABLED, "true"); //$NON-NLS-1$
+ if (!"true".equals(enabled) || "none".equals(port)) { //$NON-NLS-1$ //$NON-NLS-2$
isEnabled = false;
- this.framework = null;
this.cpTracker = null;
this.sessions = null;
- this.consoleHost = null;
- this.consolePort = null;
+ this.consoleBundle = "false".equals(enabled) ? CONSOLE_BUNDLE : enabled; //$NON-NLS-1$
return;
}
this.isEnabled = true;
- this.framework = framework;
- this.consoleHost = host != null ? host.trim() : host;
- this.consolePort = port != null ? port.trim() : port;
this.cpTracker = new ServiceTracker<CommandProvider, CommandProvider>(framework.getSystemBundleContext(), CommandProvider.class.getName(), null);
this.sessions = new ServiceTracker<ConsoleSession, FrameworkConsole>(framework.getSystemBundleContext(), ConsoleSession.class.getName(), this);
+ this.consoleBundle = "unknown"; //$NON-NLS-1$
}
public static ConsoleManager startConsole(Framework framework) {
@@ -191,6 +191,31 @@ public class ConsoleManager implements ServiceTrackerCustomizer<ConsoleSession,
}
}
+ public void checkForConsoleBundle() throws BundleException {
+ if (isEnabled)
+ return;
+ if ("none".equals(consolePort)) //$NON-NLS-1$
+ return;
+ // otherwise we need to check for the equinox console bundle and start it
+ if (consolePort == null || consolePort.length() > 0) {
+ // no -console was specified or it has specified none or a port for telnet;
+ // need to make sure the gogo shell does not create an interactive console on standard in/out
+ FrameworkProperties.setProperty("gosh.args", "--nointeractive"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ Bundle[] consoles = framework.getBundleBySymbolicName(consoleBundle);
+ if (consoles == null || consoles.length == 0) {
+ if (consolePort != null)
+ throw new BundleException("Could not find bundle: " + consoleBundle, BundleException.UNSUPPORTED_OPERATION); //$NON-NLS-1$
+ return;
+ }
+ try {
+ consoles[0].start(Bundle.START_TRANSIENT);
+ } catch (BundleException e) {
+ throw new BundleException("Could not start bundle: " + consoleBundle, BundleException.UNSUPPORTED_OPERATION, e); //$NON-NLS-1$
+ }
+ }
+
/**
* Stops the OSGi Command console
*
diff --git a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java
index ec2dcc0e5..f250acfd0 100644
--- a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java
+++ b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java
@@ -267,7 +267,7 @@ public class EclipseStarter {
if (Profile.PROFILE && Profile.STARTUP)
Profile.logTime("EclipseStarter.startup()", "osgi launched"); //$NON-NLS-1$ //$NON-NLS-2$
consoleMgr = ConsoleManager.startConsole(framework);
- if (consoleMgr != null && Profile.PROFILE && Profile.STARTUP) {
+ if (Profile.PROFILE && Profile.STARTUP) {
Profile.logTime("EclipseStarter.startup()", "console started"); //$NON-NLS-1$ //$NON-NLS-2$
}
framework.launch();
@@ -290,6 +290,14 @@ public class EclipseStarter {
Profile.logTime("EclipseStarter.startup()", "StartLevel set"); //$NON-NLS-1$ //$NON-NLS-2$
// they should all be active by this time
ensureBundlesActive(startBundles);
+
+ // in the case where the built-in console is disabled we should try to start the console bundle
+ try {
+ consoleMgr.checkForConsoleBundle();
+ } catch (BundleException e) {
+ FrameworkLogEntry entry = new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, FrameworkLogEntry.ERROR, 0, e.getMessage(), 0, e, null);
+ log.log(entry);
+ }
if (debug || FrameworkProperties.getProperty(PROP_DEV) != null)
// only spend time showing unresolved bundles in dev/debug mode and the state has changed
if (stateStamp != adaptor.getState().getTimeStamp())

Back to the top