Package com.sun.grid.jgdi.util.shell

Examples of com.sun.grid.jgdi.util.shell.AbstractCommand


     * @param cls Annotated class child of AbstractCommand
     * @throws java.lang.Exception
     */
    @SuppressWarnings(value = "unchecked")
    private void addAnnotatedCommand(Class cls) throws Exception {
        AbstractCommand cmd = null;
        CommandAnnotation ca = (CommandAnnotation) cls.getAnnotation(CommandAnnotation.class);
        if (AbstractCommand.class.isAssignableFrom(cls)) {

            cmdMap.put(ca.value(), cls);
            if (AnnotatedCommand.class.isAssignableFrom(cls)) {
View Full Code Here


    private AbstractCommand getCommand(String name) throws Exception {
        Class<? extends AbstractCommand> cls = cmdMap.get(name);
        if (cls == null) {
            return null;
        }
        AbstractCommand cmd = null;
        //If JGDIShell inner class
        if (cls.getName().contains(".JGDIShell$")) {
            Constructor c = cls.getConstructor(new Class[]{JGDIShell.class});
            cmd = (AbstractCommand) c.newInstance(new Object[]{this});
        } else {
View Full Code Here

                } catch (IndexOutOfBoundsException ioob) {
                    throw new IllegalArgumentException("command with id " + id + " not found in history");
                }
            }
            ParsedLine parsedLine = new ParsedLine(line);
            AbstractCommand cmd = getCommand(parsedLine.cmd);
            if (cmd == null) {
                exitCode = runShellCommand(line);
                return exitCode;
            }

            if (historyList.size() > maxHistory) {
                historyList.remove(0);
            }
            historyList.add(new HistoryElement(++historyIndex, line));

            cmd.init(this);
            cmd.run(parsedLine.args);
            return cmd.getExitCode();
        } catch (AbortException expected) {
            exitCode = 0;
        } catch (JGDIException ex) {
            err.println(ex.getMessage());
            logger.info("Command failed: " + ex.getMessage());
View Full Code Here

                    for (String cmd : cmdMap.keySet()) {
                        out.println(cmd);
                    }
                    break;
                case 1:
                    AbstractCommand cmd = getCommand(args[0]);
                    if (cmd == null) {
                        out.println("command " + args[0] + " not found");
                        return;
                    }
                    out.println(cmd.getUsage());
                    break;
                default:
                    out.println(getUsage());
            }
        }
View Full Code Here

TOP

Related Classes of com.sun.grid.jgdi.util.shell.AbstractCommand

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.