Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2012-06-12 21:29:15 +0000
committerThomas Watson2012-07-16 20:45:33 +0000
commitf843e83246bb55c8e035fb0fa3e5515516070cd2 (patch)
tree313b00cc0fbefbf1c6faa92f3a622fb615ca395d
parent43ba9615791ef5653de5728bc916f0519811306e (diff)
downloadrt.equinox.framework-f843e83246bb55c8e035fb0fa3e5515516070cd2.tar.gz
rt.equinox.framework-f843e83246bb55c8e035fb0fa3e5515516070cd2.tar.xz
rt.equinox.framework-f843e83246bb55c8e035fb0fa3e5515516070cd2.zip
remove internal console implementation
-rw-r--r--bundles/org.eclipse.osgi.tests/.classpath1
-rw-r--r--bundles/org.eclipse.osgi.tests/build.properties6
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/console.test/META-INF/MANIFEST.MF9
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/console.test/test/ConsoleTestActivator.java27
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/console.test/test/ConsoleTestCommandProvider.java82
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/AutomatedTests.java1
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/AllConsoleTests.java27
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/TestCommandExecution.java244
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/TestConsoleSession.java42
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/TestEquinoxStartWithConsole.java140
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/TestEquinoxStartWithoutConsole.java75
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/TestFrameworkCommandInterpreter.java148
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/TestRestrictedTelnetHost.java64
-rw-r--r--bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/ConsoleManager.java200
-rw-r--r--bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/ConsoleMessages.properties143
-rw-r--r--bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/ConsoleMsg.java159
-rw-r--r--bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandInterpreter.java599
-rw-r--r--bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandProvider.java1997
-rw-r--r--bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkConsole.java209
-rw-r--r--bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkConsoleSession.java58
-rw-r--r--bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorHook.java8
-rw-r--r--bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseCommandProvider.java283
22 files changed, 11 insertions, 4511 deletions
diff --git a/bundles/org.eclipse.osgi.tests/.classpath b/bundles/org.eclipse.osgi.tests/.classpath
index 26c1bba6f..2be8afb96 100644
--- a/bundles/org.eclipse.osgi.tests/.classpath
+++ b/bundles/org.eclipse.osgi.tests/.classpath
@@ -102,7 +102,6 @@
<classpathentry kind="src" output="bundle_tests/test.bug306181a" path="bundles_src/test.bug306181a"/>
<classpathentry kind="src" output="bundle_tests/test.bug306181b" path="bundles_src/test.bug306181b"/>
<classpathentry kind="src" output="bundle_tests/test.logging.a" path="bundles_src/test.logging.a"/>
- <classpathentry kind="src" output="bundle_tests/console.test" path="bundles_src/console.test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
diff --git a/bundles/org.eclipse.osgi.tests/build.properties b/bundles/org.eclipse.osgi.tests/build.properties
index 7bd2aeb17..a077dab5b 100644
--- a/bundles/org.eclipse.osgi.tests/build.properties
+++ b/bundles/org.eclipse.osgi.tests/build.properties
@@ -219,9 +219,6 @@ source.bundle_tests/test.bug306181b.jar = bundles_src/test.bug306181b/
manifest.bundle_tests/test.bug306181b.jar = META-INF/MANIFEST.MF
source.bundle_tests/test.logging.a.jar = bundles_src/test.logging.a/
manifest.bundle_tests/test.logging.a.jar = META-INF/MANIFEST.MF
-source.bundle_tests/console.test.jar = bundles_src/console.test/
-manifest.bundle_tests/console.test.jar = META-INF/MANIFEST.MF
-
jars.compile.order = bundle_tests/ext.framework.b.jar,\
osgitests.jar,\
@@ -324,5 +321,4 @@ jars.compile.order = bundle_tests/ext.framework.b.jar,\
bundle_tests/test.bug287750.jar,\
bundle_tests/test.bug306181a.jar,\
bundle_tests/test.bug306181b.jar,\
- bundle_tests/test.logging.a.jar,\
- bundle_tests/console.test.jar
+ bundle_tests/test.logging.a.jar
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/console.test/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/bundles_src/console.test/META-INF/MANIFEST.MF
deleted file mode 100644
index e368061f0..000000000
--- a/bundles/org.eclipse.osgi.tests/bundles_src/console.test/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,9 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: console.test
-Bundle-SymbolicName: console.test
-Bundle-Version: 1.0.0
-Import-Package: org.eclipse.osgi.framework.console;version="1.1.0",
- org.osgi.framework;version="1.5.0"
-Bundle-Activator: test.ConsoleTestActivator
-
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/console.test/test/ConsoleTestActivator.java b/bundles/org.eclipse.osgi.tests/bundles_src/console.test/test/ConsoleTestActivator.java
deleted file mode 100644
index 79c22ace3..000000000
--- a/bundles/org.eclipse.osgi.tests/bundles_src/console.test/test/ConsoleTestActivator.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 SAP AG 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:
- * Lazar Kirchev, SAP AG - initial API and implementation
- *******************************************************************************/
-package test;
-
-import org.eclipse.osgi.framework.console.CommandProvider;
-import org.osgi.framework.*;
-
-public class ConsoleTestActivator implements BundleActivator {
- ServiceRegistration serviceRegistration;
-
- public void start(BundleContext context) throws Exception {
- serviceRegistration = context.registerService(CommandProvider.class.getName(), new ConsoleTestCommandProvider(), null);
- }
-
- public void stop(BundleContext context) throws Exception {
- serviceRegistration.unregister();
- }
-
-}
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/console.test/test/ConsoleTestCommandProvider.java b/bundles/org.eclipse.osgi.tests/bundles_src/console.test/test/ConsoleTestCommandProvider.java
deleted file mode 100644
index 4cf9d45e8..000000000
--- a/bundles/org.eclipse.osgi.tests/bundles_src/console.test/test/ConsoleTestCommandProvider.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 SAP AG 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:
- * Lazar Kirchev, SAP AG - initial API and implementation
- *******************************************************************************/
-package test;
-
-import org.eclipse.osgi.framework.console.CommandInterpreter;
-import org.eclipse.osgi.framework.console.CommandProvider;
-
-public class ConsoleTestCommandProvider implements CommandProvider {
-
- public void _echo(CommandInterpreter intp) {
- intp.println(intp.nextArgument());
- }
-
- public void _cust_exec(CommandInterpreter intp) {
- String nextArg = intp.nextArgument();
- String innerCommand = null;
- if (nextArg != null) {
- intp.println("Customized execution of command " + nextArg);
- StringBuffer builder = new StringBuffer();
- while (nextArg != null) {
- builder.append(' ');
- builder.append(nextArg);
- nextArg = intp.nextArgument();
- }
- innerCommand = builder.toString().trim();
- intp.execute(innerCommand);
- }
- }
-
- public String getHelp() {
- return getHelp(null);
- }
-
- public Object _help(CommandInterpreter intp) {
- String commandName = intp.nextArgument();
- if (commandName == null) {
- return Boolean.FALSE;
- }
- String help = getHelp(commandName);
-
- if (help.length() > 0) {
- return help;
- }
-
- return Boolean.FALSE;
- }
-
- private String getHelp(String commandName) {
- boolean allCommands = commandName == null;
- StringBuffer help = new StringBuffer();
-
- if (allCommands) {
- help.append("---");
- help.append("Custom commands");
- help.append("---");
- help.append("\r\n");
- help.append("\t");
- }
- if (allCommands || "echo".equals(commandName)) {
- help.append("echo - echos input");
- help.append("\r\n");
- }
- if (allCommands) {
- help.append("\t");
- }
- if (allCommands || "cust_exec".equals(commandName)) {
- help.append("cust_exec - executes the command, passed as an argument");
- help.append("\r\n");
- }
-
- return help.toString();
- }
-
-}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/AutomatedTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/AutomatedTests.java
index f8be89a86..4c69ecaf2 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/AutomatedTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/AutomatedTests.java
@@ -60,7 +60,6 @@ public class AutomatedTests extends TestCase {
suite.addTest(FilterTests.suite());
suite.addTest(PermissionTests.suite());
suite.addTest(org.eclipse.osgi.tests.securityadmin.AllSecurityAdminTests.suite());
- //disable suite.addTest(AllConsoleTests.suite());
suite.addTest(org.eclipse.osgi.tests.resource.AllTests.suite());
return suite;
}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/AllConsoleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/AllConsoleTests.java
deleted file mode 100644
index 2f7be79ac..000000000
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/AllConsoleTests.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 SAP AG 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:
- * Lazar Kirchev, SAP AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osgi.tests.console;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class AllConsoleTests {
- public static Test suite() {
- TestSuite suite = new TestSuite(AllConsoleTests.class.getName());
- suite.addTest(TestCommandExecution.suite());
- suite.addTest(TestEquinoxStartWithConsole.suite());
- suite.addTest(TestFrameworkCommandInterpreter.suite());
- suite.addTest(TestEquinoxStartWithoutConsole.suite());
- // TODO disable because of bug 342146
- //suite.addTest(TestRestrictedTelnetHost.suite());
- return suite;
- }
-}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/TestCommandExecution.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/TestCommandExecution.java
deleted file mode 100644
index 23d518956..000000000
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/TestCommandExecution.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 SAP AG 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:
- * Lazar Kirchev, SAP AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osgi.tests.console;
-
-import java.io.*;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.core.tests.harness.CoreTest;
-import org.eclipse.osgi.framework.console.ConsoleSession;
-import org.eclipse.osgi.tests.OSGiTestsActivator;
-import org.eclipse.osgi.tests.bundles.BundleInstaller;
-import org.osgi.framework.*;
-
-/**
- * This tests execution of shell commands. One simple command is tested, and one command,
- * which itself executes another command. The test tests the whole scenario - installing a bundle, which
- * provides the commands, registering a ConsoleSession object, through which the commands
- * are sent for execution, and finally checking the output of the commands.
- *
- * This also tests the help provided for individual commands. Help for one command from custom command provider,
- * and one from the framework command provider is tested.
- *
- * Reading the output of the commands is performed in a separate thread in order to ensure that if no
- * output is available the test will not block on the reading
- *
- * The echo command just echos its argument
- * The cust_exec executes the command, passed as first argument to it, and attaches a string to its output
- */
-public class TestCommandExecution extends CoreTest {
- public static Test suite() {
- return new TestSuite(TestCommandExecution.class);
- }
-
- private BundleContext context;
- private BundleInstaller installer;
- private ConsoleSession session;
- private InputStream in;
- private OutputStream out;
- private PipedInputStream input;
-
- private static String BUNDLES_ROOT = "bundle_tests";
-
- private static String COMMAND_BUNDLE_FILE_NAME = "console.test";
- private static String SIMPLE_COMMAND_STRING = "echo";
- static String SIMPLE_COMMAND_OUTPUT = "Hello!";
-
- private static String COMPOSITE_COMMAND_STRING = "cust_exec echo Hello!";
- static String COMPOSITE_COMMAND_OUTPUT = "Customized execution of command echo";
-
- private static String HELP_CUSTOM_COMMAND_STRING = "help cust_exec";
- static String HELP_CUSTOM_COMMAND_OUTPUT = "cust_exec - executes the command, passed as an argument";
-
- private static String HELP_FRAMEWORK_COMMAND_STRING = "help ss";
- static String HELP_FRAMEWORK_COMMAND_OUTPUT = "ss [-s [<comma separated list of bundle states>] [<segment of bsn>]] - display installed bundles (short status)";
-
- static String SIMPLE = "simple";
- static String COMPOSITE = "composite";
- static String CUSTOM_HELP = "custom_help";
- static String FRAMEWORK_HELP = "framework_help";
-
- boolean isOutputOk = false;
- boolean isCompositeContained = false;
- boolean isSimpleContained = false;
-
- private static final Object waitObject = new Object();
- private static final int TIMEOUT = 1000;
-
- public void testSimpleCommandExecution() {
- Bundle bundle = prepare(SIMPLE_COMMAND_STRING + " " + SIMPLE_COMMAND_OUTPUT);
- BufferedReader reader = new BufferedReader(new InputStreamReader(input));
- Thread readThread = new Thread(new ReadThread(reader, SIMPLE));
- readThread.start();
-
- try {
- synchronized (waitObject) {
- waitObject.wait(TIMEOUT);
- }
- } catch (InterruptedException ie) {
- // do nothing
- } finally {
- readThread.interrupt();
- }
-
- assertTrue("Output not as expected", isOutputOk);
- cleanUp(bundle);
- }
-
- public void testCompositeCommandExecution() {
- Bundle bundle = prepare(COMPOSITE_COMMAND_STRING);
- BufferedReader reader = new BufferedReader(new InputStreamReader(input));
- Thread readThread = new Thread(new ReadThread(reader, COMPOSITE));
- readThread.start();
-
- try {
- synchronized (waitObject) {
- waitObject.wait(TIMEOUT);
- }
- } catch (InterruptedException ie) {
- // do nothing
- } finally {
- readThread.interrupt();
- }
- assertTrue("Output not as expected", isCompositeContained && isSimpleContained);
- cleanUp(bundle);
- }
-
- public void testHelpCustomCommand() {
- testCommand(HELP_CUSTOM_COMMAND_STRING, CUSTOM_HELP);
- }
-
- public void testHelpFrameworkCommand() {
- testCommand(HELP_FRAMEWORK_COMMAND_STRING, FRAMEWORK_HELP);
- }
-
- private void testCommand(String command, String type) {
- Bundle bundle = prepare(command);
- BufferedReader reader = new BufferedReader(new InputStreamReader(input));
- Thread readThread = new Thread(new ReadThread(reader, type));
- readThread.start();
-
- try {
- synchronized (waitObject) {
- waitObject.wait(TIMEOUT);
- }
- } catch (InterruptedException ie) {
- // do nothing
- } finally {
- readThread.interrupt();
- }
- assertTrue("Output not as expected", isOutputOk);
- cleanUp(bundle);
- }
-
- private Bundle prepare(String command) {
- context = OSGiTestsActivator.getContext();
- try {
- installer = new BundleInstaller(BUNDLES_ROOT, context);
- String location = installer.getBundleLocation(COMMAND_BUNDLE_FILE_NAME);
- Bundle cmdBundle = context.installBundle(location);
- cmdBundle.start();
- out = new PipedOutputStream();
- input = new PipedInputStream((PipedOutputStream) out);
- in = new StringBufferInputStream(command);
- session = new TestConsoleSession(in, out);
- context.registerService(ConsoleSession.class.getName(), session, null);
- return cmdBundle;
- } catch (Exception e) {
- fail("Unexpected failure", e);
- }
-
- return null;
- }
-
- private void cleanUp(Bundle bundle) {
- if (bundle != null) {
- try {
- bundle.uninstall();
- } catch (BundleException e) {
- // do nothing
- }
- }
- }
-
- private class ReadThread implements Runnable {
- BufferedReader reader;
- String type;
-
- ReadThread(BufferedReader reader, String type) {
- this.reader = reader;
- this.type = type;
- }
-
- public void run() {
- try {
- if (type.equals(SIMPLE)) {
- checkSimple();
- } else if (type.equals(COMPOSITE)) {
- checkComposite();
- } else if (type.equals(CUSTOM_HELP)) {
- checkCommandOutput(HELP_CUSTOM_COMMAND_OUTPUT);
- } else if (type.equals(FRAMEWORK_HELP)) {
- checkCommandOutput(HELP_FRAMEWORK_COMMAND_OUTPUT);
- }
- } catch (IOException e) {
- fail("Unexpected failure", e);
- }
- }
-
- private void checkSimple() throws IOException {
- String line;
- while ((line = reader.readLine()) != null) {
- if (line.indexOf(SIMPLE_COMMAND_OUTPUT) > -1) {
- isOutputOk = true;
- break;
- }
- }
- }
-
- private void checkComposite() throws IOException {
- String line;
- while ((line = reader.readLine()) != null) {
- if (line.indexOf(COMPOSITE_COMMAND_OUTPUT) > -1) {
- isCompositeContained = true;
- if ((line = reader.readLine()) != null) {
- if (line.indexOf(SIMPLE_COMMAND_OUTPUT) > -1) {
- isSimpleContained = true;
- break;
- }
- }
- }
- }
- }
-
- private void checkCommandOutput(String expectedOutput) throws IOException {
- String line;
- line = reader.readLine();
- if (line == null || (line != null && line.length() > 0)) {
- isOutputOk = false;
- return;
- }
- line = reader.readLine();
- if (line != null && line.indexOf(expectedOutput) > -1) {
- isOutputOk = true;
- } else {
- isOutputOk = false;
- return;
- }
- line = reader.readLine();
- if (line == null || (line != null && line.length() > 0)) {
- isOutputOk = false;
- return;
- }
- }
- }
-
-}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/TestConsoleSession.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/TestConsoleSession.java
deleted file mode 100644
index ce1de77c3..000000000
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/TestConsoleSession.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 SAP AG 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:
- * Lazar Kirchev, SAP AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osgi.tests.console;
-
-import java.io.*;
-import org.eclipse.osgi.framework.console.ConsoleSession;
-
-public class TestConsoleSession extends ConsoleSession {
- private InputStream in;
- private OutputStream out;
-
- public TestConsoleSession(InputStream in, OutputStream out) {
- this.in = in;
- this.out = out;
- }
-
- protected void doClose() {
- try {
- in.close();
- out.close();
- } catch (IOException e) {
- // do nothing
- }
- }
-
- public InputStream getInput() {
- return in;
- }
-
- public OutputStream getOutput() {
- return out;
- }
-
-}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/TestEquinoxStartWithConsole.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/TestEquinoxStartWithConsole.java
deleted file mode 100644
index cc9d87185..000000000
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/TestEquinoxStartWithConsole.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 SAP AG 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:
- * Lazar Kirchev, SAP AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osgi.tests.console;
-
-import java.io.*;
-import java.net.Socket;
-import java.util.HashMap;
-import java.util.Map;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.osgi.launch.EquinoxFactory;
-import org.eclipse.osgi.tests.OSGiTest;
-import org.osgi.framework.launch.Framework;
-
-/**
- * This tests that when the equinox framework is started with the -console option (with or without port)
- * the console will be actually started. In both test cases a framework is started with the respective
- * option, and the console prompt is expected to be read from the output stream.
- *
- * The reading from the output stream is performed in a separate thread to ensure that if output is not availbl
- * the test will not block on the reading.
- *
- */
-public class TestEquinoxStartWithConsole extends OSGiTest {
- public static Test suite() {
- return new TestSuite(TestEquinoxStartWithConsole.class);
- }
-
- private static String CONSOLE_PROMPT = "osgi>";
- boolean isConsolePromptAvailable = false;
- private static final Object waitObject = new Object();
- private static final int TIMEOUT = 1000;
-
- public void testEquinoxStartWithPort() {
- try {
- Map configuration = new HashMap();
- configuration.put("osgi.console", "55555");
- configuration.put("osgi.configuration.area", "inner");
- EquinoxFactory factory = new EquinoxFactory();
- Framework framework = factory.newFramework(configuration);
- framework.start();
- Socket s = new Socket("localhost", 55555);
-
- InputStream input = s.getInputStream();
- StringBuffer buffer = new StringBuffer();
- Thread readThread = new Thread(new ReadThread(input, buffer));
- readThread.start();
-
- try {
- synchronized (waitObject) {
- waitObject.wait(TIMEOUT);
- }
- } catch (InterruptedException ie) {
- // do nothing
- } finally {
- readThread.interrupt();
- input.close();
- s.close();
- }
-
- framework.stop();
- assertTrue("Console prompt not available", isConsolePromptAvailable);
- } catch (Exception e) {
- fail("Unexpected failure", e);
- }
- }
-
- public void testEquinoxStartWithoutPort() {
- try {
- Map configuration = new HashMap();
- configuration.put("osgi.console", "");
- configuration.put("osgi.configuration.area", "inner");
- EquinoxFactory factory = new EquinoxFactory();
- Framework framework = factory.newFramework(configuration);
-
- PrintStream systemOutOriginal = System.out;
- PipedOutputStream out = new PipedOutputStream();
- PrintStream print = new PrintStream(out);
- PipedInputStream input = new PipedInputStream(out);
- System.setOut(print);
-
- framework.start();
-
- StringBuffer buffer = new StringBuffer();
- Thread readThread = new Thread(new ReadThread(input, buffer));
- readThread.start();
-
- try {
- synchronized (waitObject) {
- waitObject.wait(TIMEOUT);
- }
- } catch (InterruptedException ie) {
- // do nothing
- } finally {
- readThread.interrupt();
- }
-
- System.setOut(systemOutOriginal);
-
- framework.stop();
- assertTrue("Console prompt not available", isConsolePromptAvailable);
- } catch (Exception e) {
- fail("Unexpected failure", e);
- }
- }
-
- private class ReadThread implements Runnable {
- private InputStreamReader input;
- private StringBuffer string;
-
- ReadThread(InputStream stream, StringBuffer buffer) {
- input = new InputStreamReader(stream);
- string = buffer;
- }
-
- public void run() {
- int c;
- try {
- while ((c = input.read()) != -1) {
- string.append((char) c);
- if (string.toString().indexOf(CONSOLE_PROMPT) > -1) {
- isConsolePromptAvailable = true;
- break;
- }
- }
-
- } catch (IOException e) {
- //do nothing
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/TestEquinoxStartWithoutConsole.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/TestEquinoxStartWithoutConsole.java
deleted file mode 100644
index 8d6d8143d..000000000
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/TestEquinoxStartWithoutConsole.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 SAP AG 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:
- * Lazar Kirchev, SAP AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osgi.tests.console;
-
-import java.util.HashMap;
-import java.util.Map;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.osgi.framework.console.CommandProvider;
-import org.eclipse.osgi.framework.console.ConsoleSession;
-import org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider;
-import org.eclipse.osgi.framework.internal.core.FrameworkConsoleSession;
-import org.eclipse.osgi.launch.EquinoxFactory;
-import org.eclipse.osgi.tests.OSGiTest;
-import org.osgi.framework.*;
-import org.osgi.framework.launch.Framework;
-
-/**
- * This test tests if the built-in console is correctly disabled - the Framework command provider should not be registered,
- * as well as the FrameworkConsoleSession.
- *
- */
-public class TestEquinoxStartWithoutConsole extends OSGiTest {
- public static Test suite() {
- return new TestSuite(TestEquinoxStartWithoutConsole.class);
- }
-
- public void testEquinoxStart() {
- Framework framework = null;
- try {
- Map configuration = new HashMap();
- configuration.put("osgi.console.enable.builtin", "false");
- configuration.put("osgi.configuration.area", "inner");
- EquinoxFactory factory = new EquinoxFactory();
- framework = factory.newFramework(configuration);
- framework.start();
- BundleContext context = framework.getBundleContext();
-
- ServiceReference[] commandProviders = context.getAllServiceReferences(CommandProvider.class.getName(), null);
- if (commandProviders != null) {
- for (int i = 0; i < commandProviders.length; i++) {
- if (commandProviders[i] instanceof FrameworkCommandProvider) {
- fail("FrameworkCommandProvider is registered, but should not be");
- }
- }
- }
-
- ServiceReference[] consoleSessions = context.getAllServiceReferences(ConsoleSession.class.getName(), null);
- if (consoleSessions != null) {
- for (int i = 0; i < consoleSessions.length; i++) {
- if (consoleSessions[i] instanceof FrameworkConsoleSession) {
- fail("FrameworkConsoleSession is registered, but should not be");
- }
- }
- }
- } catch (Exception e) {
- fail("Unexpected failure", e);
- } finally {
- if (framework != null)
- try {
- framework.stop();
- } catch (BundleException e) {
- // Ignore; just trying to clean up the test framework
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/TestFrameworkCommandInterpreter.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/TestFrameworkCommandInterpreter.java
deleted file mode 100644
index f9e397ce6..000000000
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/TestFrameworkCommandInterpreter.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 SAP AG 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:
- * Lazar Kirchev, SAP AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osgi.tests.console;
-
-import java.io.*;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.core.tests.harness.CoreTest;
-import org.eclipse.osgi.framework.console.CommandProvider;
-import org.eclipse.osgi.framework.internal.core.*;
-import org.eclipse.osgi.tests.OSGiTestsActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
-
-public class TestFrameworkCommandInterpreter extends CoreTest {
- public static Test suite() {
- return new TestSuite(TestFrameworkCommandInterpreter.class);
- }
-
- FrameworkCommandInterpreter cmdInterpreter;
- OutputStream out;
- private static String CMD_LINE_NEXT_ARG = "token1 token2 token3";
- private static String CMD_LINE_EXECUTE = "sl 0";
- static String EXPECTED_CMD_OUTPUT = "Bundle 0 Start Level = 0";
-
- boolean isOutputNull = false;
- boolean isOutputAsExpected = false;
-
- private static final Object waitObject = new Object();
- private static final int TIMEOUT = 1000;
-
- /*
- * Tests the FrameworkCommandInterpreter.nextArgument() method
- */
- public void testNextArgument() {
- // these are mock implementations of streams, because they are required to create FrameworkCommandInterpreter,
- // but are not actually used
- InputStream inputStr = new InputStream() {
-
- public int read() throws IOException {
- return 0;
- }
- };
-
- OutputStream outputStr = new OutputStream() {
-
- public void write(int b) throws IOException {
- // do nothing
- }
- };
-
- FrameworkConsoleSession consoleSession = new FrameworkConsoleSession(inputStr, outputStr, null);
- FrameworkConsole console = new FrameworkConsole(null, consoleSession, false, null);
- FrameworkCommandInterpreter frwkCmdInterpreter = new FrameworkCommandInterpreter(CMD_LINE_NEXT_ARG, null, console);
- assertEquals("First token not as expected", "token1", frwkCmdInterpreter.nextArgument());
- assertEquals("Second token not as expected", "token2", frwkCmdInterpreter.nextArgument());
- assertEquals("Third token not as expected", "token3", frwkCmdInterpreter.nextArgument());
- }
-
- /*
- * This method tests the execute() method of FrameworkCommandInterpreter class. It passes to the execute method
- * the "sl" command with parameter the system bundle and expects a particular output.
- */
- public void testExecute() {
- prepare();
- String command = cmdInterpreter.nextArgument();
-
- try {
- PipedInputStream input = new PipedInputStream((PipedOutputStream) out);
- cmdInterpreter.execute(command);
- BufferedReader reader = new BufferedReader(new InputStreamReader(input));
-
- // The output is read in another thread in order to insure that if for some reason there is no output,
- // the test will not block on the reading
- Thread readThread = new Thread(new ReadThread(reader));
- readThread.start();
-
- try {
- synchronized (waitObject) {
- waitObject.wait(TIMEOUT);
- }
- } catch (InterruptedException ie) {
- // do nothing
- } finally {
- readThread.interrupt();
- }
-
- assertFalse("No output from the command", isOutputNull);
- assertTrue("Output of the command not as expected", isOutputAsExpected);
- } catch (IOException e) {
- fail("Unexpected failure", e);
- }
-
- }
-
- private void prepare() {
- InputStream in = new InputStream() {
-
- public int read() throws IOException {
- return 0;
- }
- };
-
- out = new PipedOutputStream();
- FrameworkConsoleSession session = new FrameworkConsoleSession(in, out, null);
- FrameworkConsole console = new FrameworkConsole(null, session, false, null);
- BundleContext context = OSGiTestsActivator.getContext();
- ServiceTracker cptracker = new ServiceTracker(context, CommandProvider.class.getName(), null);
- cptracker.open();
- ServiceReference[] refs = cptracker.getServiceReferences();
- CommandProvider[] commandProviders = new CommandProvider[refs.length];
- for (int i = 0; i < refs.length; i++) {
- commandProviders[i] = (CommandProvider) context.getService(refs[i]);
- }
- cmdInterpreter = new FrameworkCommandInterpreter(CMD_LINE_EXECUTE, commandProviders, console);
- }
-
- private class ReadThread implements Runnable {
- BufferedReader reader;
-
- ReadThread(BufferedReader reader) {
- this.reader = reader;
- }
-
- public void run() {
- try {
- String line;
- line = reader.readLine();
- if (line == null) {
- isOutputNull = true;
- return;
- }
- isOutputAsExpected = line.indexOf(EXPECTED_CMD_OUTPUT) > -1;
- } catch (IOException e) {
- fail("Unexpected failure", e);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/TestRestrictedTelnetHost.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/TestRestrictedTelnetHost.java
deleted file mode 100644
index bb740e0da..000000000
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/console/TestRestrictedTelnetHost.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 SAP AG 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:
- * Lazar Kirchev, SAP AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osgi.tests.console;
-
-import java.net.*;
-import java.util.HashMap;
-import java.util.Map;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.core.tests.harness.CoreTest;
-import org.eclipse.osgi.launch.EquinoxFactory;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.launch.Framework;
-
-/**
- * This test tests if when the telnet access is restricted to a particular host address (in this case localhost),
- * a telnet connection cannot be open on another of the host's IP addresses.
- *
- */
-public class TestRestrictedTelnetHost extends CoreTest {
- public static Test suite() {
- return new TestSuite(TestRestrictedTelnetHost.class);
- }
-
- public void testRestrictedTelnetHost() {
- Framework framework = null;
- try {
- InetAddress address = InetAddress.getLocalHost();
- String hostname = address.getHostName();
- if ("localhost".equals(hostname))
- return; // cannot test
- Map configuration = new HashMap();
- configuration.put("osgi.console", "localhost:55555");
- configuration.put("osgi.configuration.area", "inner");
- EquinoxFactory factory = new EquinoxFactory();
- framework = factory.newFramework(configuration);
- framework.start();
-
- try {
- Socket clientSocket = new Socket(address, 55555);
- clientSocket.close();
- fail("Telnet should listen only on localhost, not on " + address.getHostAddress());
- } catch (ConnectException e) {
- // it's ok; do nothing
- }
- } catch (Exception e) {
- fail("Unexpected failure", e);
- } finally {
- try {
- framework.stop();
- } catch (BundleException e) {
- // Ignore; just try to clean up test framework
- }
- }
- }
-}
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 ecb88c91d..14b3f8f3a 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
@@ -10,114 +10,31 @@
*******************************************************************************/
package org.eclipse.osgi.framework.internal.core;
-import java.io.*;
-import java.lang.reflect.Method;
-import java.net.*;
-import java.util.Dictionary;
-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.*;
-import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
-public class ConsoleManager implements ServiceTrackerCustomizer<ConsoleSession, FrameworkConsole> {
- /**
- * ConsoleSocketGetter - provides a Thread that listens on the port
- * for FrameworkConsole.
- */
- class ConsoleSocketGetter implements Runnable {
-
- /** The ServerSocket to accept connections from */
- private final ServerSocket server;
- private volatile boolean shutdown = false;
-
- /**
- * Constructor - sets the server and starts the thread to
- * listen for connections.
- *
- * @param server a ServerSocket to accept connections from
- */
- ConsoleSocketGetter(ServerSocket server) {
- this.server = server;
- try {
- Method reuseAddress = server.getClass().getMethod("setReuseAddress", new Class[] {boolean.class}); //$NON-NLS-1$
- reuseAddress.invoke(server, new Object[] {Boolean.TRUE});
- } catch (Exception ex) {
- // try to set the socket re-use property, it isn't a problem if it can't be set
- }
- Thread t = new Thread(this, "ConsoleSocketGetter"); //$NON-NLS-1$
- t.setDaemon(false);
- t.start();
- }
-
- public void run() {
- // Print message containing port console actually bound to..
- System.out.println(NLS.bind(ConsoleMsg.CONSOLE_LISTENING_ON_PORT, server.getInetAddress().toString() + ':' + Integer.toString(server.getLocalPort())));
- while (!shutdown) {
- try {
- Socket socket = server.accept();
- if (socket == null)
- throw new IOException("No socket available. Probably caused by a shutdown."); //$NON-NLS-1$
- FrameworkConsoleSession session = new FrameworkConsoleSession(socket.getInputStream(), socket.getOutputStream(), socket);
- framework.getSystemBundleContext().registerService(ConsoleSession.class.getName(), session, null);
- } catch (Exception e) {
- if (!shutdown)
- e.printStackTrace();
- }
-
- }
- }
-
- public void shutdown() {
- if (shutdown)
- return;
- shutdown = true;
- try {
- server.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
+public class ConsoleManager {
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$
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$
- final Framework framework;
- private final ServiceTracker<CommandProvider, CommandProvider> cpTracker;
- private final ServiceTracker<ConsoleSession, FrameworkConsole> sessions;
- private final String consolePort;
- // Allow for specifying the particular local host address on which the framework to listen for connections. Currently it listens on
- // all network interfaces of the host and restricting this is desirable from security point of view. See bug 322917.
- private final String consoleHost;
- private FrameworkCommandProvider fwkCommands;
- private ServiceRegistration<?> builtinSession;
- private ConsoleSocketGetter socketGetter;
- private final boolean isEnabled;
+
+ private final Framework framework;
private final String consoleBundle;
+ private final String consolePort;
public ConsoleManager(Framework framework, String consolePropValue) {
String port = null;
- String host = null;
if (consolePropValue != null) {
int index = consolePropValue.lastIndexOf(":"); //$NON-NLS-1$
- if (index > -1) {
- host = consolePropValue.substring(0, index);
- }
port = consolePropValue.substring(index + 1);
}
- this.framework = framework;
- this.consoleHost = host != null ? host.trim() : host;
this.consolePort = port != null ? port.trim() : port;
String enabled = FrameworkProperties.getProperty(PROP_CONSOLE_ENABLED, CONSOLE_BUNDLE);
- if (!"true".equals(enabled) || "none".equals(port)) { //$NON-NLS-1$ //$NON-NLS-2$
- isEnabled = false;
- this.cpTracker = null;
- this.sessions = null;
+ this.framework = framework;
+ 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;
@@ -129,79 +46,15 @@ public class ConsoleManager implements ServiceTrackerCustomizer<ConsoleSession,
}
return;
}
- this.isEnabled = true;
- 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) {
ConsoleManager consoleManager = new ConsoleManager(framework, FrameworkProperties.getProperty(PROP_CONSOLE));
- consoleManager.startConsole();
return consoleManager;
}
- private void startConsole() {
- if (!isEnabled) {
- return;
- }
-
- this.cpTracker.open();
- this.sessions.open();
- fwkCommands = new FrameworkCommandProvider(framework);
- fwkCommands.start();
- if (consolePort == null)
- return;
- int port = -1;
- try {
- if (consolePort.length() > 0)
- port = Integer.parseInt(consolePort);
- } catch (NumberFormatException e) {
- // do nothing;
- }
- if (port < 0) {
- InputStream in = new FilterInputStream(System.in) {
- /**
- * @throws IOException
- */
- public void close() throws IOException {
- // We don't want to close System.in
- }
- };
- OutputStream out = new FilterOutputStream(System.out) {
- /**
- * @throws IOException
- */
- public void close() throws IOException {
- // We don't want to close System.out
- }
-
- public void write(byte[] var0, int var1, int var2) throws IOException {
- this.out.write(var0, var1, var2);
- }
-
- };
- FrameworkConsoleSession session = new FrameworkConsoleSession(in, out, null);
- Dictionary<String, Object> props = null;
- props = new Hashtable<String, Object>(1);
- props.put(PROP_SYSTEM_IN_OUT, Boolean.TRUE);
- builtinSession = framework.getSystemBundleContext().registerService(ConsoleSession.class.getName(), session, props);
- } else {
- try {
- if (consoleHost != null) {
- socketGetter = new ConsoleSocketGetter(new ServerSocket(port, 0, InetAddress.getByName(consoleHost)));
- } else {
- socketGetter = new ConsoleManager.ConsoleSocketGetter(new ServerSocket(port));
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
-
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
@@ -223,44 +76,7 @@ public class ConsoleManager implements ServiceTrackerCustomizer<ConsoleSession,
*
*/
public void stopConsole() {
- if (!isEnabled) {
- return;
- }
- if (builtinSession != null)
- try {
- builtinSession.unregister();
- } catch (IllegalStateException e) {
- // ignore; this can happen if the session was closed manually (bug 314343)
- }
- sessions.close();
- cpTracker.close();
- if (socketGetter != null)
- socketGetter.shutdown();
- if (fwkCommands != null)
- fwkCommands.stop();
- }
-
- public FrameworkConsole addingService(ServiceReference<ConsoleSession> reference) {
- FrameworkConsole console = null;
-
- Boolean isSystemInOut = (Boolean) reference.getProperty(PROP_SYSTEM_IN_OUT);
- if (isSystemInOut == null)
- isSystemInOut = Boolean.FALSE;
-
- ConsoleSession session = framework.getSystemBundleContext().getService(reference);
- console = new FrameworkConsole(framework.getSystemBundleContext(), session, isSystemInOut.booleanValue(), cpTracker);
-
- Thread t = new Thread(console, CONSOLE_NAME);
- t.setDaemon(false);
- t.start();
- return console;
- }
-
- public void modifiedService(ServiceReference<ConsoleSession> reference, FrameworkConsole service) {
// nothing
}
- public void removedService(ServiceReference<ConsoleSession> reference, FrameworkConsole service) {
- service.shutdown();
- }
}
diff --git a/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/ConsoleMessages.properties b/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/ConsoleMessages.properties
deleted file mode 100644
index fc686ad45..000000000
--- a/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/ConsoleMessages.properties
+++ /dev/null
@@ -1,143 +0,0 @@
-###############################################################################
-# Copyright (c) 2003, 2011 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
-###############################################################################
-
-#External Messages for EN locale
-CONSOLE_PROMPT=osgi>
-CONSOLE_ID=id
-CONSOLE_MORE=-- More...Press Enter to Continue...
-CONSOLE_HELP_CONTROLLING_CONSOLE_HEADING=---Controlling the Console---
-CONSOLE_HELP_MORE=More prompt for console output
-CONSOLE_HELP_DISCONNECT=Disconnects from telnet session
-CONSOLE_CONFIRM_MORE=Use 'more' prompt?
-CONSOLE_MORE_ENTER_LINES=Enter maximum number of lines to scroll:
-CONSOLE_CONFIRM_DISCONNECT=Disconnect from console?
-CONSOLE_CONFIRM=Confirm
-CONSOLE_CONFIRM_VALUES=y/n; default=
-CONSOLE_Y=y
-CONSOLE_N=n
-CONSOLE_ERROR_READING_RESOURCE=Error reading {0}
-CONSOLE_RESOURCE_NOT_IN_BUNDLE={0} not found in {1}
-CONSOLE_NESTED_EXCEPTION=Nested Exception:
-CONSOLE_PROMPT_DEFAULT=default
-CONSOLE_INVALID_INPUT=Invalid input.
-CONSOLE_TOO_MUCH_INVALID_INPUT=Too much invalid input.
-CONSOLE_LINES_TO_SCROLL_NEGATIVE_ERROR=Lines to scroll is set to a negative number
-CONSOLE_HELP_CONTROLLING_FRAMEWORK_HEADER=Controlling the OSGi framework
-CONSOLE_HELP_LAUNCH_COMMAND_DESCRIPTION=start the OSGi Framework
-CONSOLE_HELP_SHUTDOWN_COMMAND_DESCRIPTION=shutdown the OSGi Framework
-CONSOLE_HELP_CLOSE_COMMAND_DESCRIPTION=shutdown and exit
-CONSOLE_HELP_EXIT_COMMAND_DESCRIPTION=exit immediately (System.exit)
-CONSOLE_HELP_GC_COMMAND_DESCRIPTION=perform a garbage collection
-CONSOLE_HELP_INIT_COMMAND_DESCRIPTION=uninstall all bundles
-CONSOLE_HELP_SETPROP_COMMAND_DESCRIPTION=set the OSGi property
-CONSOLE_HELP_CONTROLLING_BUNDLES_HEADER=Controlling Bundles
-CONSOLE_HELP_INSTALL_COMMAND_DESCRIPTION=install and optionally start bundle from the given URL
-CONSOLE_HELP_UNINSTALL_COMMAND_DESCRIPTION=uninstall the specified bundle(s)
-CONSOLE_HELP_START_COMMAND_DESCRIPTION=start the specified bundle(s)
-CONSOLE_HELP_STOP_COMMAND_DESCRIPTION=stop the specified bundle(s)
-CONSOLE_HELP_REFRESH_COMMAND_DESCRIPTION=refresh the packages of the specified bundles
-CONSOLE_HELP_UPDATE_COMMAND_DESCRIPTION=update the specified bundle(s)
-CONSOLE_HELP_DISPLAYING_STATUS_HEADER=Displaying Status
-CONSOLE_HELP_STATUS_COMMAND_DESCRIPTION=display installed bundles and registered services
-CONSOLE_HELP_STATE_ARGUMENT_DESCRIPTION=[-s [<comma separated list of bundle states>] [<segment of bsn>]]
-CONSOLE_HELP_SS_COMMAND_DESCRIPTION=display installed bundles (short status)
-CONSOLE_HELP_SERVICES_COMMAND_DESCRIPTION=display registered service details. Examples for [filter]: (objectClass=com.xyz.Person); (&(objectClass=com.xyz.Person)(|(sn=Jensen)(cn=Babs J*))); passing only com.xyz.Person is a shortcut for (objectClass=com.xyz.Person). The filter syntax specification is available at http://www.ietf.org/rfc/rfc1960.txt
-CONSOLE_HELP_PACKAGES_COMMAND_DESCRIPTION=display imported/exported package details
-CONSOLE_HELP_BUNDLES_COMMAND_DESCRIPTION=display details for all installed bundles
-CONSOLE_HELP_BUNDLE_COMMAND_DESCRIPTION=display details for the specified bundle(s)
-CONSOLE_HELP_HEADERS_COMMAND_DESCRIPTION=print bundle headers
-CONSOLE_HELP_EXTRAS_HEADER=Extras
-CONSOLE_HELP_EXEC_COMMAND_DESCRIPTION=execute a command in a separate process and wait
-CONSOLE_HELP_FORK_COMMAND_DESCRIPTION=execute a command in a separate process
-CONSOLE_HELP_KEYVALUE_ARGUMENT_DESCRIPTION=<key>=<value>
-CONSOLE_HELP_FILTER_ARGUMENT_DESCRIPTION=[filter]
-CONSOLE_HELP_PACKAGES_ARGUMENT_DESCRIPTION=[<pkgname>|<id>|<location>]
-CONSOLE_HELP_IDLOCATION_ARGUMENT_DESCRIPTION=(<id>|<location>)
-CONSOLE_HELP_OPTIONAL_IDLOCATION_ARGUMENT_DESCRIPTION=[<id>|<location>]
-CONSOLE_HELP_COMMAND_ARGUMENT_DESCRIPTION=<command>
-CONSOLE_HELP_GETPROP_COMMAND_DESCRIPTION=displays the system properties with the given name, or all of them.
-CONSOLE_HELP_GETPROP_ARGUMENT_DESCRIPTION=[ name ]
-CONSOLE_NO_BUNDLE_SPECIFIED_ERROR=No bundle(s) specified!
-CONSOLE_NOTHING_TO_INSTALL_ERROR=Nothing to install!
-CONSOLE_NO_INSTALLED_BUNDLES_ERROR=No installed bundles.
-CONSOLE_BUNDLE_ID_MESSAGE=Bundle id is
-CONSOLE_FRAMEWORK_IS_LAUNCHED_MESSAGE=Framework is launched.
-CONSOLE_FRAMEWORK_IS_SHUTDOWN_MESSAGE=Framework is shutdown.
-CONSOLE_ID_MESSAGE=Id={0}
-CONSOLE_BUNDLE_LOCATION_MESSAGE=Bundle Location
-CONSOLE_STATE_BUNDLE_FILE_NAME_HEADER=State Bundle File Name
-CONSOLE_REGISTERED_SERVICES_MESSAGE=Registered Services
-CONSOLE_REGISTERED_BY_BUNDLE_MESSAGE=Registered by bundle:
-CONSOLE_BUNDLES_USING_SERVICE_MESSAGE=Bundles using service:
-CONSOLE_NO_BUNDLES_USING_SERVICE_MESSAGE=No bundles using service.
-CONSOLE_NO_REGISTERED_SERVICES_MESSAGE=No registered services.
-CONSOLE_NO_EXPORTED_PACKAGES_MESSAGE=No exported packages
-CONSOLE_NO_IMPORTED_PACKAGES_MESSAGE=No imported packages
-CONSOLE_REMOVAL_PENDING_MESSAGE=removal pending
-CONSOLE_IMPORTS_MESSAGE=imports
-CONSOLE_STALE_MESSAGE=stale
-CONSOLE_NO_EXPORTED_PACKAGES_NO_PACKAGE_ADMIN_MESSAGE=No exported packages [PackageAdmin service is not registered]
-CONSOLE_SERVICES_IN_USE_MESSAGE=Services in use:
-CONSOLE_NO_SERVICES_IN_USE_MESSAGE=No services in use.
-CONSOLE_STATUS_MESSAGE=Status={0}
-CONSOLE_DATA_ROOT_MESSAGE=Data Root={0}
-CONSOLE_EXPORTED_PACKAGES_MESSAGE=Exported packages
-CONSOLE_IMPORTED_PACKAGES_MESSAGE=Imported packages
-CONSOLE_EXPORTED_REMOVAL_PENDING_MESSAGE=[exported(removal pending)]
-CONSOLE_EXPORTED_MESSAGE=[exported]
-CONSOLE_TOTAL_MEMORY_MESSAGE=Total memory:
-CONSOLE_FREE_MEMORY_BEFORE_GARBAGE_COLLECTION_MESSAGE=Free memory before GC:
-CONSOLE_FREE_MEMORY_AFTER_GARBAGE_COLLECTION_MESSAGE=Free memory after GC:
-CONSOLE_MEMORY_GAINED_WITH_GARBAGE_COLLECTION_MESSAGE=Memory gained with GC:
-CONSOLE_FRAMEWORK_LAUNCHED_PLEASE_SHUTDOWN_MESSAGE=Framework is launched. Please shutdown framework first.
-CONSOLE_INVALID_BUNDLE_SPECIFICATION_ERROR=Invalid bundle specification.
-CONSOLE_CAN_NOT_REFRESH_NO_PACKAGE_ADMIN_ERROR=Cannot refresh [PackageAdmin service is not registered]
-CONSOLE_CAN_NOT_USE_STARTLEVEL_NO_STARTLEVEL_SVC_ERROR=Cannot use Startlevel commands [Startlevel service is not registered]
-CONSOLE_NO_COMMAND_SPECIFIED_ERROR=No command specified
-CONSOLE_EXECUTED_RESULT_CODE_MESSAGE=Executed ({0}); result code = {1}
-CONSOLE_STARTED_IN_MESSAGE=Started({0}) in {1}
-CONSOLE_BUNDLE_HEADERS_TITLE=Bundle headers:
-CONSOLE_SYSTEM_PROPERTIES_TITLE=System properties:
-CONSOLE_NO_PARAMETERS_SPECIFIED_TITLE=No parameters specified:
-CONSOLE_SETTING_PROPERTIES_TITLE=Setting Properties:
-CONSOLE_STATE_BUNDLE_TITLE=State Bundle
-CONSOLE_THREADGROUP_TITLE=ThreadGroupType: Name: ParentGroup: MaxP: Threads:
-CONSOLE_THREADTYPE_TITLE=ThreadType: Name: ThreadGroup: Prio:
-CONSOLE_CANNOT_FIND_BUNDLE_ERROR=Cannot find bundle {0}
-CONSOLE_LISTENING_ON_PORT=Listening on port {0} ...
-STARTLEVEL_HELP_HEADING=Controlling Start Level
-STARTLEVEL_HELP_SL=display the start level for the specified bundle, or for the framework if no bundle specified
-STARTLEVEL_HELP_SETFWSL=set the framework start level
-STARTLEVEL_HELP_SETBSL=set the start level for the bundle(s)
-STARTLEVEL_HELP_SETIBSL=set the initial bundle start level
-STARTLEVEL_FRAMEWORK_ACTIVE_STARTLEVEL=Framework Active Start Level = {0}
-STARTLEVEL_NO_STARTLEVEL_GIVEN=No Start Level given.
-STARTLEVEL_NO_STARTLEVEL_OR_BUNDLE_GIVEN=No Bundle or Start Level given.
-STARTLEVEL_INITIAL_BUNDLE_STARTLEVEL=Initial Bundle Start Level = {0}
-STARTLEVEL_BUNDLE_STARTLEVEL=Bundle {0} Start Level = {1}
-STARTLEVEL_ARGUMENT_DESCRIPTION = <start level>
-STARTLEVEL_IDLOCATION_ARGUMENT_DESCRIPTION = <start level> (<id>|<location>)
-STARTLEVEL_POSITIVE_INTEGER=Startlevel must be a positive integer.
-CONSOLE_NAMED_CLASS_SPACE_MESSAGE=Named class space
-CONSOLE_PROVIDED_MESSAGE=[provided]
-CONSOLE_HOST_MESSAGE=Host bundles
-CONSOLE_NO_HOST_MESSAGE=No host bundles
-CONSOLE_FRAGMENT_MESSAGE=Fragment bundles
-CONSOLE_NO_FRAGMENT_MESSAGE=No fragment bundles
-CONSOLE_NO_NAMED_CLASS_SPACES_MESSAGE=No named class spaces
-CONSOLE_REQUIRED_BUNDLES_MESSAGE=Required bundles
-CONSOLE_NO_REQUIRED_BUNDLES_MESSAGE=No required bundles
-CONSOLE_REQUIRES_MESSAGE=[requires]
-CONSOLE_HELP_PROFILE_HEADING=Controlling the Profiling
-CONSOLE_HELP_PROFILELOG_DESCRIPTION=Display & flush the profile log messages
-CONSOLE_HELP_HELP_COMMAND_DESCRIPTION=Display help for the specified command
-CONSOLE_PROPS_COMMAND_DESCRIPTION=Display system properties
-CONSOLE_THREADS_COMMAND_DESCRIPTION=Display threads and thread groups
diff --git a/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/ConsoleMsg.java b/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/ConsoleMsg.java
deleted file mode 100644
index ac72bc22c..000000000
--- a/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/ConsoleMsg.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2011 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.osgi.framework.internal.core;
-
-import org.eclipse.osgi.util.NLS;
-
-public class ConsoleMsg extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.osgi.framework.internal.core.ConsoleMessages"; //$NON-NLS-1$
-
- public static String CONSOLE_LINES_TO_SCROLL_NEGATIVE_ERROR;
- public static String CONSOLE_NESTED_EXCEPTION;
- public static String CONSOLE_ERROR_READING_RESOURCE;
- public static String CONSOLE_RESOURCE_NOT_IN_BUNDLE;
- public static String CONSOLE_MORE;
- public static String CONSOLE_HELP_CONTROLLING_CONSOLE_HEADING;
- public static String CONSOLE_HELP_MORE;
- public static String CONSOLE_HELP_DISCONNECT;
- public static String CONSOLE_CONFIRM_MORE;
- public static String CONSOLE_CONFIRM_DISCONNECT;
- public static String CONSOLE_CONFIRM;
- public static String CONSOLE_CONFIRM_VALUES;
- public static String CONSOLE_Y;
- public static String CONSOLE_N;
- public static String CONSOLE_PROMPT_DEFAULT;
- public static String CONSOLE_INVALID_INPUT;
- public static String CONSOLE_TOO_MUCH_INVALID_INPUT;
- public static String CONSOLE_MORE_ENTER_LINES;
-
- public static String CONSOLE_LISTENING_ON_PORT;
- public static String CONSOLE_PROMPT;
-
- public static String CONSOLE_HELP_CONTROLLING_FRAMEWORK_HEADER;
- public static String CONSOLE_HELP_LAUNCH_COMMAND_DESCRIPTION;
- public static String CONSOLE_HELP_SHUTDOWN_COMMAND_DESCRIPTION;
- public static String CONSOLE_HELP_CLOSE_COMMAND_DESCRIPTION;
- public static String CONSOLE_HELP_EXIT_COMMAND_DESCRIPTION;
- public static String CONSOLE_HELP_GC_COMMAND_DESCRIPTION;
- public static String CONSOLE_HELP_INIT_COMMAND_DESCRIPTION;
- public static String CONSOLE_HELP_KEYVALUE_ARGUMENT_DESCRIPTION;
- public static String CONSOLE_HELP_SETPROP_COMMAND_DESCRIPTION;
- public static String CONSOLE_HELP_CONTROLLING_BUNDLES_HEADER;
- public static String CONSOLE_HELP_INSTALL_COMMAND_DESCRIPTION;
- public static String CONSOLE_HELP_UNINSTALL_COMMAND_DESCRIPTION;
- public static String CONSOLE_HELP_START_COMMAND_DESCRIPTION;
- public static String CONSOLE_HELP_STOP_COMMAND_DESCRIPTION;
- public static String CONSOLE_HELP_REFRESH_COMMAND_DESCRIPTION;
- public static String CONSOLE_HELP_DISPLAYING_STATUS_HEADER;
- public static String CONSOLE_HELP_STATUS_COMMAND_DESCRIPTION;
- public static String CONSOLE_HELP_STATE_ARGUMENT_DESCRIPTION;
- public static String CONSOLE_HELP_SS_COMMAND_DESCRIPTION;
- public static String CONSOLE_HELP_FILTER_ARGUMENT_DESCRIPTION;
- public static String CONSOLE_HELP_SERVICES_COMMAND_DESCRIPTION;
- public static String CONSOLE_HELP_PACKAGES_ARGUMENT_DESCRIPTION;
- public static String CONSOLE_HELP_PACKAGES_COMMAND_DESCRIPTION;
- public static String CONSOLE_HELP_BUNDLES_COMMAND_DESCRIPTION;
- public static String CONSOLE_HELP_IDLOCATION_ARGUMENT_DESCRIPTION;
- public static String CONSOLE_HELP_BUNDLE_COMMAND_DESCRIPTION;
- public static String CONSOLE_HELP_HEADERS_COMMAND_DESCRIPTION;
- public static String CONSOLE_HELP_EXTRAS_HEADER;
- public static String CONSOLE_HELP_COMMAND_ARGUMENT_DESCRIPTION;
- public static String CONSOLE_HELP_GETPROP_COMMAND_DESCRIPTION;
- public static String CONSOLE_HELP_GETPROP_ARGUMENT_DESCRIPTION;
- public static String CONSOLE_HELP_EXEC_COMMAND_DESCRIPTION;
- public static String CONSOLE_HELP_FORK_COMMAND_DESCRIPTION;
- public static String STARTLEVEL_HELP_HEADING;
- public static String CONSOLE_HELP_OPTIONAL_IDLOCATION_ARGUMENT_DESCRIPTION;
- public static String STARTLEVEL_HELP_SL;
- public static String STARTLEVEL_ARGUMENT_DESCRIPTION;
- public static String STARTLEVEL_HELP_SETFWSL;
- public static String STARTLEVEL_IDLOCATION_ARGUMENT_DESCRIPTION;
- public static String STARTLEVEL_HELP_SETBSL;
- public static String STARTLEVEL_HELP_SETIBSL;
- public static String CONSOLE_HELP_PROFILE_HEADING;
- public static String CONSOLE_HELP_PROFILELOG_DESCRIPTION;
- public static String CONSOLE_HELP_UPDATE_COMMAND_DESCRIPTION;
- public static String CONSOLE_HELP_HELP_COMMAND_DESCRIPTION;
-
- public static String CONSOLE_NO_BUNDLE_SPECIFIED_ERROR;
- public static String CONSOLE_NOTHING_TO_INSTALL_ERROR;
- public static String CONSOLE_BUNDLE_ID_MESSAGE;
- public static String CONSOLE_NO_INSTALLED_BUNDLES_ERROR;
- public static String CONSOLE_REGISTERED_SERVICES_MESSAGE;
- public static String CONSOLE_FRAMEWORK_IS_LAUNCHED_MESSAGE;
- public static String CONSOLE_FRAMEWORK_IS_SHUTDOWN_MESSAGE;
- public static String CONSOLE_ID;
- public static String CONSOLE_BUNDLE_LOCATION_MESSAGE;
- public static String CONSOLE_STATE_BUNDLE_FILE_NAME_HEADER;
- public static String CONSOLE_BUNDLES_USING_SERVICE_MESSAGE;
- public static String CONSOLE_NO_REGISTERED_SERVICES_MESSAGE;
- public static String CONSOLE_NO_BUNDLES_USING_SERVICE_MESSAGE;
- public static String CONSOLE_REGISTERED_BY_BUNDLE_MESSAGE;
- public static String CONSOLE_IMPORTS_MESSAGE;
- public static String CONSOLE_STALE_MESSAGE;
- public static String CONSOLE_NO_EXPORTED_PACKAGES_NO_PACKAGE_ADMIN_MESSAGE;
- public static String CONSOLE_NO_EXPORTED_PACKAGES_MESSAGE;
- public static String CONSOLE_REMOVAL_PENDING_MESSAGE;
- public static String CONSOLE_SERVICES_IN_USE_MESSAGE;
- public static String CONSOLE_NO_SERVICES_IN_USE_MESSAGE;
- public static String CONSOLE_ID_MESSAGE;
- public static String CONSOLE_STATUS_MESSAGE;
- public static String CONSOLE_DATA_ROOT_MESSAGE;
-
- public static String CONSOLE_IMPORTED_PACKAGES_MESSAGE;
- public static String CONSOLE_NO_IMPORTED_PACKAGES_MESSAGE;
- public static String CONSOLE_HOST_MESSAGE;
- public static String CONSOLE_EXPORTED_PACKAGES_MESSAGE;
- public static String CONSOLE_EXPORTED_REMOVAL_PENDING_MESSAGE;
- public static String CONSOLE_EXPORTED_MESSAGE;
- public static String CONSOLE_NO_HOST_MESSAGE;
- public static String CONSOLE_FRAGMENT_MESSAGE;
- public static String CONSOLE_NO_FRAGMENT_MESSAGE;
- public static String CONSOLE_NO_NAMED_CLASS_SPACES_MESSAGE;
- public static String CONSOLE_NAMED_CLASS_SPACE_MESSAGE;
- public static String CONSOLE_PROVIDED_MESSAGE;
- public static String CONSOLE_REQUIRED_BUNDLES_MESSAGE;
- public static String CONSOLE_NO_REQUIRED_BUNDLES_MESSAGE;
- public static String CONSOLE_TOTAL_MEMORY_MESSAGE;
- public static String CONSOLE_FREE_MEMORY_BEFORE_GARBAGE_COLLECTION_MESSAGE;
- public static String CONSOLE_FREE_MEMORY_AFTER_GARBAGE_COLLECTION_MESSAGE;
- public static String CONSOLE_MEMORY_GAINED_WITH_GARBAGE_COLLECTION_MESSAGE;
- public static String CONSOLE_FRAMEWORK_LAUNCHED_PLEASE_SHUTDOWN_MESSAGE;
- public static String CONSOLE_INVALID_BUNDLE_SPECIFICATION_ERROR;
- public static String CONSOLE_CAN_NOT_REFRESH_NO_PACKAGE_ADMIN_ERROR;
- public static String CONSOLE_NO_COMMAND_SPECIFIED_ERROR;
- public static String CONSOLE_STARTED_IN_MESSAGE;
- public static String CONSOLE_EXECUTED_RESULT_CODE_MESSAGE;
- public static String CONSOLE_BUNDLE_HEADERS_TITLE;
- public static String CONSOLE_SYSTEM_PROPERTIES_TITLE;
- public static String CONSOLE_NO_PARAMETERS_SPECIFIED_TITLE;
- public static String CONSOLE_SETTING_PROPERTIES_TITLE;
- public static String CONSOLE_STATE_BUNDLE_TITLE;
- public static String CONSOLE_THREADGROUP_TITLE;
- public static String CONSOLE_THREADTYPE_TITLE;
- public static String CONSOLE_REQUIRES_MESSAGE;
- public static String CONSOLE_CAN_NOT_USE_STARTLEVEL_NO_STARTLEVEL_SVC_ERROR;
- public static String CONSOLE_CANNOT_FIND_BUNDLE_ERROR;
- public static String CONSOLE_PROPS_COMMAND_DESCRIPTION;
- public static String CONSOLE_THREADS_COMMAND_DESCRIPTION;
-
- public static String STARTLEVEL_FRAMEWORK_ACTIVE_STARTLEVEL;
- public static String STARTLEVEL_BUNDLE_STARTLEVEL;
- public static String STARTLEVEL_NO_STARTLEVEL_GIVEN;
- public static String STARTLEVEL_NO_STARTLEVEL_OR_BUNDLE_GIVEN;
- public static String STARTLEVEL_INITIAL_BUNDLE_STARTLEVEL;
- public static String STARTLEVEL_POSITIVE_INTEGER;
-
- static {
- // initialize resource bundles
- NLS.initializeMessages(BUNDLE_NAME, ConsoleMsg.class);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandInterpreter.java b/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandInterpreter.java
deleted file mode 100644
index c23e1feac..000000000
--- a/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandInterpreter.java
+++ /dev/null
@@ -1,599 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2011 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.osgi.framework.internal.core;
-
-import java.io.*;
-import java.lang.reflect.*;
-import java.net.URL;
-import java.util.*;
-import org.eclipse.osgi.framework.console.CommandInterpreter;
-import org.eclipse.osgi.framework.console.CommandProvider;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.Bundle;
-
-/**
- * This class knows how to parse and execute the command line arguments to the FrameworkConsole.
- * It attempts to pass the command to each registered CommandProvider until it finds one
- * that knows what to do with it.
- *
- * FrameworkCommandInterpreter provides support for the "More" command which allows the operator to configure
- * the number of lines to display before being prompted to continue.
- *
- * FrameworkCommandInterpreter provides several print methods which handle the "More" command.
- */
-public class FrameworkCommandInterpreter implements CommandInterpreter {
- private static final String WS_DELIM = " \t\n\r\f"; //$NON-NLS-1$
-
- /** The command line in StringTokenizer form */
- private StringTokenizer tok;
- /** The active CommandProviders */
- private CommandProvider[] commandProviders;
- /** The FrameworkConsole */
- private FrameworkConsole con;
- /** The stream to send output to */
- private PrintWriter out;
-
- /** Strings used to format other strings */
- private String tab = "\t"; //$NON-NLS-1$
- private String newline = "\r\n"; //$NON-NLS-1$
- private boolean firstCommand = true;
-
- /**
- * The maximum number of lines to print without user prompt.
- * 0 means no user prompt is required, the window is scrollable.
- */
- protected static int maxLineCount;
-
- /** The number of lines printed without user prompt.*/
- protected int currentLineCount;
-
- /**
- * The constructor. It turns the cmdline string into a StringTokenizer and remembers
- * the input parms.
- */
- public FrameworkCommandInterpreter(String cmdline, CommandProvider[] commandProviders, FrameworkConsole con) {
- tok = new StringTokenizer(cmdline);
- this.commandProviders = commandProviders;
- this.con = con;
- this.out = con.getWriter();
- }
-
- /**
- Get the next argument in the input.
-
- E.g. if the commandline is hello world, the _hello method
- will get "world" as the first argument.
-
- @return A string containing the next argument on the command line
- */
- public String nextArgument() {
- if (tok == null || !tok.hasMoreElements())
- return null;
- return consumeQuotes(tok.nextToken());
- }
-
- private String consumeQuotes(String arg) {
- if (!(arg.startsWith("\"") || arg.startsWith("'"))) //$NON-NLS-1$//$NON-NLS-2$
- return arg;
- String quote = arg.substring(0, 1);
- if (arg.endsWith(quote)) {
- if (arg.length() >= 2)
- // strip the beginning and ending quotes
- return arg.substring(1, arg.length() - 1);
- // single quote case; return empty string
- return ""; //$NON-NLS-1$
- }
-
- try {
- arg = arg.substring(1) + tok.nextToken(quote);
- } catch (NoSuchElementException e) {
- // should not happen
- printStackTrace(e);
- return ""; //$NON-NLS-1$
- }
- try {
- // skip to next whitespace separated token
- tok.nextToken(WS_DELIM);
- } catch (NoSuchElementException e) {
- // this is ok we are at the end
- }
- return arg;
- }
-
- /**
- Execute a command line as if it came from the end user.
-
- Searches the list of command providers using introspection until
- it finds one that contains a matching method. It searches for a method
- with the name "_cmd" where cmd is the command to execute. For example,
- for a command of "launch" execute searches for a method called "_launch".
-
- @param cmd The name of the command to execute.
- @return The object returned by the method executed.
- */
- public Object execute(String cmd) {
- if (!firstCommand)
- return innerExecute(cmd);
- firstCommand = false;
- resetLineCount();
- Object retval = null;
- // handle "more" command here
- if (cmd.equalsIgnoreCase("more")) { //$NON-NLS-1$
- try {
- _more();
- } catch (Exception e) {
- printStackTrace(e);
- }
- return retval;
- }
- // handle "disconnect" command here
- if (cmd.equalsIgnoreCase("disconnect")) { //$NON-NLS-1$
- try {
- _disconnect();
- } catch (Exception e) {
- printStackTrace(e);
- }
- return retval;
- }
-
- // handle "help" command here
- if (cmd.equalsIgnoreCase("help") && !tok.hasMoreElements()) { //$NON-NLS-1$
- displayAllHelp();
- return retval;
- }
-
- Class<?>[] parameterTypes = new Class[] {CommandInterpreter.class};
- Object[] parameters = new Object[] {this};
- boolean executed = false;
- int size = commandProviders.length;
-
- if (cmd.equalsIgnoreCase("help") && tok.hasMoreElements()) { //$NON-NLS-1$
- String commandName = nextArgument();
-
- String builtinHelp = getHelp(commandName);
- if (builtinHelp != null) {
- print(builtinHelp);
- return builtinHelp;
- }
- for (int i = 0; i < size; i++) {
- // re-create the StringTokenizer for the call of each CommandProvider - there may be help commands in more than one CommandProvider
- tok = new StringTokenizer(commandName);
- boolean isException = false;
- Object target = commandProviders[i];
- Method method = null;
- try {
- method = target.getClass().getMethod("_" + cmd, parameterTypes); //$NON-NLS-1$
- retval = method.invoke(target, parameters);
- } catch (NoSuchMethodException e) {
- // keep going - maybe another command provider will provide help <command> method
- isException = true;
- } catch (InvocationTargetException e) {
- // keep going - maybe another command provider will provide help <command> method
- printStackTrace(e.getTargetException());
- isException = true;
- } catch (Exception ee) {
- printStackTrace(ee);
- }
-
- if (retval != null) {
- if (retval instanceof Boolean) {
- executed = executed || ((Boolean) retval).booleanValue();
- } else if (retval instanceof String) {
- print(retval);
- return retval;
- } else {
- // this could happen if a CommandProvider provides an arbitrary help command;
- // since there is no way to determine if this CommandProvider provides the search command,
- // we should continue with the other CommandProvider
- executed = true;
- }
- } else {
- // if the return value is null, but there was no exception assume that a help method was called
- executed = executed || !isException;
- }
- }
- } else {
- for (int i = 0; !executed && (i < size); i++) {
- try {
- Object target = commandProviders[i];
- Method method = target.getClass().getMethod("_" + cmd, parameterTypes); //$NON-NLS-1$
- retval = method.invoke(target, parameters);
- executed = true; // stop after the command has been found
- } catch (NoSuchMethodException ite) {
- // keep going - maybe another command provider will be able to execute this command
- } catch (InvocationTargetException ite) {
- executed = true; // don't want to keep trying - we found the method but got an error
- printStackTrace(ite.getTargetException());
- } catch (Exception ee) {
- executed = true; // don't want to keep trying - we got an error we don't understand
- printStackTrace(ee);
- }
- }
- }
-
- // if no command was found to execute, display help for all registered command providers
- if (!executed) {
- displayAllHelp();
- }
- return retval;
- }
-
- private void displayAllHelp() {
- int size = commandProviders.length;
- for (int i = 0; i < size; i++) {
- try {
- CommandProvider commandProvider = commandProviders[i];
- out.print(commandProvider.getHelp());
- out.flush();
- } catch (Exception ee) {
- printStackTrace(ee);
- }
- }
- // call help for the more command provided by this class
- out.print(getHelp(null));
- out.flush();
- }
-
- private Object innerExecute(String cmd) {
- if (cmd != null && cmd.length() > 0) {
- CommandInterpreter intcp = new FrameworkCommandInterpreter(cmd, commandProviders, con);
- String command = intcp.nextArgument();
- if (command != null)
- return intcp.execute(command);
- }
- return null;
- }
-
- /**
- * Answers the number of lines output to the console
- * window should scroll without user interaction.
- *
- * @return The number of lines to scroll.
- */
- private int getMaximumLinesToScroll() {
- return maxLineCount;
- }
-
- /**
- * Sets the number of lines output to the console
- * window will scroll without user interaction.
- * <p>
- * Note that this number does not include the line
- * for the 'more' prompt itself.
- * <p>
- * If the number of lines is 0 then no 'more' prompt
- * is disabled.
- *
- * @param lines the number of lines to scroll
- */
- private void setMaximumLinesToScroll(int lines) {
- if (lines < 0) {
- throw new IllegalArgumentException(ConsoleMsg.CONSOLE_LINES_TO_SCROLL_NEGATIVE_ERROR);
- }
-
- maxLineCount = lines;
- }
-
- /**
- * Resets the line counter for the 'more' prompt.
- */
- private void resetLineCount() {
- currentLineCount = 0;
- }
-
- /**
- * Prints a string to the output medium (appended with newline character).
- * <p>
- * This method does not increment the line counter for the 'more' prompt.
- *
- * @param o the string to be printed
- */
- private void printline(Object o) {
- print(o + newline);
- }
-
- /**
- * Prints an object to the outputstream
- *
- * @param o the object to be printed
- */
- public void print(Object o) {
- synchronized (out) {
- check4More();
- out.print(o);
- out.flush();
- }
- }
-
- /**
- * Prints a empty line to the outputstream
- */
- public void println() {
- println(""); //$NON-NLS-1$
- }
-
- /**
- * Print a stack trace including nested exceptions.
- * @param t The offending exception
- */
- public void printStackTrace(Throwable t) {
- t.printStackTrace(out);
-
- Method[] methods = t.getClass().getMethods();
-
- int size = methods.length;
- Class<Throwable> throwable = Throwable.class;
-
- for (int i = 0; i < size; i++) {
- Method method = methods[i];
-
- if (Modifier.isPublic(method.getModifiers()) && method.getName().startsWith("get") && throwable.isAssignableFrom(method.getReturnType()) && (method.getParameterTypes().length == 0)) { //$NON-NLS-1$
- try {
- Throwable nested = (Throwable) method.invoke(t, (Object[]) null);
-
- if ((nested != null) && (nested != t)) {
- out.println(ConsoleMsg.CONSOLE_NESTED_EXCEPTION);
- printStackTrace(nested);
- }
- } catch (IllegalAccessException e) {
- // nothing
- } catch (InvocationTargetException e) {
- // nothing
- }
- }
- }
- }
-
- /**
- * Prints an object to the output medium (appended with newline character).
- * <p>
- * If running on the target environment, the user is prompted with '--more'
- * if more than the configured number of lines have been printed without user prompt.
- * This enables the user of the program to have control over scrolling.
- * <p>
- * For this to work properly you should not embed "\n" etc. into the string.
- *
- * @param o the object to be printed
- */
- public void println(Object o) {
- if (o == null) {
- return;
- }
- synchronized (out) {
- check4More();
- printline(o);
- currentLineCount++;
- currentLineCount += o.toString().length() / 80;
- }
- }
-
- /**
- * Prints the given dictionary sorted by keys.
- *
- * @param dic the dictionary to print
- * @param title the header to print above the key/value pairs
- */
- public void printDictionary(Dictionary<?, ?> dic, String title) {
- if (dic == null)
- return;
-
- int count = dic.size();
- String[] keys = new String[count];
- Enumeration<?> keysEnum = dic.keys();
- int i = 0;
- while (keysEnum.hasMoreElements()) {
- keys[i++] = (String) keysEnum.nextElement();
- }
- Util.sortByString(keys);
-
- if (title != null) {
- println(title);
- }
- for (i = 0; i < count; i++) {
- println(" " + keys[i] + " = " + dic.get(keys[i])); //$NON-NLS-1$//$NON-NLS-2$
- }
- println();
- }
-
- /**
- * Prints the given bundle resource if it exists
- *
- * @param bundle the bundle containing the resource
- * @param resource the resource to print
- */
- public void printBundleResource(Bundle bundle, String resource) {
- URL entry = null;
- entry = bundle.getEntry(resource);
- if (entry != null) {
- try {
- println(resource);
- InputStream in = entry.openStream();
- byte[] buffer = new byte[1024];
- int read = 0;
- try {
- while ((read = in.read(buffer)) != -1)
- print(new String(buffer, 0, read));
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException e) {
- // nothing
- }
- }
- }
- } catch (Exception e) {
- System.err.println(NLS.bind(ConsoleMsg.CONSOLE_ERROR_READING_RESOURCE, resource));
- }
- } else {
- println(NLS.bind(ConsoleMsg.CONSOLE_RESOURCE_NOT_IN_BUNDLE, resource, bundle.toString()));
- }
- }
-
- /**
- * Displays the more... prompt if the max line count has been reached
- * and waits for the operator to hit enter.
- *
- */
- private void check4More() {
- int max = getMaximumLinesToScroll();
- if (max > 0) {
- if (currentLineCount >= max) {
- out.print(ConsoleMsg.CONSOLE_MORE);
- out.flush();
- con.getInput(); // wait for user entry
- resetLineCount(); //Reset the line counter for the 'more' prompt
- }
- }
- }
-
- /**
- Answer a string (may be as many lines as you like) with help
- texts that explain the command.
- */
- public String getHelp(String commandName) {
- boolean all = commandName == null;
- StringBuffer help = new StringBuffer(256);
- if (all) {
- help.append(ConsoleMsg.CONSOLE_HELP_CONTROLLING_CONSOLE_HEADING);
- help.append(newline);
- }
- if (all || "more".equals(commandName)) { //$NON-NLS-1$
- help.append(tab);
- help.append("more - "); //$NON-NLS-1$
- help.append(ConsoleMsg.CONSOLE_HELP_MORE);
- help.append(newline);
- }
- if (all || "disconnect".equals(commandName)) { //$NON-NLS-1$
- help.append(tab);
- help.append("disconnect - "); //$NON-NLS-1$
- help.append(ConsoleMsg.CONSOLE_HELP_DISCONNECT);
- help.append(newline);
- }
- if (all || "help".equals(commandName)) { //$NON-NLS-1$
- help.append(tab);
- help.append("help <commmand> - "); //$NON-NLS-1$
- help.append(ConsoleMsg.CONSOLE_HELP_HELP_COMMAND_DESCRIPTION);
- help.append(newline);
- }
- return help.length() == 0 ? null : help.toString();
- }
-
- /**
- * Toggles the use of the more prompt for displayed output.
- *
- */
- public void _more() throws Exception {
- if (confirm(ConsoleMsg.CONSOLE_CONFIRM_MORE, true)) {
- int lines = prompt(newline + ConsoleMsg.CONSOLE_MORE_ENTER_LINES, 24);
- setMaximumLinesToScroll(lines);
- } else {
- setMaximumLinesToScroll(0);
- }
- }
-
- private void _disconnect() throws Exception {
- if (confirm(ConsoleMsg.CONSOLE_CONFIRM_DISCONNECT, true)) {
- con.shutdown();
- }
- }
-
- /**
- * Prompts the user for confirmation.
- *
- * @param string the message to present to the user to confirm
- * @param defaultAnswer the default result
- *
- * @return <code>true</code> if the user confirms; <code>false</code> otherwise.
- */
- protected boolean confirm(String string, boolean defaultAnswer) {
- synchronized (out) {
- if (string.length() > 0) {
- print(string);
- } else {
- print(ConsoleMsg.CONSOLE_CONFIRM);
- }
- print(" (" + ConsoleMsg.CONSOLE_CONFIRM_VALUES); //$NON-NLS-1$
- if (defaultAnswer) {
- print(ConsoleMsg.CONSOLE_Y + ") "); //$NON-NLS-1$
- } else {
- print(ConsoleMsg.CONSOLE_N + ") "); //$NON-NLS-1$
- }
- }
- String input = con.getInput();
- resetLineCount();
- if (input.length() == 0) {
- return defaultAnswer;
- }
- return input.toLowerCase().charAt(0) == ConsoleMsg.CONSOLE_Y.charAt(0);
- }
-
- /**
- * Prompts the user for input from the input medium providing a default value.
- *
- * @param string the message to present to the user
- * @param defaultAnswer the string to use as a default return value
- *
- * @return The user provided string or the defaultAnswer,
- * if user provided string was empty.
- */
- protected String prompt(String string, String defaultAnswer) {
- if (string.length() > 0) {
- if (defaultAnswer.length() > 0) {
- StringBuffer buf = new StringBuffer(256);
- buf.append(string);
- buf.append(" "); //$NON-NLS-1$
- buf.append(ConsoleMsg.CONSOLE_PROMPT_DEFAULT);
- buf.append("="); //$NON-NLS-1$
- buf.append(defaultAnswer);
- buf.append(") "); //$NON-NLS-1$
- print(buf.toString());
- } else {
- print(string);
- }
- }
- String input = con.getInput();
- resetLineCount();
- if (input.length() > 0) {
- return input;
- }
- return defaultAnswer;
- }
-
- /**
- * Prompts the user for input of a positive integer.
- *
- * @param string the message to present to the user
- * @param defaultAnswer the integer to use as a default return value
- *
- * @return The user provided integer or the defaultAnswer,
- * if user provided an empty input.
- */
- protected int prompt(String string, int defaultAnswer) {
- Integer i = new Integer(defaultAnswer);
- int answer;
- for (int j = 0; j < 3; j++) {
- String s = prompt(string, i.toString());
- try {
- answer = Integer.parseInt(s);
- if (answer >= 0) {
- return answer;
- }
- } catch (NumberFormatException e) {
- // nothing
- }
- println(ConsoleMsg.CONSOLE_INVALID_INPUT);
- }
- println(ConsoleMsg.CONSOLE_TOO_MUCH_INVALID_INPUT);
- return defaultAnswer;
- }
-}
diff --git a/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandProvider.java b/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandProvider.java
deleted file mode 100644
index 20036db97..000000000
--- a/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandProvider.java
+++ /dev/null
@@ -1,1997 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2011 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.osgi.framework.internal.core;
-
-import java.io.*;
-import java.lang.reflect.Field;
-import java.net.URL;
-import java.security.ProtectionDomain;
-import java.util.*;
-import java.util.Map.Entry;
-import org.eclipse.osgi.framework.console.CommandInterpreter;
-import org.eclipse.osgi.framework.console.CommandProvider;
-import org.eclipse.osgi.internal.permadmin.SecurityAdmin;
-import org.eclipse.osgi.internal.profile.Profile;
-import org.eclipse.osgi.service.resolver.*;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.*;
-import org.osgi.service.condpermadmin.ConditionalPermissionInfo;
-import org.osgi.service.condpermadmin.ConditionalPermissionUpdate;
-import org.osgi.service.packageadmin.PackageAdmin;
-import org.osgi.service.packageadmin.RequiredBundle;
-import org.osgi.service.startlevel.StartLevel;
-
-/**
- * This class provides methods to execute commands from the command line. It registers
- * itself as a CommandProvider so it can be invoked by a CommandInterpreter. The
- * FrameworkCommandProvider registers itself with the highest ranking (Integer.MAXVALUE) so it will always be
- * called first. Other CommandProviders should register with lower rankings.
- *
- * The commands provided by this class are:
- ---Controlling the OSGi framework---
- close - shutdown and exit
- exit - exit immediately (System.exit)
- gc - perform a garbage collection
- init - uninstall all bundles
- launch - start the Service Management Framework
- setprop <key>=<value> - set the OSGI property
- shutdown - shutdown the Service Management Framework
- ---Controlliing Bundles---
- install <url> {s[tart]} - install and optionally start bundle from the given URL
- refresh (<id>|<location>) - refresh the packages of the specified bundles
- start (<id>|<location>) - start the specified bundle(s)
- stop (<id>|<location>) - stop the specified bundle(s)
- uninstall (<id>|<location>) - uninstall the specified bundle(s)
- update (<id>|<location>|<*>) - update the specified bundle(s)
- ---Displaying Status---
- bundle (<id>|<location>) - display details for the specified bundle(s)
- bundles - display details for all installed bundles
- headers (<id>|<location>) - print bundle headers
- packages {<pkgname>|<id>|<location>} - display imported/exported package details
- props - display System properties
- services {filter} - display registered service details. Examples for [filter]: (objectClass=com.xyz.Person); (&(objectClass=com.xyz.Person)(sn=Jensen)); passing only com.xyz.Person is a shortcut for (objectClass=com.xyz.Person). The filter syntax specification is available at http://www.ietf.org/rfc/rfc1960.txt
- ss - display installed bundles (short status)
- status - display installed bundles and registered services
- threads - display threads and thread groups
- ---Extras---
- exec <command> - execute a command in a separate process and wait
- fork <command> - execute a command in a separate process
- getprop <name> - Displays the system properties with the given name, or all of them.
- ---Controlling StartLevel---
- sl {(<id>|<location>)} - display the start level for the specified bundle, or for the framework if no bundle specified
- setfwsl <start level> - set the framework start level
- setbsl <start level> (<id>|<location>) - set the start level for the bundle(s)
- setibsl <start level> - set the initial bundle start level
- ---Getting Help---
- help <command> - Display help for the specified command
-
- *
- * There is a method for each command which is named '_'+method. The methods are
- * invoked by a CommandInterpreter's execute method.
- */
-public class FrameworkCommandProvider implements CommandProvider, SynchronousBundleListener {
-
- /** An instance of the OSGi framework */
- private final Framework framework;
- /** The system bundle context */
- private final BundleContext context;
- /** The start level implementation */
- private final StartLevelManager slImpl;
- private final SecurityAdmin securityAdmin;
- private ServiceRegistration<?> providerReg;
-
- /** Strings used to format other strings */
- private final static String tab = "\t"; //$NON-NLS-1$
- private final static String newline = "\r\n"; //$NON-NLS-1$
-
- /** this list contains the bundles known to be lazily awaiting activation */
- private final List<Bundle> lazyActivation = new ArrayList<Bundle>();
-
- /** this map contains the mapping between the command name and its description and eventually arguments.*/
- private Map<String, String[]> commandsHelp = null;
- /** this map contains the mapping between the command groups and the names of the commands in each group*/
- private Map<String, String[]> commandGroups = null;
-
- /**
- * Constructor.
- *
- * initialize must be called after creating this object.
- *
- * @param framework The current instance of the framework
- */
- public FrameworkCommandProvider(Framework framework) {
- this.framework = framework;
- context = framework.systemBundle.getContext();
- slImpl = framework.startLevelManager;
- securityAdmin = framework.securityAdmin;
- }
-
- /**
- * Starts this CommandProvider.
- *
- * Registers this object as a CommandProvider with the highest ranking possible.
- * Adds this object as a SynchronousBundleListener.
- */
- void start() {
- Dictionary<String, Object> props = new Hashtable<String, Object>();
- props.put(Constants.SERVICE_RANKING, new Integer(Integer.MAX_VALUE));
- providerReg = context.registerService(CommandProvider.class.getName(), this, props);
- context.addBundleListener(this);
- }
-
- void stop() {
- context.removeBundleListener(this);
- if (providerReg != null)
- providerReg.unregister();
- }
-
- /**
- Answer a string (may be as many lines as you like) with help
- texts that explain the command. This getHelp() method uses the
- ConsoleMsg class to obtain the correct NLS data to display to the user.
-
- @return The help string
- */
- public String getHelp() {
- return getHelp(null);
- }
-
- /* This method either returns the help message for a particular command,
- * or returns the help messages for all commands (if commandName is not specified)*/
- private String getHelp(String commandName) {
- StringBuffer help = new StringBuffer(1024);
-
- if (commandsHelp == null) {
- initializeCommandsHelp();
- }
-
- if (commandGroups == null) {
- initializeCommandGroups();
- }
-
- if (commandName != null) {
- if (commandsHelp.containsKey(commandName)) {
- addCommand(commandName, commandsHelp.get(commandName), help);
- }
- return help.toString();
- }
-
- for (Entry<String, String[]> groupEntry : commandGroups.entrySet()) {
- addHeader(groupEntry.getKey(), help);
- for (String command : groupEntry.getValue()) {
- addCommand(command, commandsHelp.get(command), help);
- }
- }
-
- return help.toString();
- }
-
- private void initializeCommandsHelp() {
- commandsHelp = new HashMap<String, String[]>();
- // add help for commands for controlling the framework
- commandsHelp.put("launch", new String[] {ConsoleMsg.CONSOLE_HELP_LAUNCH_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("shutdown", new String[] {ConsoleMsg.CONSOLE_HELP_SHUTDOWN_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("close", new String[] {ConsoleMsg.CONSOLE_HELP_CLOSE_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("exit", new String[] {ConsoleMsg.CONSOLE_HELP_EXIT_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("init", new String[] {ConsoleMsg.CONSOLE_HELP_INIT_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("setprop", new String[] {ConsoleMsg.CONSOLE_HELP_KEYVALUE_ARGUMENT_DESCRIPTION, ConsoleMsg.CONSOLE_HELP_SETPROP_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("setp", new String[] {ConsoleMsg.CONSOLE_HELP_KEYVALUE_ARGUMENT_DESCRIPTION, ConsoleMsg.CONSOLE_HELP_SETPROP_COMMAND_DESCRIPTION}); //$NON-NLS-1$
-
- // add help for commands for controlling bundles
- commandsHelp.put("install", new String[] {ConsoleMsg.CONSOLE_HELP_INSTALL_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("i", new String[] {ConsoleMsg.CONSOLE_HELP_INSTALL_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("uninstall", new String[] {ConsoleMsg.CONSOLE_HELP_UNINSTALL_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("un", new String[] {ConsoleMsg.CONSOLE_HELP_UNINSTALL_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("start", new String[] {ConsoleMsg.CONSOLE_HELP_START_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("sta", new String[] {ConsoleMsg.CONSOLE_HELP_START_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("stop", new String[] {ConsoleMsg.CONSOLE_HELP_STOP_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("sto", new String[] {ConsoleMsg.CONSOLE_HELP_STOP_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("refresh", new String[] {ConsoleMsg.CONSOLE_HELP_REFRESH_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("r", new String[] {ConsoleMsg.CONSOLE_HELP_REFRESH_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("update", new String[] {ConsoleMsg.CONSOLE_HELP_UPDATE_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("up", new String[] {ConsoleMsg.CONSOLE_HELP_UPDATE_COMMAND_DESCRIPTION}); //$NON-NLS-1$
-
- // add help for commands for displaying status
- commandsHelp.put("status", new String[] {ConsoleMsg.CONSOLE_HELP_STATE_ARGUMENT_DESCRIPTION, ConsoleMsg.CONSOLE_HELP_STATUS_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("s", new String[] {ConsoleMsg.CONSOLE_HELP_STATE_ARGUMENT_DESCRIPTION, ConsoleMsg.CONSOLE_HELP_STATUS_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("ss", new String[] {ConsoleMsg.CONSOLE_HELP_STATE_ARGUMENT_DESCRIPTION, ConsoleMsg.CONSOLE_HELP_SS_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("services", new String[] {ConsoleMsg.CONSOLE_HELP_FILTER_ARGUMENT_DESCRIPTION, ConsoleMsg.CONSOLE_HELP_SERVICES_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("packages", new String[] {ConsoleMsg.CONSOLE_HELP_PACKAGES_ARGUMENT_DESCRIPTION, ConsoleMsg.CONSOLE_HELP_PACKAGES_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("p", new String[] {ConsoleMsg.CONSOLE_HELP_PACKAGES_ARGUMENT_DESCRIPTION, ConsoleMsg.CONSOLE_HELP_PACKAGES_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("bundles", new String[] {ConsoleMsg.CONSOLE_HELP_STATE_ARGUMENT_DESCRIPTION, ConsoleMsg.CONSOLE_HELP_BUNDLES_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("bundle", new String[] {ConsoleMsg.CONSOLE_HELP_IDLOCATION_ARGUMENT_DESCRIPTION, ConsoleMsg.CONSOLE_HELP_BUNDLE_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("b", new String[] {ConsoleMsg.CONSOLE_HELP_IDLOCATION_ARGUMENT_DESCRIPTION, ConsoleMsg.CONSOLE_HELP_BUNDLE_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("headers", new String[] {ConsoleMsg.CONSOLE_HELP_IDLOCATION_ARGUMENT_DESCRIPTION, ConsoleMsg.CONSOLE_HELP_HEADERS_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("h", new String[] {ConsoleMsg.CONSOLE_HELP_IDLOCATION_ARGUMENT_DESCRIPTION, ConsoleMsg.CONSOLE_HELP_HEADERS_COMMAND_DESCRIPTION}); //$NON-NLS-1$
-
- // add help for extra commands
- commandsHelp.put("exec", new String[] {ConsoleMsg.CONSOLE_HELP_COMMAND_ARGUMENT_DESCRIPTION, ConsoleMsg.CONSOLE_HELP_EXEC_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("fork", new String[] {ConsoleMsg.CONSOLE_HELP_COMMAND_ARGUMENT_DESCRIPTION, ConsoleMsg.CONSOLE_HELP_FORK_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("gc", new String[] {ConsoleMsg.CONSOLE_HELP_GC_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("getprop", new String[] {ConsoleMsg.CONSOLE_HELP_GETPROP_ARGUMENT_DESCRIPTION, ConsoleMsg.CONSOLE_HELP_GETPROP_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("props", new String[] {ConsoleMsg.CONSOLE_PROPS_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("pr", new String[] {ConsoleMsg.CONSOLE_PROPS_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("threads", new String[] {ConsoleMsg.CONSOLE_THREADS_COMMAND_DESCRIPTION}); //$NON-NLS-1$
- commandsHelp.put("t", new String[] {ConsoleMsg.CONSOLE_THREADS_COMMAND_DESCRIPTION}); //$NON-NLS-1$
-
- // add help for startlevel commands
- commandsHelp.put("sl", new String[] {ConsoleMsg.CONSOLE_HELP_OPTIONAL_IDLOCATION_ARGUMENT_DESCRIPTION, ConsoleMsg.STARTLEVEL_HELP_SL}); //$NON-NLS-1$
- commandsHelp.put("setfwsl", new String[] {ConsoleMsg.STARTLEVEL_ARGUMENT_DESCRIPTION, ConsoleMsg.STARTLEVEL_HELP_SETFWSL}); //$NON-NLS-1$
- commandsHelp.put("setbsl", new String[] {ConsoleMsg.STARTLEVEL_IDLOCATION_ARGUMENT_DESCRIPTION, ConsoleMsg.STARTLEVEL_HELP_SETBSL}); //$NON-NLS-1$
- commandsHelp.put("setibsl", new String[] {ConsoleMsg.STARTLEVEL_ARGUMENT_DESCRIPTION, ConsoleMsg.STARTLEVEL_HELP_SETIBSL}); //$NON-NLS-1$
-
- // add help for profilelog command
- commandsHelp.put("profilelog", new String[] {ConsoleMsg.CONSOLE_HELP_PROFILELOG_DESCRIPTION}); //$NON-NLS-1$
- }
-
- private void initializeCommandGroups() {
- commandGroups = new LinkedHashMap<String, String[]>();
- commandGroups.put(ConsoleMsg.CONSOLE_HELP_CONTROLLING_FRAMEWORK_HEADER, new String[] {"launch", "shutdown", "close", "exit", "init", "setprop"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- commandGroups.put(ConsoleMsg.CONSOLE_HELP_CONTROLLING_BUNDLES_HEADER, new String[] {"install", "uninstall", "start", "stop", "refresh", "update"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- commandGroups.put(ConsoleMsg.CONSOLE_HELP_DISPLAYING_STATUS_HEADER, new String[] {"status", "ss", "services", "packages", "bundles", "bundle", "headers"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- commandGroups.put(ConsoleMsg.CONSOLE_HELP_EXTRAS_HEADER, new String[] {"exec", "fork", "gc", "getprop", "props", "threads"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- commandGroups.put(ConsoleMsg.STARTLEVEL_HELP_HEADING, new String[] {"sl", "setfwsl", "setbsl", "setibsl"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- commandGroups.put(ConsoleMsg.CONSOLE_HELP_PROFILE_HEADING, new String[] {"profilelog"}); //$NON-NLS-1$
- }
-
- /** Private helper method for getHelp. Formats the help headers. */
- private void addHeader(String header, StringBuffer help) {
- help.append("---"); //$NON-NLS-1$
- help.append(header);
- help.append("---"); //$NON-NLS-1$
- help.append(newline);
- }
-
- /** Private helper method for getHelp. Formats the command descriptions. */
- private void addCommand(String command, String description, StringBuffer help) {
- help.append(tab);
- help.append(command);
- help.append(" - "); //$NON-NLS-1$
- help.append(description);
- help.append(newline);
- }
-
- /** Private helper method for getHelp. Formats the command descriptions with command arguments. */
- private void addCommand(String command, String parameters, String description, StringBuffer help) {
- help.append(tab);
- help.append(command);
- help.append(" "); //$NON-NLS-1$
- help.append(parameters);
- help.append(" - "); //$NON-NLS-1$
- help.append(description);
- help.append(newline);
- }
-
- /** Private helper method for getHelp. According to its arguments chooses which one of the above addCommand methods to use. */
- private void addCommand(String command, String[] attributes, StringBuffer help) {
- if (attributes.length == 1) {
- addCommand(command, attributes[0], help);
- } else if (attributes.length == 2) {
- addCommand(command, attributes[0], attributes[1], help);
- }
- }
-
- /**
- * Handle the exit command. Exit immediately (System.exit)
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _exit(CommandInterpreter intp) throws Exception {
- intp.println();
- System.exit(0);
- }
-
- /**
- * Handle the launch command. Start the OSGi framework.
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _launch(CommandInterpreter intp) throws Exception {
- framework.launch();
- }
-
- /**
- * Handle the shutdown command. Shutdown the OSGi framework.
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _shutdown(CommandInterpreter intp) throws Exception {
- framework.shutdown(FrameworkEvent.STOPPED);
- }
-
- /**
- * Handle the start command's abbreviation. Invoke _start()
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _sta(CommandInterpreter intp) throws Exception {
- _start(intp);
- }
-
- /**
- * Handle the start command. Start the specified bundle(s).
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _start(CommandInterpreter intp) throws Exception {
- String nextArg = intp.nextArgument();
- if (nextArg == null) {
- intp.println(ConsoleMsg.CONSOLE_NO_BUNDLE_SPECIFIED_ERROR);
- }
- while (nextArg != null) {
- AbstractBundle bundle = getBundleFromToken(intp, nextArg, true);
- if (bundle != null) {
- bundle.start();
- }
- nextArg = intp.nextArgument();
- }
- }
-
- /**
- * Handle the stop command's abbreviation. Invoke _stop()
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _sto(CommandInterpreter intp) throws Exception {
- _stop(intp);
- }
-
- /**
- * Handle the stop command. Stop the specified bundle(s).
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _stop(CommandInterpreter intp) throws Exception {
- String nextArg = intp.nextArgument();
- if (nextArg == null) {
- intp.println(ConsoleMsg.CONSOLE_NO_BUNDLE_SPECIFIED_ERROR);
- }
- while (nextArg != null) {
- AbstractBundle bundle = getBundleFromToken(intp, nextArg, true);
- if (bundle != null) {
- bundle.stop();
- }
- nextArg = intp.nextArgument();
- }
- }
-
- /**
- * Handle the install command's abbreviation. Invoke _install()
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _i(CommandInterpreter intp) throws Exception {
- _install(intp);
- }
-
- /**
- * Handle the install command. Install and optionally start bundle from the given URL\r\n"
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _install(CommandInterpreter intp) throws Exception {
- String url = intp.nextArgument();
- if (url == null) {
- intp.println(ConsoleMsg.CONSOLE_NOTHING_TO_INSTALL_ERROR);
- } else {
- AbstractBundle bundle = (AbstractBundle) context.installBundle(url);
- intp.print(ConsoleMsg.CONSOLE_BUNDLE_ID_MESSAGE);
- intp.println(new Long(bundle.getBundleId()));
-
- String nextArg = intp.nextArgument();
- if (nextArg != null) {
- String start = nextArg.toLowerCase();
-
- if (matchCommand("start", start, 1)) { //$NON-NLS-1$
- bundle.start();
- }
- }
- }
-
- }
-
- private static boolean matchCommand(String command, String input, int minLength) {
- if (minLength <= 0)
- minLength = command.length();
- int length = input.length();
- if (minLength > length)
- length = minLength;
- return (command.regionMatches(0, input, 0, length));
- }
-
- /**
- * Handle the update command's abbreviation. Invoke _update()
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _up(CommandInterpreter intp) throws Exception {
- _update(intp);
- }
-
- /**
- * Handle the update command. Update the specified bundle(s).
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _update(CommandInterpreter intp) throws Exception {
- String token = intp.nextArgument();
- if (token == null) {
- intp.println(ConsoleMsg.CONSOLE_NO_BUNDLE_SPECIFIED_ERROR);
- }
- while (token != null) {
-
- if ("*".equals(token)) { //$NON-NLS-1$
- AbstractBundle[] bundles = (AbstractBundle[]) context.getBundles();
-
- int size = bundles.length;
-
- if (size > 0) {
- for (int i = 0; i < size; i++) {
- AbstractBundle bundle = bundles[i];
-
- if (bundle.getBundleId() != 0) {
- try {
- bundle.update();
- } catch (BundleException e) {
- intp.printStackTrace(e);
- }
- }
- }
- } else {
- intp.println(ConsoleMsg.CONSOLE_NO_INSTALLED_BUNDLES_ERROR);
- }
- } else {
- AbstractBundle bundle = getBundleFromToken(intp, token, true);
- if (bundle != null) {
- String source = intp.nextArgument();
- try {
- if (source != null) {
- bundle.update(new URL(source).openStream());
- } else {
- bundle.update();
- }
- } catch (BundleException e) {
- intp.printStackTrace(e);
- }
- }
- }
- token = intp.nextArgument();
- }
- }
-
- /**
- * Handle the uninstall command's abbreviation. Invoke _uninstall()
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _un(CommandInterpreter intp) throws Exception {
- _uninstall(intp);
- }
-
- /**
- * Handle the uninstall command. Uninstall the specified bundle(s).
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _uninstall(CommandInterpreter intp) throws Exception {
- String nextArg = intp.nextArgument();
- if (nextArg == null) {
- intp.println(ConsoleMsg.CONSOLE_NO_BUNDLE_SPECIFIED_ERROR);
- }
- while (nextArg != null) {
- AbstractBundle bundle = getBundleFromToken(intp, nextArg, true);
- if (bundle != null) {
- bundle.uninstall();
- }
- nextArg = intp.nextArgument();
- }
- }
-
- /**
- * Handle the status command's abbreviation. Invoke _status()
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _s(CommandInterpreter intp) throws Exception {
- _status(intp);
- }
-
- private Object[] processOption(CommandInterpreter intp) {
- String option = intp.nextArgument();
- String filteredName = null;
- int stateFilter = -1;
- if (option != null && option.equals("-s")) { //$NON-NLS-1$
- String searchedState = intp.nextArgument();
- if (searchedState == null)
- searchedState = ""; //$NON-NLS-1$
- StringTokenizer tokens = new StringTokenizer(searchedState, ","); //$NON-NLS-1$
- while (tokens.hasMoreElements()) {
- String desiredState = (String) tokens.nextElement();
- Field match = null;
- try {
- match = Bundle.class.getField(desiredState.toUpperCase());
- if (stateFilter == -1)
- stateFilter = 0;
- stateFilter |= match.getInt(match);
- } catch (NoSuchFieldException e) {
- intp.println(ConsoleMsg.CONSOLE_INVALID_INPUT + ": " + desiredState); //$NON-NLS-1$
- return null;
- } catch (IllegalAccessException e) {
- intp.println(ConsoleMsg.CONSOLE_INVALID_INPUT + ": " + desiredState); //$NON-NLS-1$
- return null;
- }
- }
- } else {
- filteredName = option;
- }
- String tmp = intp.nextArgument();
- if (tmp != null)
- filteredName = tmp;
- return new Object[] {filteredName, new Integer(stateFilter)};
- }
-
- /**
- * Handle the status command. Display installed bundles and registered services.
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _status(CommandInterpreter intp) throws Exception {
- if (framework.isActive()) {
- intp.println(ConsoleMsg.CONSOLE_FRAMEWORK_IS_LAUNCHED_MESSAGE);
- } else {
- intp.println(ConsoleMsg.CONSOLE_FRAMEWORK_IS_SHUTDOWN_MESSAGE);
- }
- intp.println();
-
- Object[] options = processOption(intp);
- if (options == null)
- return;
-
- AbstractBundle[] bundles = (AbstractBundle[]) context.getBundles();
- int size = bundles.length;
-
- if (size == 0) {
- intp.println(ConsoleMsg.CONSOLE_NO_INSTALLED_BUNDLES_ERROR);
- return;
- }
- intp.print(ConsoleMsg.CONSOLE_ID);
- intp.print(tab);
- intp.println(ConsoleMsg.CONSOLE_BUNDLE_LOCATION_MESSAGE);
- intp.println(ConsoleMsg.CONSOLE_STATE_BUNDLE_FILE_NAME_HEADER);
- for (int i = 0; i < size; i++) {
- AbstractBundle bundle = bundles[i];
- if (!match(bundle, (String) options[0], ((Integer) options[1]).intValue()))
- continue;
- intp.print(new Long(bundle.getBundleId()));
- intp.print(tab);
- intp.println(bundle.getLocation());
- intp.print(" "); //$NON-NLS-1$
- intp.print(getStateName(bundle));
- intp.println(bundle.bundledata);
- }
-
- ServiceReference<?>[] services = context.getServiceReferences((String) null, (String) null);
- if (services != null) {
- intp.println(ConsoleMsg.CONSOLE_REGISTERED_SERVICES_MESSAGE);
- size = services.length;
- for (int i = 0; i < size; i++) {
- intp.println(services[i]);
- }
- }
- }
-
- /**
- * Handle the services command's abbreviation. Invoke _services()
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _se(CommandInterpreter intp) throws Exception {
- _services(intp);
- }
-
- /**
- * Handle the services command. Display registered service details.
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _services(CommandInterpreter intp) throws Exception {
- String filter = null;
-
- String nextArg = intp.nextArgument();
- if (nextArg != null) {
- StringBuffer buf = new StringBuffer();
- while (nextArg != null) {
- buf.append(' ');
- buf.append(nextArg);
- nextArg = intp.nextArgument();
- }
- filter = buf.toString();
- }
-
- InvalidSyntaxException originalException = null;
- ServiceReference<?>[] services = null;
-
- try {
- services = context.getServiceReferences((String) null, filter);
- } catch (InvalidSyntaxException e) {
- originalException = e;
- }
-
- if (filter != null) {
- filter = filter.trim();
- }
- // If the filter is invalid and does not start with a bracket, probably the argument was the name of an interface.
- // Try to construct an object class filter with this argument, and if still invalid - throw the original InvalidSyntaxException
- if (originalException != null && !filter.startsWith("(") && filter.indexOf(' ') < 0) { //$NON-NLS-1$
- try {
- filter = "(" + Constants.OBJECTCLASS + "=" + filter + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- services = context.getServiceReferences((String) null, filter);
- } catch (InvalidSyntaxException e) {
- throw originalException;
- }
- } else if (originalException != null) {
- throw originalException;
- }
-
- if (services != null) {
- int size = services.length;
- if (size > 0) {
- for (int j = 0; j < size; j++) {
- ServiceReference<?> service = services[j];
- intp.println(service);
- intp.print(" "); //$NON-NLS-1$
- intp.print(ConsoleMsg.CONSOLE_REGISTERED_BY_BUNDLE_MESSAGE);
- intp.print(" "); //$NON-NLS-1$
- intp.println(service.getBundle());
- Bundle[] users = service.getUsingBundles();
- if (users != null) {
- intp.print(" "); //$NON-NLS-1$
- intp.println(ConsoleMsg.CONSOLE_BUNDLES_USING_SERVICE_MESSAGE);
- for (int k = 0; k < users.length; k++) {
- intp.print(" "); //$NON-NLS-1$
- intp.println(users[k]);
- }
- } else {
- intp.print(" "); //$NON-NLS-1$
- intp.println(ConsoleMsg.CONSOLE_NO_BUNDLES_USING_SERVICE_MESSAGE);
- }
- }
- return;
- }
- }
- intp.println(ConsoleMsg.CONSOLE_NO_REGISTERED_SERVICES_MESSAGE);
- }
-
- /**
- * Handle the packages command's abbreviation. Invoke _packages()
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _p(CommandInterpreter intp) throws Exception {
- _packages(intp);
- }
-
- /**
- * Handle the packages command. Display imported/exported package details.
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _packages(CommandInterpreter intp) throws Exception {
- org.osgi.framework.Bundle bundle = null;
-
- String token = intp.nextArgument();
- if (token != null) {
- bundle = getBundleFromToken(intp, token, false);
- }
-
- ServiceReference<?> packageAdminRef = context.getServiceReference("org.osgi.service.packageadmin.PackageAdmin"); //$NON-NLS-1$
- if (packageAdminRef != null) {
- PackageAdmin packageAdmin = (PackageAdmin) context.getService(packageAdminRef);
- if (packageAdmin != null) {
- try {
- org.osgi.service.packageadmin.ExportedPackage[] packages = null;
-
- if (token != null)
- packages = packageAdmin.getExportedPackages(token);
- if (packages == null)
- packages = packageAdmin.getExportedPackages(bundle);
-
- if (packages == null) {
- intp.println(ConsoleMsg.CONSOLE_NO_EXPORTED_PACKAGES_MESSAGE);
- } else {
- for (int i = 0; i < packages.length; i++) {
- org.osgi.service.packageadmin.ExportedPackage pkg = packages[i];
- intp.print(pkg);
-
- boolean removalPending = pkg.isRemovalPending();
- if (removalPending) {
- intp.print("("); //$NON-NLS-1$
- intp.print(ConsoleMsg.CONSOLE_REMOVAL_PENDING_MESSAGE);
- intp.println(")"); //$NON-NLS-1$
- }
-
- org.osgi.framework.Bundle exporter = pkg.getExportingBundle();
- if (exporter != null) {
- intp.print("<"); //$NON-NLS-1$
- intp.print(exporter);
- intp.println(">"); //$NON-NLS-1$
-
- org.osgi.framework.Bundle[] importers = pkg.getImportingBundles();
- for (int j = 0; j < importers.length; j++) {
- intp.print(" "); //$NON-NLS-1$
- intp.print(importers[j]);
- intp.print(" "); //$NON-NLS-1$
- intp.println(ConsoleMsg.CONSOLE_IMPORTS_MESSAGE);
- }
- } else {
- intp.print("<"); //$NON-NLS-1$
- intp.print(ConsoleMsg.CONSOLE_STALE_MESSAGE);
- intp.println(">"); //$NON-NLS-1$
- }
-
- }
- }
- } finally {
- context.ungetService(packageAdminRef);
- }
- }
- } else {
- intp.println(ConsoleMsg.CONSOLE_NO_EXPORTED_PACKAGES_NO_PACKAGE_ADMIN_MESSAGE);
- }
- }
-
- /**
- * Handle the bundles command. Display details for all installed bundles.
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _bundles(CommandInterpreter intp) throws Exception {
- Object[] options = processOption(intp);
- if (options == null)
- return;
-
- AbstractBundle[] bundles = (AbstractBundle[]) context.getBundles();
- int size = bundles.length;
-
- if (size == 0) {
- intp.println(ConsoleMsg.CONSOLE_NO_INSTALLED_BUNDLES_ERROR);
- return;
- }
-
- for (int i = 0; i < size; i++) {
- AbstractBundle bundle = bundles[i];
- if (!match(bundle, (String) options[0], ((Integer) options[1]).intValue()))
- continue;
- long id = bundle.getBundleId();
- intp.println(bundle);
- intp.print(" "); //$NON-NLS-1$
- intp.print(NLS.bind(ConsoleMsg.CONSOLE_ID_MESSAGE, String.valueOf(id)));
- intp.print(", "); //$NON-NLS-1$
- intp.print(NLS.bind(ConsoleMsg.CONSOLE_STATUS_MESSAGE, getStateName(bundle)));
- if (id != 0) {
- File dataRoot = framework.getDataFile(bundle, ""); //$NON-NLS-1$
-
- String root = (dataRoot == null) ? null : dataRoot.getAbsolutePath();
-
- intp.print(NLS.bind(ConsoleMsg.CONSOLE_DATA_ROOT_MESSAGE, root));
- } else {
- intp.println();
- }
-
- ServiceReference<?>[] services = bundle.getRegisteredServices();
- if (services != null) {
- intp.print(" "); //$NON-NLS-1$
- intp.println(ConsoleMsg.CONSOLE_REGISTERED_SERVICES_MESSAGE);
- for (int j = 0; j < services.length; j++) {
- intp.print(" "); //$NON-NLS-1$
- intp.println(services[j]);
- }
- } else {
- intp.print(" "); //$NON-NLS-1$
- intp.println(ConsoleMsg.CONSOLE_NO_REGISTERED_SERVICES_MESSAGE);
- }
-
- services = bundle.getServicesInUse();
- if (services != null) {
- intp.print(" "); //$NON-NLS-1$
- intp.println(ConsoleMsg.CONSOLE_SERVICES_IN_USE_MESSAGE);
- for (int j = 0; j < services.length; j++) {
- intp.print(" "); //$NON-NLS-1$
- intp.println(services[j]);
- }
- } else {
- intp.print(" "); //$NON-NLS-1$
- intp.println(ConsoleMsg.CONSOLE_NO_SERVICES_IN_USE_MESSAGE);
- }
- }
- }
-
- /**
- * Handle the bundle command's abbreviation. Invoke _bundle()
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _b(CommandInterpreter intp) throws Exception {
- _bundle(intp);
- }
-
- /**
- * Handle the bundle command. Display details for the specified bundle(s).
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _bundle(CommandInterpreter intp) throws Exception {
- String nextArg = intp.nextArgument();
- if (nextArg == null) {
- intp.println(ConsoleMsg.CONSOLE_NO_BUNDLE_SPECIFIED_ERROR);
- }
- while (nextArg != null) {
- AbstractBundle bundle = getBundleFromToken(intp, nextArg, true);
- if (bundle != null) {
- long id = bundle.getBundleId();
- intp.println(bundle);
- intp.print(" "); //$NON-NLS-1$
- intp.print(NLS.bind(ConsoleMsg.CONSOLE_ID_MESSAGE, String.valueOf(id)));
- intp.print(", "); //$NON-NLS-1$
- intp.print(NLS.bind(ConsoleMsg.CONSOLE_STATUS_MESSAGE, getStateName(bundle)));
- if (id != 0) {
- File dataRoot = framework.getDataFile(bundle, ""); //$NON-NLS-1$
-
- String root = (dataRoot == null) ? null : dataRoot.getAbsolutePath();
-
- intp.print(NLS.bind(ConsoleMsg.CONSOLE_DATA_ROOT_MESSAGE, root));
- intp.println();
- } else {
- intp.println();
- }
-
- ServiceReference<?>[] services = bundle.getRegisteredServices();
- if (services != null) {
- intp.print(" "); //$NON-NLS-1$
- intp.println(ConsoleMsg.CONSOLE_REGISTERED_SERVICES_MESSAGE);
- for (int j = 0; j < services.length; j++) {
- intp.print(" "); //$NON-NLS-1$
- intp.println(services[j]);
- }
- } else {
- intp.print(" "); //$NON-NLS-1$
- intp.println(ConsoleMsg.CONSOLE_NO_REGISTERED_SERVICES_MESSAGE);
- }
-
- services = bundle.getServicesInUse();
- if (services != null) {
- intp.print(" "); //$NON-NLS-1$
- intp.println(ConsoleMsg.CONSOLE_SERVICES_IN_USE_MESSAGE);
- for (int j = 0; j < services.length; j++) {
- intp.print(" "); //$NON-NLS-1$
- intp.println(services[j]);
- }
- } else {
- intp.print(" "); //$NON-NLS-1$
- intp.println(ConsoleMsg.CONSOLE_NO_SERVICES_IN_USE_MESSAGE);
- }
-
- ServiceReference<?> packageAdminRef = context.getServiceReference("org.osgi.service.packageadmin.PackageAdmin"); //$NON-NLS-1$
- if (packageAdminRef != null) {
- BundleDescription desc = bundle.getBundleDescription();
- if (desc != null) {
- boolean title = true;
- try {
- ExportPackageDescription[] exports = desc.getSelectedExports();
- if (exports == null || exports.length == 0) {
- intp.print(" "); //$NON-NLS-1$
- intp.println(ConsoleMsg.CONSOLE_NO_EXPORTED_PACKAGES_MESSAGE);
- } else {
- title = true;
-
- for (int i = 0; i < exports.length; i++) {
- if (title) {
- intp.print(" "); //$NON-NLS-1$
- intp.println(ConsoleMsg.CONSOLE_EXPORTED_PACKAGES_MESSAGE);
- title = false;
- }
- intp.print(" "); //$NON-NLS-1$
- intp.print(exports[i].getName());
- intp.print("; version=\""); //$NON-NLS-1$
- intp.print(exports[i].getVersion());
- intp.print("\""); //$NON-NLS-1$
- if (desc.isRemovalPending()) {
- intp.println(ConsoleMsg.CONSOLE_EXPORTED_REMOVAL_PENDING_MESSAGE);
- } else {
- intp.println(ConsoleMsg.CONSOLE_EXPORTED_MESSAGE);
- }
- }
-
- if (title) {
- intp.print(" "); //$NON-NLS-1$
- intp.println(ConsoleMsg.CONSOLE_NO_EXPORTED_PACKAGES_MESSAGE);
- }
- }
- title = true;
- if (desc != null) {
- List<ImportPackageSpecification> fragmentsImportPackages = new ArrayList<ImportPackageSpecification>();
-
- // Get bundle' fragments imports
- BundleDescription[] fragments = desc.getFragments();
- for (int i = 0; i < fragments.length; i++) {
- ImportPackageSpecification[] fragmentImports = fragments[i].getImportPackages();
- for (int j = 0; j < fragmentImports.length; j++) {
- fragmentsImportPackages.add(fragmentImports[j]);
- }
- }
-
- // Get all bundle imports
- ImportPackageSpecification[] importPackages;
- if (fragmentsImportPackages.size() > 0) {
- ImportPackageSpecification[] directImportPackages = desc.getImportPackages();
- importPackages = new ImportPackageSpecification[directImportPackages.length + fragmentsImportPackages.size()];
-
- for (int i = 0; i < directImportPackages.length; i++) {
- importPackages[i] = directImportPackages[i];
- }
-
- int offset = directImportPackages.length;
- for (int i = 0; i < fragmentsImportPackages.size(); i++) {
- importPackages[offset + i] = fragmentsImportPackages.get(i);
- }
- } else {
- importPackages = desc.getImportPackages();
- }
-
- // Get all resolved imports
- ExportPackageDescription[] imports = null;
- imports = desc.getContainingState().getStateHelper().getVisiblePackages(desc, StateHelper.VISIBLE_INCLUDE_EE_PACKAGES | StateHelper.VISIBLE_INCLUDE_ALL_HOST_WIRES);
-
- // Get the unresolved optional and dynamic imports
- List<ImportPackageSpecification> unresolvedImports = new ArrayList<ImportPackageSpecification>();
-
- for (int i = 0; i < importPackages.length; i++) {
- if (importPackages[i].getDirective(Constants.RESOLUTION_DIRECTIVE).equals(ImportPackageSpecification.RESOLUTION_OPTIONAL)) {
- if (importPackages[i].getSupplier() == null) {
- unresolvedImports.add(importPackages[i]);
- }
- } else if (importPackages[i].getDirective(org.osgi.framework.Constants.RESOLUTION_DIRECTIVE).equals(ImportPackageSpecification.RESOLUTION_DYNAMIC)) {
- boolean isResolvable = false;
-
- // Check if the dynamic import can be resolved by any of the wired imports,
- // and if not - add it to the list of unresolved imports
- for (int j = 0; j < imports.length; j++) {
- if (importPackages[i].isSatisfiedBy(imports[j])) {
- isResolvable = true;
- }
- }
-
- if (isResolvable == false) {
- unresolvedImports.add(importPackages[i]);
- }
- }
- }
-
- title = printImportedPackages(imports, intp, title);
-
- if (desc.isResolved() && (unresolvedImports.isEmpty() == false)) {
- printUnwiredDynamicImports(unresolvedImports, intp);
- title = false;
- }
- }
-
- if (title) {
- intp.print(" "); //$NON-NLS-1$
- intp.println(ConsoleMsg.CONSOLE_NO_IMPORTED_PACKAGES_MESSAGE);
- }
-
- PackageAdmin packageAdmin = (PackageAdmin) context.getService(packageAdminRef);
- if (packageAdmin != null) {
- intp.print(" "); //$NON-NLS-1$
- if ((packageAdmin.getBundleType(bundle) & PackageAdmin.BUNDLE_TYPE_FRAGMENT) > 0) {
- org.osgi.framework.Bundle[] hosts = packageAdmin.getHosts(bundle);
- if (hosts != null) {
- intp.println(ConsoleMsg.CONSOLE_HOST_MESSAGE);
- for (int i = 0; i < hosts.length; i++) {
- intp.print(" "); //$NON-NLS-1$
- intp.println(hosts[i]);
- }
- } else {
- intp.println(ConsoleMsg.CONSOLE_NO_HOST_MESSAGE);
- }
- } else {
- org.osgi.framework.Bundle[] fragments = packageAdmin.getFragments(bundle);
- if (fragments != null) {
- intp.println(ConsoleMsg.CONSOLE_FRAGMENT_MESSAGE);
- for (int i = 0; i < fragments.length; i++) {
- intp.print(" "); //$NON-NLS-1$
- intp.println(fragments[i]);
- }
- } else {
- intp.println(ConsoleMsg.CONSOLE_NO_FRAGMENT_MESSAGE);
- }
- }
-
- RequiredBundle[] requiredBundles = packageAdmin.getRequiredBundles(null);
- RequiredBundle requiredBundle = null;
- if (requiredBundles != null) {
- for (int i = 0; i < requiredBundles.length; i++) {
- if (requiredBundles[i].getBundle() == bundle) {
- requiredBundle = requiredBundles[i];
- break;
- }
- }
- }
-
- if (requiredBundle == null) {
- intp.print(" "); //$NON-NLS-1$
- intp.println(ConsoleMsg.CONSOLE_NO_NAMED_CLASS_SPACES_MESSAGE);
- } else {
- intp.print(" "); //$NON-NLS-1$
- intp.println(ConsoleMsg.CONSOLE_NAMED_CLASS_SPACE_MESSAGE);
- intp.print(" "); //$NON-NLS-1$
- intp.print(requiredBundle);
- if (requiredBundle.isRemovalPending()) {
- intp.println(ConsoleMsg.CONSOLE_REMOVAL_PENDING_MESSAGE);
- } else {
- intp.println(ConsoleMsg.CONSOLE_PROVIDED_MESSAGE);
- }
- }
- title = true;
- for (int i = 0; i < requiredBundles.length; i++) {
- if (requiredBundles[i] == requiredBundle)
- continue;
-
- org.osgi.framework.Bundle[] depBundles = requiredBundles[i].getRequiringBundles();
- if (depBundles == null)
- continue;
-
- for (int j = 0; j < depBundles.length; j++) {
- if (depBundles[j] == bundle) {
- if (title) {
- intp.print(" "); //$NON-NLS-1$
- intp.println(ConsoleMsg.CONSOLE_REQUIRED_BUNDLES_MESSAGE);
- title = false;
- }
- intp.print(" "); //$NON-NLS-1$
- intp.print(requiredBundles[i]);
-
- org.osgi.framework.Bundle provider = requiredBundles[i].getBundle();
- intp.print("<"); //$NON-NLS-1$
- intp.print(provider);
- intp.println(">"); //$NON-NLS-1$
- }
- }
- }
- if (title) {
- intp.print(" "); //$NON-NLS-1$
- intp.println(ConsoleMsg.CONSOLE_NO_REQUIRED_BUNDLES_MESSAGE);
- }
-
- }
- } finally {
- context.ungetService(packageAdminRef);
- }
- }
- } else {
- intp.print(" "); //$NON-NLS-1$
- intp.println(ConsoleMsg.CONSOLE_NO_EXPORTED_PACKAGES_NO_PACKAGE_ADMIN_MESSAGE);
- }
-
- SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- ProtectionDomain domain = bundle.getProtectionDomain();
-
- intp.println(domain);
- }
- }
- nextArg = intp.nextArgument();
- }
- }
-
- private boolean printImportedPackages(ExportPackageDescription[] importedPkgs, CommandInterpreter intp, boolean title) {
- for (int i = 0; i < importedPkgs.length; i++) {
- if (title) {
- intp.print(" "); //$NON-NLS-1$
- intp.println(ConsoleMsg.CONSOLE_IMPORTED_PACKAGES_MESSAGE);
- title = false;
- }
- intp.print(" "); //$NON-NLS-1$
- intp.print(importedPkgs[i].getName());
- intp.print("; version=\""); //$NON-NLS-1$
- intp.print(importedPkgs[i].getVersion());
- intp.print("\""); //$NON-NLS-1$
- Bundle exporter = context.getBundle(importedPkgs[i].getSupplier().getBundleId());
- if (exporter != null) {
- intp.print("<"); //$NON-NLS-1$
- intp.print(exporter);
- intp.println(">"); //$NON-NLS-1$
- } else {
- intp.print("<"); //$NON-NLS-1$
- intp.print(ConsoleMsg.CONSOLE_STALE_MESSAGE);
- intp.println(">"); //$NON-NLS-1$
- }
- }
- return title;
- }
-
- private void printUnwiredDynamicImports(List<ImportPackageSpecification> dynamicImports, CommandInterpreter intp) {
- for (int i = 0; i < dynamicImports.size(); i++) {
- ImportPackageSpecification importPackage = dynamicImports.get(i);
- intp.print(" "); //$NON-NLS-1$
- intp.print(importPackage.getName());
- intp.print("; version=\""); //$NON-NLS-1$
- intp.print(importPackage.getVersionRange());
- intp.print("\""); //$NON-NLS-1$
- intp.print("<"); //$NON-NLS-1$
- intp.print("unwired"); //$NON-NLS-1$
- intp.print(">"); //$NON-NLS-1$
- intp.print("<"); //$NON-NLS-1$
- intp.print(importPackage.getDirective(org.osgi.framework.Constants.RESOLUTION_DIRECTIVE));
- intp.println(">"); //$NON-NLS-1$
- }
- }
-
- /**
- * Handle the gc command. Perform a garbage collection.
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _gc(CommandInterpreter intp) throws Exception {
- long before = Runtime.getRuntime().freeMemory();
-
- /* Let the finilizer finish its work and remove objects from its queue */
- System.gc(); /* asyncronous garbage collector might already run */
- System.gc(); /* to make sure it does a full gc call it twice */
- System.runFinalization();
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- // do nothing
- }
-
- long after = Runtime.getRuntime().freeMemory();
- intp.print(ConsoleMsg.CONSOLE_TOTAL_MEMORY_MESSAGE);
- intp.println(String.valueOf(Runtime.getRuntime().totalMemory()));
- intp.print(ConsoleMsg.CONSOLE_FREE_MEMORY_BEFORE_GARBAGE_COLLECTION_MESSAGE);
- intp.println(String.valueOf(before));
- intp.print(ConsoleMsg.CONSOLE_FREE_MEMORY_AFTER_GARBAGE_COLLECTION_MESSAGE);
- intp.println(String.valueOf(after));
- intp.print(ConsoleMsg.CONSOLE_MEMORY_GAINED_WITH_GARBAGE_COLLECTION_MESSAGE);
- intp.println(String.valueOf(after - before));
- }
-
- /**
- * Handle the init command. Uninstall all bundles.
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- @SuppressWarnings("deprecation")
- public void _init(CommandInterpreter intp) throws Exception {
- if (framework.isActive()) {
- intp.print(newline);
- intp.println(ConsoleMsg.CONSOLE_FRAMEWORK_LAUNCHED_PLEASE_SHUTDOWN_MESSAGE);
- return;
- }
-
- AbstractBundle[] bundles = (AbstractBundle[]) context.getBundles();
-
- int size = bundles.length;
-
- if (size > 0) {
- for (int i = 0; i < size; i++) {
- AbstractBundle bundle = bundles[i];
-
- if (bundle.getBundleId() != 0) {
- try {
- bundle.uninstall();
- } catch (BundleException e) {
- intp.printStackTrace(e);
- }
- }
- }
- } else {
- intp.println(ConsoleMsg.CONSOLE_NO_INSTALLED_BUNDLES_ERROR);
- }
- if (securityAdmin != null) {
- // clear the permissions from permission admin
- securityAdmin.setDefaultPermissions(null);
- String[] permLocations = securityAdmin.getLocations();
- if (permLocations != null)
- for (int i = 0; i < permLocations.length; i++)
- securityAdmin.setPermissions(permLocations[i], null);
- ConditionalPermissionUpdate update = securityAdmin.newConditionalPermissionUpdate();
- update.getConditionalPermissionInfos().clear();
- update.commit();
- }
- // clear the permissions from conditional permission admin
- if (securityAdmin != null)
- for (Enumeration<ConditionalPermissionInfo> infos = securityAdmin.getConditionalPermissionInfos(); infos.hasMoreElements();)
- infos.nextElement().delete();
- }
-
- /**
- * Handle the close command. Shutdown and exit.
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _close(CommandInterpreter intp) throws Exception {
- intp.println();
- framework.close();
- System.exit(0);
- }
-
- /**
- * Handle the refresh command's abbreviation. Invoke _refresh()
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _r(CommandInterpreter intp) throws Exception {
- _refresh(intp);
- }
-
- /**
- * Handle the refresh command. Refresh the packages of the specified bundles.
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _refresh(CommandInterpreter intp) throws Exception {
- ServiceReference<?> packageAdminRef = context.getServiceReference("org.osgi.service.packageadmin.PackageAdmin"); //$NON-NLS-1$
- if (packageAdminRef != null) {
- org.osgi.service.packageadmin.PackageAdmin packageAdmin = (org.osgi.service.packageadmin.PackageAdmin) context.getService(packageAdminRef);
- if (packageAdmin != null) {
- try {
- Bundle[] refresh = null;
-
- String token = intp.nextArgument();
- if (token != null) {
- List<Bundle> bundles = new ArrayList<Bundle>();
-
- while (token != null) {
- AbstractBundle bundle = getBundleFromToken(intp, token, true);
-
- if (bundle != null) {
- bundles.add(bundle);
- }
- token = intp.nextArgument();
- }
-
- int size = bundles.size();
-
- if (size == 0) {
- intp.println(ConsoleMsg.CONSOLE_INVALID_BUNDLE_SPECIFICATION_ERROR);
- return;
- }
-
- refresh = new Bundle[size];
- bundles.toArray(refresh);
- }
-
- packageAdmin.refreshPackages(refresh);
- } finally {
- context.ungetService(packageAdminRef);
- }
- }
- } else {
- intp.println(ConsoleMsg.CONSOLE_CAN_NOT_REFRESH_NO_PACKAGE_ADMIN_ERROR);
- }
- }
-
- /**
- * Executes the given system command in a separate system process
- * and waits for it to finish.
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _exec(CommandInterpreter intp) throws Exception {
- String command = intp.nextArgument();
- if (command == null) {
- intp.println(ConsoleMsg.CONSOLE_NO_COMMAND_SPECIFIED_ERROR);
- return;
- }
-
- Process p = Runtime.getRuntime().exec(command);
-
- intp.println(NLS.bind(ConsoleMsg.CONSOLE_STARTED_IN_MESSAGE, command, String.valueOf(p)));
- int result = p.waitFor();
- intp.println(NLS.bind(ConsoleMsg.CONSOLE_EXECUTED_RESULT_CODE_MESSAGE, command, String.valueOf(result)));
- }
-
- /**
- * Executes the given system command in a separate system process. It does
- * not wait for a result.
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _fork(CommandInterpreter intp) throws Exception {
- String command = intp.nextArgument();
- if (command == null) {
- intp.println(ConsoleMsg.CONSOLE_NO_COMMAND_SPECIFIED_ERROR);
- return;
- }
-
- Process p = Runtime.getRuntime().exec(command);
- intp.println(NLS.bind(ConsoleMsg.CONSOLE_STARTED_IN_MESSAGE, command, String.valueOf(p)));
- }
-
- /**
- * Handle the headers command's abbreviation. Invoke _headers()
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _h(CommandInterpreter intp) throws Exception {
- _headers(intp);
- }
-
- /**
- * Handle the headers command. Display headers for the specified bundle(s).
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _headers(CommandInterpreter intp) throws Exception {
-
- String nextArg = intp.nextArgument();
- if (nextArg == null) {
- intp.println(ConsoleMsg.CONSOLE_NO_BUNDLE_SPECIFIED_ERROR);
- }
- while (nextArg != null) {
- AbstractBundle bundle = getBundleFromToken(intp, nextArg, true);
- if (bundle != null) {
- intp.printDictionary(bundle.getHeaders(), ConsoleMsg.CONSOLE_BUNDLE_HEADERS_TITLE);
- }
- nextArg = intp.nextArgument();
- }
- }
-
- /**
- * Handles the props command's abbreviation. Invokes _props()
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _pr(CommandInterpreter intp) throws Exception {
- _props(intp);
- }
-
- /**
- * Handles the _props command. Prints the system properties sorted.
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _props(CommandInterpreter intp) throws Exception {
- intp.printDictionary(FrameworkProperties.getProperties(), ConsoleMsg.CONSOLE_SYSTEM_PROPERTIES_TITLE);
- }
-
- /**
- * Handles the setprop command's abbreviation. Invokes _setprop()
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _setp(CommandInterpreter intp) throws Exception {
- _setprop(intp);
- }
-
- /**
- * Handles the setprop command. Sets the CDS property in the given argument.
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _setprop(CommandInterpreter intp) throws Exception {
- String argument = intp.nextArgument();
- if (argument == null) {
- intp.println(ConsoleMsg.CONSOLE_NO_PARAMETERS_SPECIFIED_TITLE);
- _props(intp);
- } else {
- InputStream in = new ByteArrayInputStream(argument.getBytes());
- try {
- Properties sysprops = FrameworkProperties.getProperties();
- Properties newprops = new Properties();
- newprops.load(in);
- intp.println(ConsoleMsg.CONSOLE_SETTING_PROPERTIES_TITLE);
- Enumeration<?> keys = newprops.propertyNames();
- while (keys.hasMoreElements()) {
- String key = (String) keys.nextElement();
- String value = (String) newprops.get(key);
- sysprops.put(key, value);
- intp.println(tab + key + " = " + value); //$NON-NLS-1$
- }
- } catch (IOException e) {
- // ignore
- } finally {
- try {
- in.close();
- } catch (IOException e) {
- // ignore
- }
- }
- }
- }
-
- /**
- * Prints the short version of the status.
- * For the long version use "status".
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _ss(CommandInterpreter intp) throws Exception {
- if (framework.isActive()) {
- intp.println();
- intp.println(ConsoleMsg.CONSOLE_FRAMEWORK_IS_LAUNCHED_MESSAGE);
- } else {
- intp.println();
- intp.println(ConsoleMsg.CONSOLE_FRAMEWORK_IS_SHUTDOWN_MESSAGE);
- }
-
- Object[] options = processOption(intp);
- if (options == null)
- return;
-
- AbstractBundle[] bundles = (AbstractBundle[]) context.getBundles();
- if (bundles.length == 0) {
- intp.println(ConsoleMsg.CONSOLE_NO_INSTALLED_BUNDLES_ERROR);
- } else {
- intp.print(newline);
- intp.print(ConsoleMsg.CONSOLE_ID);
- intp.print(tab);
- intp.println(ConsoleMsg.CONSOLE_STATE_BUNDLE_TITLE);
- for (int i = 0; i < bundles.length; i++) {
- AbstractBundle b = bundles[i];
- if (!match(b, (String) options[0], ((Integer) options[1]).intValue()))
- continue;
- String label = b.getSymbolicName();
- if (label == null || label.length() == 0)
- label = b.toString();
- else
- label = label + "_" + b.getVersion(); //$NON-NLS-1$
- intp.println(b.getBundleId() + "\t" + getStateName(b) + label); //$NON-NLS-1$
- if (b.isFragment()) {
- Bundle[] hosts = b.getHosts();
- if (hosts != null)
- for (int j = 0; j < hosts.length; j++)
- intp.println("\t Master=" + hosts[j].getBundleId()); //$NON-NLS-1$
- } else {
- Bundle[] fragments = b.getFragments();
- if (fragments != null) {
- intp.print("\t Fragments="); //$NON-NLS-1$
- for (int f = 0; f < fragments.length; f++) {
- AbstractBundle fragment = (AbstractBundle) fragments[f];
- intp.print((f > 0 ? ", " : "") + fragment.getBundleId()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- intp.println();
- }
- }
- }
- }
- }
-
- private boolean match(Bundle toFilter, String searchedName, int searchedState) {
- if ((toFilter.getState() & searchedState) == 0) {
- return false;
- }
- if (searchedName != null && toFilter.getSymbolicName() != null && toFilter.getSymbolicName().indexOf(searchedName) == -1) {
- return false;
- }
- return true;
- }
-
- /**
- * Handles the threads command abbreviation. Invokes _threads().
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _t(CommandInterpreter intp) throws Exception {
- _threads(intp);
- }
-
- /**
- * Prints the information about the currently running threads
- * in the embedded system.
- *
- * @param intp A CommandInterpreter object containing the command
- * and it's arguments.
- */
- public void _threads(CommandInterpreter intp) throws Exception {
-
- ThreadGroup[] threadGroups = getThreadGroups();
- Util.sortByString(threadGroups);
-
- ThreadGroup tg = getTopThreadGroup();
- Thread[] threads = new Thread[tg.activeCount()];
- int count = tg.enumerate(threads, true);
- Util.sortByString(threads);
-
- StringBuffer sb = new StringBuffer(120);
- intp.println();
- intp.println(ConsoleMsg.CONSOLE_THREADGROUP_TITLE);
- for (int i = 0; i < threadGroups.length; i++) {
- tg = threadGroups[i];
- int all = tg.activeCount(); //tg.allThreadsCount();
- int local = tg.enumerate(new Thread[all], false); //tg.threadsCount();
- ThreadGroup p = tg.getParent();
- String parent = (p == null) ? "-none-" : p.getName(); //$NON-NLS-1$
- sb.setLength(0);
- sb.append(Util.toString(simpleClassName(tg), 18)).append(" ").append(Util.toString(tg.getName(), 21)).append(" ").append(Util.toString(parent, 16)).append(Util.toString(new Integer(tg.getMaxPriority()), 3)).append(Util.toString(new Integer(local), 4)).append("/").append(Util.toString(String.valueOf(all), 6)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- intp.println(sb.toString());
- }
- intp.print(newline);
- intp.println(ConsoleMsg.CONSOLE_THREADTYPE_TITLE);
- for (int j = 0; j < count; j++) {
- Thread t = threads[j];
- if (t != null) {
- sb.setLength(0);
- sb.append(Util.toString(simpleClassName(t), 18)).append(" ").append(Util.toString(t.getName(), 21)).append(" ").append(Util.toString(t.getThreadGroup().getName(), 16)).append(Util.toString(new Integer(t.getPriority()), 3)); //$NON-NLS-1$ //$NON-NLS-2$
- if (t.isDaemon())
- sb.append(" [daemon]"); //$NON-NLS-1$
- intp.println(sb.toString());
- }
- }
- }
-
- /**
- * Handles the sl (startlevel) command.
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _sl(CommandInterpreter intp) throws Exception {
- if (isStartLevelSvcPresent(intp)) {
- org.osgi.framework.Bundle bundle = null;
- String token = intp.nextArgument();
- int value = 0;
- if (token != null) {
- bundle = getBundleFromToken(intp, token, true);
- if (bundle == null) {
- return;
- }
- }
- if (bundle == null) { // must want framework startlevel
- value = slImpl.getStartLevel();
- intp.println(NLS.bind(ConsoleMsg.STARTLEVEL_FRAMEWORK_ACTIVE_STARTLEVEL, String.valueOf(value)));
- } else { // must want bundle startlevel
- value = slImpl.getBundleStartLevel(bundle);
- intp.println(NLS.bind(ConsoleMsg.STARTLEVEL_BUNDLE_STARTLEVEL, new Long(bundle.getBundleId()), new Integer(value)));
- }
- }
- }
-
- /**
- * Handles the setfwsl (set framework startlevel) command.
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _setfwsl(CommandInterpreter intp) throws Exception {
- if (isStartLevelSvcPresent(intp)) {
- int value = 0;
- String token = intp.nextArgument();
- if (token == null) {
- intp.println(ConsoleMsg.STARTLEVEL_NO_STARTLEVEL_GIVEN);
- value = slImpl.getStartLevel();
- intp.println(NLS.bind(ConsoleMsg.STARTLEVEL_FRAMEWORK_ACTIVE_STARTLEVEL, String.valueOf(value)));
- } else {
- value = this.getStartLevelFromToken(intp, token);
- if (value > 0) {
- try {
- slImpl.setStartLevel(value);
- intp.println(NLS.bind(ConsoleMsg.STARTLEVEL_FRAMEWORK_ACTIVE_STARTLEVEL, String.valueOf(value)));
- } catch (IllegalArgumentException e) {
- intp.println(e.getMessage());
- }
- }
- }
- }
- }
-
- /**
- * Handles the setbsl (set bundle startlevel) command.
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _setbsl(CommandInterpreter intp) throws Exception {
- if (isStartLevelSvcPresent(intp)) {
- String token;
- AbstractBundle bundle = null;
- token = intp.nextArgument();
- if (token == null) {
- intp.println(ConsoleMsg.STARTLEVEL_NO_STARTLEVEL_OR_BUNDLE_GIVEN);
- return;
- }
-
- int newSL = this.getStartLevelFromToken(intp, token);
-
- token = intp.nextArgument();
- if (token == null) {
- intp.println(ConsoleMsg.STARTLEVEL_NO_STARTLEVEL_OR_BUNDLE_GIVEN);
- return;
- }
- while (token != null) {
- bundle = getBundleFromToken(intp, token, true);
- if (bundle != null) {
- try {
- slImpl.setBundleStartLevel(bundle, newSL);
- intp.println(NLS.bind(ConsoleMsg.STARTLEVEL_BUNDLE_STARTLEVEL, new Long(bundle.getBundleId()), new Integer(newSL)));
- } catch (IllegalArgumentException e) {
- intp.println(e.getMessage());
- }
- }
- token = intp.nextArgument();
- }
- }
- }
-
- /**
- * Handles the setibsl (set initial bundle startlevel) command.
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _setibsl(CommandInterpreter intp) throws Exception {
- if (isStartLevelSvcPresent(intp)) {
- int value = 0;
- String token = intp.nextArgument();
- if (token == null) {
- intp.println(ConsoleMsg.STARTLEVEL_NO_STARTLEVEL_GIVEN);
- value = slImpl.getInitialBundleStartLevel();
- intp.println(NLS.bind(ConsoleMsg.STARTLEVEL_INITIAL_BUNDLE_STARTLEVEL, String.valueOf(value)));
- } else {
- value = this.getStartLevelFromToken(intp, token);
- if (value > 0) {
- try {
- slImpl.setInitialBundleStartLevel(value);
- intp.println(NLS.bind(ConsoleMsg.STARTLEVEL_INITIAL_BUNDLE_STARTLEVEL, String.valueOf(value)));
- } catch (IllegalArgumentException e) {
- intp.println(e.getMessage());
- }
- }
- }
- }
- }
-
- public void _requiredBundles(CommandInterpreter intp) {
- _classSpaces(intp);
- }
-
- public void _classSpaces(CommandInterpreter intp) {
-
- String token = intp.nextArgument();
-
- ServiceReference<?> packageAdminRef = context.getServiceReference("org.osgi.service.packageadmin.PackageAdmin"); //$NON-NLS-1$
- if (packageAdminRef != null) {
- PackageAdmin packageAdmin = (PackageAdmin) context.getService(packageAdminRef);
- if (packageAdmin != null) {
- try {
- org.osgi.service.packageadmin.RequiredBundle[] symBundles = null;
-
- symBundles = packageAdmin.getRequiredBundles(token);
-
- if (symBundles == null) {
- intp.println(ConsoleMsg.CONSOLE_NO_NAMED_CLASS_SPACES_MESSAGE);
- } else {
- for (int i = 0; i < symBundles.length; i++) {
- org.osgi.service.packageadmin.RequiredBundle symBundle = symBundles[i];
- intp.print(symBundle);
-
- boolean removalPending = symBundle.isRemovalPending();
- if (removalPending) {
- intp.print("("); //$NON-NLS-1$
- intp.print(ConsoleMsg.CONSOLE_REMOVAL_PENDING_MESSAGE);
- intp.println(")"); //$NON-NLS-1$
- }
-
- org.osgi.framework.Bundle provider = symBundle.getBundle();
- if (provider != null) {
- intp.print("<"); //$NON-NLS-1$
- intp.print(provider);
- intp.println(">"); //$NON-NLS-1$
-
- org.osgi.framework.Bundle[] requiring = symBundle.getRequiringBundles();
- if (requiring != null)
- for (int j = 0; j < requiring.length; j++) {
- intp.print(" "); //$NON-NLS-1$
- intp.print(requiring[j]);
- intp.print(" "); //$NON-NLS-1$
- intp.println(ConsoleMsg.CONSOLE_REQUIRES_MESSAGE);
- }
- } else {
- intp.print("<"); //$NON-NLS-1$
- intp.print(ConsoleMsg.CONSOLE_STALE_MESSAGE);
- intp.println(">"); //$NON-NLS-1$
- }
-
- }
- }
- } finally {
- context.ungetService(packageAdminRef);
- }
- }
- } else {
- intp.println(ConsoleMsg.CONSOLE_NO_EXPORTED_PACKAGES_NO_PACKAGE_ADMIN_MESSAGE);
- }
- }
-
- /**
- * Handles the profilelog command.
- *
- * @param intp A CommandInterpreter object containing the command and it's arguments.
- */
- public void _profilelog(CommandInterpreter intp) throws Exception {
- intp.println(Profile.getProfileLog());
- }
-
- public void _getPackages(CommandInterpreter intp) {
-
- String nextArg = intp.nextArgument();
- if (nextArg == null)
- return;
- AbstractBundle bundle = getBundleFromToken(intp, nextArg, true);
- ServiceReference<?> ref = context.getServiceReference("org.eclipse.osgi.service.resolver.PlatformAdmin"); //$NON-NLS-1$
- if (ref == null)
- return;
- PlatformAdmin platformAdmin = (PlatformAdmin) context.getService(ref);
- try {
- ExportPackageDescription[] exports = platformAdmin.getStateHelper().getVisiblePackages(bundle.getBundleDescription(), StateHelper.VISIBLE_INCLUDE_EE_PACKAGES | StateHelper.VISIBLE_INCLUDE_ALL_HOST_WIRES);
- for (int i = 0; i < exports.length; i++) {
- intp.println(exports[i] + ": " + platformAdmin.getStateHelper().getAccessCode(bundle.getBundleDescription(), exports[i])); //$NON-NLS-1$
- }
- } finally {
- context.ungetService(ref);
- }
- }
-
- /**
- * Handles the help command
- *
- * @param intp
- * @return description for a particular command or false if there is no command with the specified name
- */
- public Object _help(CommandInterpreter intp) {
- String commandName = intp.nextArgument();
- if (commandName == null) {
- return false;
- }
- String help = getHelp(commandName);
- return help.length() > 0 ? help : false;
- }
-
- /**
- * Checks for the presence of the StartLevel Service. Outputs a message if it is not present.
- * @param intp The CommandInterpreter object to be used to write to the console
- * @return true or false if service is present or not
- */
- protected boolean isStartLevelSvcPresent(CommandInterpreter intp) {
- boolean retval = false;
- ServiceReference<?> slSvcRef = context.getServiceReference("org.osgi.service.startlevel.StartLevel"); //$NON-NLS-1$
- if (slSvcRef != null) {
- StartLevel slSvc = (StartLevel) context.getService(slSvcRef);
- if (slSvc != null) {
- retval = true;
- }
- } else {
- intp.println(ConsoleMsg.CONSOLE_CAN_NOT_USE_STARTLEVEL_NO_STARTLEVEL_SVC_ERROR);
- }
- return retval;
- }
-
- /**
- * Given a number or a token representing a bundle symbolic name or bundle location,
- * retrieve the Bundle object with that id. The bundle symbolic name token is parsed as
- * symbolicname[@version]
- *
- * @param intp The CommandInterpreter
- * @param token A string containing a potential bundle it
- * @param error A boolean indicating whether or not to output a message
- * @return The requested Bundle object
- */
- protected AbstractBundle getBundleFromToken(CommandInterpreter intp, String token, boolean error) {
- AbstractBundle bundle = null;
- try {
- long id = Long.parseLong(token);
- bundle = (AbstractBundle) context.getBundle(id);
- } catch (NumberFormatException nfe) {
-
- // if not found, assume token is either symbolic name@version, or location
- String symbolicName = token;
- Version version = null;
-
- // check for @ -- this may separate either the version string, or be part of the
- // location
- int ix = token.indexOf("@"); //$NON-NLS-1$
- if (ix != -1) {
- if ((ix + 1) != token.length()) {
- try {
- // if the version parses, then use the token prior to @ as a symbolic name
- version = Version.parseVersion(token.substring(ix + 1, token.length()));
- symbolicName = token.substring(0, ix);
- } catch (IllegalArgumentException e) {
- // version doesn't parse, assume token is symbolic name without version, or location
- }
- }
- }
-
- Bundle[] bundles = context.getBundles();
- for (int i = 0, n = bundles.length; i < n; i++) {
- AbstractBundle b = (AbstractBundle) bundles[i];
- // if symbolicName matches, then matches if there is no version specific on command, or the version matches
- // if there is no version specified on command, pick first matching bundle
- if ((symbolicName.equals(b.getSymbolicName()) && (version == null || version.equals(b.getVersion()))) || token.equals(b.getLocation())) {
- bundle = b;
- break;
- }
- }
- }
-
- if ((bundle == null) && error) {
- intp.println(NLS.bind(ConsoleMsg.CONSOLE_CANNOT_FIND_BUNDLE_ERROR, token));
- }
-
- return (bundle);
- }
-
- /**
- * Given a string containing a startlevel value, validate it and convert it to an int
- *
- * @param intp A CommandInterpreter object used for printing out error messages
- * @param value A string containing a potential startlevel
- * @return The start level or an int <0 if it was invalid
- */
- protected int getStartLevelFromToken(CommandInterpreter intp, String value) {
- int retval = -1;
- try {
- retval = Integer.parseInt(value);
- if (Integer.parseInt(value) <= 0) {
- intp.println(ConsoleMsg.STARTLEVEL_POSITIVE_INTEGER);
- }
- } catch (NumberFormatException nfe) {
- intp.println(ConsoleMsg.STARTLEVEL_POSITIVE_INTEGER);
- }
- return retval;
- }
-
- /**
- * Given a bundle, return the string describing that bundle's state.
- *
- * @param bundle A bundle to return the state of
- * @return A String describing the state
- */
- protected String getStateName(Bundle bundle) {
- int state = bundle.getState();
- switch (state) {
- case Bundle.UNINSTALLED :
- return "UNINSTALLED "; //$NON-NLS-1$
-
- case Bundle.INSTALLED :
- if (isDisabled(bundle)) {
- return "<DISABLED> "; //$NON-NLS-1$
- }
- return "INSTALLED "; //$NON-NLS-1$
-
- case Bundle.RESOLVED :
- return "RESOLVED "; //$NON-NLS-1$
-
- case Bundle.STARTING :
- synchronized (lazyActivation) {
- if (lazyActivation.contains(bundle)) {
- return "<<LAZY>> "; //$NON-NLS-1$
- }
- return "STARTING "; //$NON-NLS-1$
- }
-
- case Bundle.STOPPING :
- return "STOPPING "; //$NON-NLS-1$
-
- case Bundle.ACTIVE :
- return "ACTIVE "; //$NON-NLS-1$
-
- default :
- return Integer.toHexString(state);
- }
- }
-
- private boolean isDisabled(Bundle bundle) {
- boolean disabled = false;
- ServiceReference<?> platformAdminRef = null;
- try {
- platformAdminRef = context.getServiceReference(PlatformAdmin.class.getName());
- if (platformAdminRef != null) {
- PlatformAdmin platAdmin = (PlatformAdmin) context.getService(platformAdminRef);
- if (platAdmin != null) {
- State state = platAdmin.getState(false);
- BundleDescription bundleDesc = state.getBundle(bundle.getBundleId());
- DisabledInfo[] disabledInfos = state.getDisabledInfos(bundleDesc);
- if ((disabledInfos != null) && (disabledInfos.length != 0)) {
- disabled = true;
- }
- }
- }
- } finally {
- if (platformAdminRef != null)
- context.ungetService(platformAdminRef);
- }
- return disabled;
- }
-
- /**
- * Answers all thread groups in the system.
- *
- * @return An array of all thread groups.
- */
- protected ThreadGroup[] getThreadGroups() {
- ThreadGroup tg = getTopThreadGroup();
- ThreadGroup[] groups = new ThreadGroup[tg.activeGroupCount()];
- int count = tg.enumerate(groups, true);
- if (count == groups.length) {
- return groups;
- }
- // get rid of null entries
- ThreadGroup[] ngroups = new ThreadGroup[count];
- System.arraycopy(groups, 0, ngroups, 0, count);
- return ngroups;
- }
-
- /**
- * Answers the top level group of the current thread.
- * <p>
- * It is the 'system' or 'main' thread group under
- * which all 'user' thread groups are allocated.
- *
- * @return The parent of all user thread groups.
- */
- protected ThreadGroup getTopThreadGroup() {
- ThreadGroup topGroup = Thread.currentThread().getThreadGroup();
- if (topGroup != null) {
- while (topGroup.getParent() != null) {
- topGroup = topGroup.getParent();
- }
- }
- return topGroup;
- }
-
- /**
- * Returns the simple class name of an object.
- *
- * @param o The object for which a class name is requested
- * @return The simple class name.
- */
- public String simpleClassName(Object o) {
- java.util.StringTokenizer t = new java.util.StringTokenizer(o.getClass().getName(), "."); //$NON-NLS-1$
- int ct = t.countTokens();
- for (int i = 1; i < ct; i++) {
- t.nextToken();
- }
- return t.nextToken();
- }
-
- public void _getprop(CommandInterpreter ci) throws Exception {
- Properties allProperties = FrameworkProperties.getProperties();
- String filter = ci.nextArgument();
- Iterator<?> propertyNames = new TreeSet<Object>(allProperties.keySet()).iterator();
- while (propertyNames.hasNext()) {
- String prop = (String) propertyNames.next();
- if (filter == null || prop.startsWith(filter)) {
- ci.println(prop + '=' + allProperties.getProperty(prop));
- }
- }
- }
-
- /**
- * This is used to track lazily activated bundles.
- */
- public void bundleChanged(BundleEvent event) {
- int type = event.getType();
- Bundle bundle = event.getBundle();
- synchronized (lazyActivation) {
- switch (type) {
- case BundleEvent.LAZY_ACTIVATION :
- if (!lazyActivation.contains(bundle)) {
- lazyActivation.add(bundle);
- }
- break;
-
- default :
- lazyActivation.remove(bundle);
- break;
- }
- }
-
- }
-}
diff --git a/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkConsole.java b/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkConsole.java
deleted file mode 100644
index 8ecbcf968..000000000
--- a/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkConsole.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2010 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.osgi.framework.internal.core;
-
-import java.io.*;
-import org.eclipse.osgi.framework.console.*;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * This class starts OSGi with a console for development use.
- *
- * FrameworkConsole provides a printStackTrace method to print Exceptions and their
- * nested Exceptions.
- */
-public class FrameworkConsole implements Runnable {
- /** The stream to receive commands on */
- private final BufferedReader in;
- /** The stream to write command results to */
- private final PrintWriter out;
- /** The current bundle context */
- private final BundleContext context;
- /** A tracker containing the service object of all registered command providers */
- private final ServiceTracker<CommandProvider, CommandProvider> cptracker;
- private final ConsoleSession consoleSession;
- private final boolean isSystemInOut;
- /** Default code page which must be supported by all JVMs */
- static final String defaultEncoding = "iso8859-1"; //$NON-NLS-1$
- /** The current setting for code page */
- static final String encoding = FrameworkProperties.getProperty("osgi.console.encoding", FrameworkProperties.getProperty("file.encoding", defaultEncoding)); //$NON-NLS-1$ //$NON-NLS-2$
- private static final boolean blockOnready = FrameworkProperties.getProperty("osgi.dev") != null || FrameworkProperties.getProperty("osgi.console.blockOnReady") != null; //$NON-NLS-1$ //$NON-NLS-2$
- volatile boolean shutdown = false;
-
- public FrameworkConsole(BundleContext context, ConsoleSession consoleSession, boolean isSystemInOut, ServiceTracker<CommandProvider, CommandProvider> cptracker) {
- this.context = context;
- this.cptracker = cptracker;
- this.isSystemInOut = isSystemInOut;
- this.consoleSession = consoleSession;
- in = createBufferedReader(consoleSession.getInput());
- out = createPrintWriter(consoleSession.getOutput());
- }
-
- /**
- * Return a BufferedReader from an InputStream. Handle encoding.
- *
- * @param _in An InputStream to wrap with a BufferedReader
- * @return a BufferedReader
- */
- static BufferedReader createBufferedReader(InputStream _in) {
- BufferedReader reader;
- try {
- reader = new BufferedReader(new InputStreamReader(_in, encoding));
- } catch (UnsupportedEncodingException uee) {
- // if the encoding is not supported by the jvm, punt and use whatever encodiing there is
- reader = new BufferedReader(new InputStreamReader(_in));
- }
- return reader;
- }
-
- /**
- * Return a PrintWriter from an OutputStream. Handle encoding.
- *
- * @param _out An OutputStream to wrap with a PrintWriter
- * @return a PrintWriter
- */
- static PrintWriter createPrintWriter(OutputStream _out) {
- PrintWriter writer;
- try {
- writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(_out, encoding)), true);
- } catch (UnsupportedEncodingException uee) {
- // if the encoding is not supported by the jvm, punt and use whatever encoding there is
- writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(_out)), true);
- }
- return writer;
- }
-
- /**
- * Return the current output PrintWriter
- * @return The currently active PrintWriter
- */
- public PrintWriter getWriter() {
- return out;
- }
-
- /**
- * Command Line Interface for OSGi. The method processes the initial commands
- * and then reads and processes commands from the console InputStream.
- * Command output is written to the console PrintStream. The method will
- * loop reading commands from the console InputStream until end-of-file
- * is reached. This method will then return.
- */
- public void run() {
- try {
- runConsole();
- } finally {
- // ensure the console is shutdown before exiting the thread
- shutdown();
- }
- }
-
- private void runConsole() {
- // wait to receive commands from console and handle them
- //cache the console prompt String
- String consolePrompt = "\r\n" + ConsoleMsg.CONSOLE_PROMPT; //$NON-NLS-1$
- while (!shutdown) {
- out.print(consolePrompt);
- out.flush();
-
- String cmdline = null;
- try {
- if (blockOnready && isSystemInOut) {
- // bug 40066: avoid waiting on input stream - apparently generates contention with other native calls
- try {
- while (!in.ready())
- Thread.sleep(300);
- cmdline = in.readLine();
- } catch (InterruptedException e) {
- // do nothing; probably got disconnected
- }
- } else
- cmdline = in.readLine();
- } catch (IOException ioe) {
- if (!shutdown)
- ioe.printStackTrace(out);
- }
- if (cmdline == null)
- // we assume the session is done and break out of the loop.
- break;
- if (!shutdown)
- docommand(cmdline);
- }
- }
-
- /**
- * Process the args on the command line.
- * This method invokes a CommandInterpreter to do the actual work.
- *
- * @param cmdline a string containing the command line arguments
- */
- protected void docommand(String cmdline) {
- if (cmdline != null && cmdline.length() > 0) {
- CommandInterpreter intcp = new FrameworkCommandInterpreter(cmdline, getServices(), this);
- String command = intcp.nextArgument();
- if (command != null) {
- intcp.execute(command);
- }
- }
- }
-
- /**
- * Reads a string from standard input until user hits the Enter key.
- *
- * @return The string read from the standard input without the newline character.
- */
- public String getInput() {
- String input;
- try {
- /** The buffered input reader on standard in. */
- input = in.readLine();
- System.out.println("<" + input + ">"); //$NON-NLS-1$//$NON-NLS-2$
- } catch (IOException e) {
- input = ""; //$NON-NLS-1$
- }
- return input;
- }
-
- /**
- * Return an array of service objects for all services
- * being tracked by this <tt>ServiceTracker</tt> object.
- *
- * The array is sorted primarily by descending Service Ranking and
- * secondarily by ascending Service ID.
- *
- * @return Array of service objects; if no service
- * are being tracked then an empty array is returned
- */
- public CommandProvider[] getServices() {
- ServiceReference<CommandProvider>[] serviceRefs = cptracker.getServiceReferences();
- if (serviceRefs == null)
- return new CommandProvider[0];
- Util.dsort(serviceRefs, 0, serviceRefs.length);
-
- CommandProvider[] serviceObjects = new CommandProvider[serviceRefs.length];
- for (int i = 0; i < serviceRefs.length; i++)
- serviceObjects[i] = FrameworkConsole.this.context.getService(serviceRefs[i]);
- return serviceObjects;
- }
-
- /**
- * Stops the console so the thread can be GC'ed
- */
- public synchronized void shutdown() {
- if (shutdown)
- return;
- shutdown = true;
- consoleSession.close();
- }
-
-}
diff --git a/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkConsoleSession.java b/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkConsoleSession.java
deleted file mode 100644
index 91b7c24d8..000000000
--- a/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkConsoleSession.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.osgi.framework.internal.core;
-
-import java.io.*;
-import java.net.Socket;
-import org.eclipse.osgi.framework.console.ConsoleSession;
-
-public class FrameworkConsoleSession extends ConsoleSession {
- private final Socket s;
- private final InputStream in;
- private final OutputStream out;
-
- public FrameworkConsoleSession(InputStream in, OutputStream out, Socket s) {
- this.in = in;
- this.out = out;
- this.s = s;
- }
-
- public synchronized InputStream getInput() {
- return in;
- }
-
- public synchronized OutputStream getOutput() {
- return out;
- }
-
- public void doClose() {
- if (s != null)
- try {
- s.close();
- } catch (IOException ioe) {
- // do nothing
- }
- if (out != null)
- try {
- out.close();
- } catch (IOException e) {
- // do nothing
- }
- if (in != null)
- try {
- in.close();
- } catch (IOException ioe) {
- // do nothing
- }
- }
-
-}
diff --git a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorHook.java b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorHook.java
index d8c88d684..657e6be86 100644
--- a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorHook.java
+++ b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorHook.java
@@ -20,10 +20,10 @@ import org.eclipse.core.runtime.adaptor.LocationManager;
import org.eclipse.osgi.baseadaptor.*;
import org.eclipse.osgi.baseadaptor.hooks.AdaptorHook;
import org.eclipse.osgi.framework.adaptor.FrameworkAdaptor;
-import org.eclipse.osgi.framework.console.CommandProvider;
import org.eclipse.osgi.framework.debug.Debug;
import org.eclipse.osgi.framework.debug.FrameworkDebugOptions;
-import org.eclipse.osgi.framework.internal.core.*;
+import org.eclipse.osgi.framework.internal.core.BundleHost;
+import org.eclipse.osgi.framework.internal.core.FrameworkProperties;
import org.eclipse.osgi.framework.log.FrameworkLog;
import org.eclipse.osgi.framework.log.FrameworkLogEntry;
import org.eclipse.osgi.internal.baseadaptor.AdaptorUtil;
@@ -92,10 +92,6 @@ public class EclipseAdaptorHook implements AdaptorHook, HookConfigurator {
if (converter == null)
converter = new PluginConverterImpl(adaptor, context);
registrations.add(AdaptorUtil.register(PluginConverter.class.getName(), converter, context));
- String builtinEnabled = FrameworkProperties.getProperty(ConsoleManager.PROP_CONSOLE_ENABLED, ConsoleManager.CONSOLE_BUNDLE);
- if ("true".equals(builtinEnabled)) { //$NON-NLS-1$
- registrations.add(AdaptorUtil.register(CommandProvider.class.getName(), new EclipseCommandProvider(context), context));
- }
registrations.add(AdaptorUtil.register(org.eclipse.osgi.service.localization.BundleLocalization.class.getName(), new BundleLocalizationImpl(), context));
}
diff --git a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseCommandProvider.java b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseCommandProvider.java
deleted file mode 100644
index 9647edfa7..000000000
--- a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseCommandProvider.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2011 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 java.util.*;
-import java.util.Map.Entry;
-import org.eclipse.osgi.framework.console.CommandInterpreter;
-import org.eclipse.osgi.framework.console.CommandProvider;
-import org.eclipse.osgi.service.resolver.*;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-
-/**
- * Internal class.
- */
-public class EclipseCommandProvider implements CommandProvider {
- public static final String NEW_LINE = "\r\n"; //$NON-NLS-1$
- public static final String TAB = "\t"; //$NON-NLS-1$
- private static final String POLICY_CONSOLE = "org.eclipse.osgi.framework.console"; //$NON-NLS-1$
- private PlatformAdmin platformAdmin;
- private BundleContext context;
-
- // holds the mapping between command name and command description
- private Map<String, String> commandsHelp = null;
-
- public EclipseCommandProvider(BundleContext context) {
- this.context = context;
- }
-
- public String getHelp() {
- return getHelp(null);
- }
-
- /* Returns either the help message for a particular command,
- * or the help messages for all commands (if commandName is not specified)*/
- private String getHelp(String commandName) {
- StringBuffer help = new StringBuffer(512);
-
- if (commandsHelp == null) {
- initializeCommandsHelp();
- }
-
- if (commandName != null) {
- if (commandsHelp.containsKey(commandName)) {
- addCommand(commandName, commandsHelp.get(commandName), help);
- }
- return help.toString();
- }
-
- addHeader(EclipseAdaptorMsg.ECLIPSE_CONSOLE_COMMANDS_HEADER, help);
- for (Entry<String, String> entry : commandsHelp.entrySet()) {
- addCommand(entry.getKey(), entry.getValue(), help);
- }
-
- return help.toString();
- }
-
- private void initializeCommandsHelp() {
- commandsHelp = new LinkedHashMap<String, String>();
- commandsHelp.put("diag", EclipseAdaptorMsg.ECLIPSE_CONSOLE_HELP_DIAG_COMMAND_DESCRIPTION); //$NON-NLS-1$
- commandsHelp.put("enableBundle", EclipseAdaptorMsg.ECLIPSE_CONSOLE_HELP_ENABLE_COMMAND_DESCRIPTION); //$NON-NLS-1$
- commandsHelp.put("disableBundle", EclipseAdaptorMsg.ECLIPSE_CONSOLE_HELP_DISABLE_COMMAND_DESCRIPTION); //$NON-NLS-1$
- commandsHelp.put("disabledBundles", EclipseAdaptorMsg.ECLIPSE_CONSOLE_HELP_LD_COMMAND_DESCRIPTION); //$NON-NLS-1$
- }
-
- /** Private helper method for getHelp. Formats the help headers. */
- private void addHeader(String header, StringBuffer help) {
- help.append("---"); //$NON-NLS-1$
- help.append(header);
- help.append("---"); //$NON-NLS-1$
- help.append(NEW_LINE);
- }
-
- /** Private helper method for getHelp. Formats the command descriptions. */
- private void addCommand(String command, String description, StringBuffer help) {
- help.append(TAB);
- help.append(command);
- help.append(" - "); //$NON-NLS-1$
- help.append(description);
- help.append(NEW_LINE);
- }
-
- private BundleDescription getBundleDescriptionFromToken(State state, String token) {
- try {
- long id = Long.parseLong(token);
- return state.getBundle(id);
- } catch (NumberFormatException nfe) {
- BundleDescription[] allBundles = state.getBundles(token);
- if (allBundles.length > 0)
- return allBundles[0];
- }
- return null;
- }
-
- private PlatformAdmin getPlatformAdmin(CommandInterpreter ci) {
- if (platformAdmin == null) {
- ServiceReference<?> platformAdminRef = context.getServiceReference(PlatformAdmin.class.getName());
- if (platformAdminRef == null) {
- ci.print(" "); //$NON-NLS-1$
- ci.println(EclipseAdaptorMsg.ECLIPSE_CONSOLE_NO_CONSTRAINTS_NO_PLATFORM_ADMIN_MESSAGE);
- return null;
- }
- platformAdmin = (PlatformAdmin) context.getService(platformAdminRef);
- }
- return platformAdmin;
- }
-
- private void ungetPlatformAdmin() {
- ServiceReference<?> platformAdminRef = context.getServiceReference(PlatformAdmin.class.getName());
- context.ungetService(platformAdminRef);
- }
-
- public void _diag(CommandInterpreter ci) throws Exception {
- String nextArg = ci.nextArgument();
- if (nextArg == null) {
- ci.println(EclipseAdaptorMsg.ECLIPSE_CONSOLE_NO_BUNDLE_SPECIFIED_ERROR);
- return;
- }
- try {
- State systemState = getPlatformAdmin(ci).getState(false);
- while (nextArg != null) {
- BundleDescription bundle = getBundleDescriptionFromToken(systemState, nextArg);
- if (bundle == null) {
- ci.println(NLS.bind(EclipseAdaptorMsg.ECLIPSE_CONSOLE_CANNOT_FIND_BUNDLE_ERROR, nextArg));
- nextArg = ci.nextArgument();
- continue;
- }
- ci.println(bundle.getLocation() + " [" + bundle.getBundleId() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
- VersionConstraint[] unsatisfied = platformAdmin.getStateHelper().getUnsatisfiedConstraints(bundle);
- ResolverError[] resolverErrors = platformAdmin.getState(false).getResolverErrors(bundle);
- for (int i = 0; i < resolverErrors.length; i++) {
- if ((resolverErrors[i].getType() & (ResolverError.MISSING_FRAGMENT_HOST | ResolverError.MISSING_GENERIC_CAPABILITY | ResolverError.MISSING_IMPORT_PACKAGE | ResolverError.MISSING_REQUIRE_BUNDLE)) != 0)
- continue;
- ci.print(" "); //$NON-NLS-1$
- ci.println(resolverErrors[i].toString());
- }
-
- if (unsatisfied.length == 0 && resolverErrors.length == 0) {
- ci.print(" "); //$NON-NLS-1$
- ci.println(EclipseAdaptorMsg.ECLIPSE_CONSOLE_NO_CONSTRAINTS);
- }
- if (unsatisfied.length > 0) {
- ci.print(" "); //$NON-NLS-1$
- ci.println(EclipseAdaptorMsg.ECLIPSE_CONSOLE_DIRECT_CONSTRAINTS);
- }
- for (int i = 0; i < unsatisfied.length; i++) {
- ci.print(" "); //$NON-NLS-1$
- ci.println(MessageHelper.getResolutionFailureMessage(unsatisfied[i]));
- }
- VersionConstraint[] unsatisfiedLeaves = platformAdmin.getStateHelper().getUnsatisfiedLeaves(new BundleDescription[] {bundle});
- boolean foundLeaf = false;
- for (int i = 0; i < unsatisfiedLeaves.length; i++) {
- if (unsatisfiedLeaves[i].getBundle() == bundle)
- continue;
- if (!foundLeaf) {
- foundLeaf = true;
- ci.print(" "); //$NON-NLS-1$
- ci.println(EclipseAdaptorMsg.ECLIPSE_CONSOLE_LEAF_CONSTRAINTS);
- }
- ci.print(" "); //$NON-NLS-1$
- ci.println(unsatisfiedLeaves[i].getBundle().getLocation() + " [" + unsatisfiedLeaves[i].getBundle().getBundleId() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
- ci.print(" "); //$NON-NLS-1$
- ci.println(MessageHelper.getResolutionFailureMessage(unsatisfiedLeaves[i]));
- }
- nextArg = ci.nextArgument();
- }
- } finally {
- ungetPlatformAdmin();
- }
- }
-
- public void _enableBundle(CommandInterpreter ci) throws Exception {
- String nextArg = ci.nextArgument();
- if (nextArg == null) {
- ci.println(EclipseAdaptorMsg.ECLIPSE_CONSOLE_NO_BUNDLE_SPECIFIED_ERROR);
- return;
- }
- try {
- State systemState = getPlatformAdmin(ci).getState(false);
- while (nextArg != null) {
- BundleDescription bundleDesc = getBundleDescriptionFromToken(systemState, nextArg);
- if (bundleDesc == null) {
- ci.println(NLS.bind(EclipseAdaptorMsg.ECLIPSE_CONSOLE_CANNOT_FIND_BUNDLE_ERROR, nextArg));
- nextArg = ci.nextArgument();
- continue;
- }
- DisabledInfo[] infos = systemState.getDisabledInfos(bundleDesc);
- for (int i = 0; i < infos.length; i++) {
- getPlatformAdmin(ci).removeDisabledInfo(infos[i]);
- }
- nextArg = ci.nextArgument();
- }
- } finally {
- ungetPlatformAdmin();
- }
- }
-
- public void _disableBundle(CommandInterpreter ci) throws Exception {
- String nextArg = ci.nextArgument();
- if (nextArg == null) {
- ci.println(EclipseAdaptorMsg.ECLIPSE_CONSOLE_NO_BUNDLE_SPECIFIED_ERROR);
- return;
- }
- try {
- State systemState = getPlatformAdmin(ci).getState(false);
- while (nextArg != null) {
- BundleDescription bundleDesc = getBundleDescriptionFromToken(systemState, nextArg);
- if (bundleDesc == null) {
- ci.println(NLS.bind(EclipseAdaptorMsg.ECLIPSE_CONSOLE_CANNOT_FIND_BUNDLE_ERROR, nextArg));
- nextArg = ci.nextArgument();
- continue;
- }
- DisabledInfo info = new DisabledInfo(POLICY_CONSOLE, EclipseAdaptorMsg.ECLIPSE_CONSOLE_BUNDLE_DISABLED_MESSAGE, bundleDesc);
- getPlatformAdmin(ci).addDisabledInfo(info);
- nextArg = ci.nextArgument();
- }
- } finally {
- ungetPlatformAdmin();
- }
- }
-
- public void _disabledBundles(CommandInterpreter ci) throws Exception {
-
- try {
- State systemState = getPlatformAdmin(ci).getState(false);
- BundleDescription[] disabledBundles = systemState.getDisabledBundles();
-
- ci.println(NLS.bind(EclipseAdaptorMsg.ECLIPSE_CONSOLE_DISABLED_COUNT_MESSAGE, String.valueOf(disabledBundles.length)));
-
- if (disabledBundles.length > 0) {
- ci.println();
- }
- for (int i = 0; i < disabledBundles.length; i++) {
- DisabledInfo[] disabledInfos = systemState.getDisabledInfos(disabledBundles[i]);
-
- ci.println(NLS.bind(EclipseAdaptorMsg.ECLIPSE_CONSOLE_DISABLED_BUNDLE_HEADER, formatBundleName(disabledBundles[i]), String.valueOf(disabledBundles[i].getBundleId())));
- ci.print(NLS.bind(EclipseAdaptorMsg.ECLIPSE_CONSOLE_DISABLED_BUNDLE_REASON1, disabledInfos[0].getMessage(), disabledInfos[0].getPolicyName()));
-
- for (int j = 1; j < disabledInfos.length; j++) {
- ci.print(NLS.bind(EclipseAdaptorMsg.ECLIPSE_CONSOLE_DISABLED_BUNDLE_REASON1, disabledInfos[j].getMessage(), String.valueOf(disabledInfos[j].getPolicyName())));
- }
-
- ci.println();
- }
- } finally {
- ungetPlatformAdmin();
- }
- }
-
- /**
- * Handles the help command
- *
- * @param intp
- * @return description for a particular command or false if there is no command with the specified name
- */
- public Object _help(CommandInterpreter intp) {
- String commandName = intp.nextArgument();
- if (commandName == null) {
- return false;
- }
- String help = getHelp(commandName);
- return help.length() > 0 ? help : false;
- }
-
- private String formatBundleName(BundleDescription b) {
- String label = b.getSymbolicName();
- if (label == null || label.length() == 0)
- label = b.toString();
- else
- label = label + "_" + b.getVersion(); //$NON-NLS-1$
-
- return label;
- }
-}

Back to the top