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 http://www.eclipse.org/legal/epl-v10.html 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(CommandSession commandSessionObject[] 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++)
				argList.add(args[i]);
			return command.invoke(new CustomCommandInterpreter(commandSessionargList));
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(CommandSession commandSessionObject[] argsthrows Exception {
		return main(commandSessionargs);
	}
New to GrepCode? Check out our FAQ X