Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2012-09-04 18:17:00 +0000
committerThomas Watson2012-09-04 18:17:00 +0000
commit13742e7928e4c146b6b75e97e724ec71d48c332a (patch)
treee85fe5f374f1037246823ef15db76d8a4fad5e63 /bundles/org.eclipse.osgi/container/src/org/eclipse/core
parent714a06e8335c7a6842fa96df6a063d2b6ceef5cd (diff)
downloadrt.equinox.framework-13742e7928e4c146b6b75e97e724ec71d48c332a.tar.gz
rt.equinox.framework-13742e7928e4c146b6b75e97e724ec71d48c332a.tar.xz
rt.equinox.framework-13742e7928e4c146b6b75e97e724ec71d48c332a.zip
Move ConsoleManager
Diffstat (limited to 'bundles/org.eclipse.osgi/container/src/org/eclipse/core')
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java1
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/internal/adaptor/ConsoleManager.java87
2 files changed, 87 insertions, 1 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java
index 481a53e33..f66a38285 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java
@@ -19,7 +19,6 @@ import java.security.ProtectionDomain;
import java.util.*;
import org.eclipse.core.runtime.internal.adaptor.*;
import org.eclipse.osgi.container.namespaces.EquinoxModuleDataNamespace;
-import org.eclipse.osgi.framework.internal.core.ConsoleManager;
import org.eclipse.osgi.framework.log.FrameworkLog;
import org.eclipse.osgi.framework.log.FrameworkLogEntry;
import org.eclipse.osgi.framework.util.FilePath;
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/internal/adaptor/ConsoleManager.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/internal/adaptor/ConsoleManager.java
new file mode 100644
index 000000000..5f77f763b
--- /dev/null
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/internal/adaptor/ConsoleManager.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2012 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.core.runtime.internal.adaptor;
+
+import org.eclipse.osgi.internal.framework.EquinoxConfiguration;
+import org.osgi.framework.*;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+public class ConsoleManager {
+
+ public static final String PROP_CONSOLE = "osgi.console"; //$NON-NLS-1$
+ public static final String CONSOLE_BUNDLE = "org.eclipse.equinox.console"; //$NON-NLS-1$
+ public static final String PROP_CONSOLE_ENABLED = "osgi.console.enable.builtin"; //$NON-NLS-1$
+
+ private final BundleContext context;
+ private final EquinoxConfiguration equinoxConfig;
+ private final String consoleBundle;
+ private final String consolePort;
+
+ public ConsoleManager(BundleContext context, EquinoxConfiguration equinoxConfig) {
+ this.equinoxConfig = equinoxConfig;
+ String port = null;
+ String consolePropValue = equinoxConfig.getConfiguration(PROP_CONSOLE);
+ if (consolePropValue != null) {
+ int index = consolePropValue.lastIndexOf(":"); //$NON-NLS-1$
+ port = consolePropValue.substring(index + 1);
+ }
+ this.consolePort = port != null ? port.trim() : port;
+ String enabled = equinoxConfig.getConfiguration(PROP_CONSOLE_ENABLED, CONSOLE_BUNDLE);
+ this.context = context;
+ if (!"true".equals(enabled) || "none".equals(consolePort)) { //$NON-NLS-1$ //$NON-NLS-2$
+ this.consoleBundle = "false".equals(enabled) ? CONSOLE_BUNDLE : enabled; //$NON-NLS-1$
+ 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
+ equinoxConfig.setProperty("gosh.args", "--nointeractive"); //$NON-NLS-1$//$NON-NLS-2$
+ } else {
+ // Need to make sure we don't shutdown the framework if no console is around (bug 362412)
+ equinoxConfig.setProperty("gosh.args", "--noshutdown"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ return;
+ }
+ this.consoleBundle = "unknown"; //$NON-NLS-1$
+ }
+
+ public static ConsoleManager startConsole(BundleContext context, EquinoxConfiguration equinoxConfig) {
+ ConsoleManager consoleManager = new ConsoleManager(context, equinoxConfig);
+ return consoleManager;
+ }
+
+ @SuppressWarnings("deprecation")
+ public void checkForConsoleBundle() throws BundleException {
+ if ("none".equals(consolePort)) //$NON-NLS-1$
+ return;
+ // otherwise we need to check for the equinox console bundle and start it
+ ServiceReference<PackageAdmin> paRef = context.getServiceReference(PackageAdmin.class);
+ PackageAdmin pa = paRef == null ? null : context.getService(paRef);
+ Bundle[] consoles = pa.getBundles(consoleBundle, null);
+ 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
+ *
+ */
+ public void stopConsole() {
+ // nothing
+ }
+
+}

Back to the top