public Collection resolveCommands()

in gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandResolverImpl.java [232:274]


    public Collection<Command> resolveCommands(String name, Variables variables) throws CommandException {
        // name may be null
        assert variables != null;

        if (name == null) {
            name = "";
        }
        
        log.debug("Resolving commands for name: {}", name);

        List<Command> commands = new ArrayList<Command>();

        try {
            FileObject file = resolveCommandFile(name, variables);

            log.trace("Resolved (for commands): {}", file);

            if (file != null && file.exists()) {
                if (file.getType().hasChildren()) {
                    for (FileObject child : file.getChildren()) {
                        Command command = createCommand(child);
                        commands.add(command);
                    }
                }
                else {
                    Command command = createCommand(file);
                    commands.add(command);
                }
            }
        }
        catch (FileSystemException e) {
            log.warn("Failed to resolve commands for name: " + name, e);
        }

        log.debug("Resolved {} commands", commands.size());
        if (log.isTraceEnabled()) {
            for (Command command : commands) {
                log.trace("    {}", command);
            }
        }

        return commands;
    }