Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2010, 2012 IBM Corporation, SAP AG. 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 Contributors: Thomas Watson, IBM Corporation - initial API and implementation Lazar Kirchev, SAP AG - initial API and implementation /
package org.eclipse.equinox.console.command.adapter;
This adapter class provides for execution of legacy Equinox commands from the Gogo shell. The commands are executed through the main method of the adapter. It finds the appropriate Equinox command and executes it with the proper argument.
public class CommandProviderAdapter {
	private final Method[] commands;
	public CommandProviderAdapter(CommandProvider commandProviderMethod[] commands) {
		this. = commandProvider;
		this. = commands;
	public Object main(Object[] argsthrows Exception {
		try {
			// first argument is the command
			Method command = findCommand("_" + args[0]);
			ArrayList<ObjectargList = new ArrayList<Object>();
			for (int i = 1; i < args.lengthi++)
			return command.invoke(new CustomCommandInterpreter(argList));
catch (InvocationTargetException e) {
			if (e.getTargetException() instanceof Exception)
			throw (Errore.getTargetException();
	private Method findCommand(Object commandName) {
		for (Method command : ) {
			if (command.getName().equalsIgnoreCase(commandName.toString()))
				return command;
		throw new IllegalArgumentException("Cannot find the command method for: " + commandName);
	// TODO Felix gogo seems to search for _main
	public Object _main(Object[] argsthrows Exception {
		return main(args);
New to GrepCode? Check out our FAQ X