diff options
author | Thomas Watson | 2011-03-25 13:22:59 +0000 |
---|---|---|
committer | Thomas Watson | 2011-03-25 13:22:59 +0000 |
commit | eacae982816f3c7eb2d9d38e89267b05fc25bd3c (patch) | |
tree | 28d3650c260d6d634681df297876b2c4df65124d /bundles/org.eclipse.osgi.tests/bundles_src | |
parent | e6ac9bdb2b9a247de44369b787e3dae91e6edaed (diff) | |
download | rt.equinox.framework-eacae982816f3c7eb2d9d38e89267b05fc25bd3c.tar.gz rt.equinox.framework-eacae982816f3c7eb2d9d38e89267b05fc25bd3c.tar.xz rt.equinox.framework-eacae982816f3c7eb2d9d38e89267b05fc25bd3c.zip |
Diffstat (limited to 'bundles/org.eclipse.osgi.tests/bundles_src')
3 files changed, 89 insertions, 0 deletions
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 new file mode 100644 index 000000000..e368061f0 --- /dev/null +++ b/bundles/org.eclipse.osgi.tests/bundles_src/console.test/META-INF/MANIFEST.MF @@ -0,0 +1,9 @@ +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 new file mode 100644 index 000000000..79c22ace3 --- /dev/null +++ b/bundles/org.eclipse.osgi.tests/bundles_src/console.test/test/ConsoleTestActivator.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * 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 new file mode 100644 index 000000000..54e9cdc58 --- /dev/null +++ b/bundles/org.eclipse.osgi.tests/bundles_src/console.test/test/ConsoleTestCommandProvider.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * 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() { + StringBuffer help = new StringBuffer(); + help.append("---"); + help.append("Custom commands"); + help.append("---"); + help.append("\r\n"); + help.append("\t"); + help.append("echo - echos input"); + help.append("\r\n"); + help.append("\t"); + help.append("cust_exec - executes the command, passed as an argument"); + help.append("\r\n"); + return help.toString(); + } + +} |