class CclCommandTerminal {

    public void executeCommands(final JSchSshTerminal terminal, final List<String> commands, final boolean authenticate)
            throws SshException {
        final EtmPoint point = PointFactory.getPoint(getClass(), "executeCommands");
        try {
            final boolean hasStreamConfiguration = streamConfiguration != null;
            final boolean hasCclOutputStream = hasStreamConfiguration
                    && OutputType.CCL_SESSION.equals(streamConfiguration.getOutputType());
            if (hasStreamConfiguration) {
                terminal.setOutputStream(hasCclOutputStream
                        ? new CclOutputStreamProxy(streamConfiguration.getOutputStream(), OUTPUT_START, OUTPUT_END)
                        : new OutputStreamProxy(streamConfiguration.getOutputStream()));
            }
            terminal.setExpectationTimeout(terminalProperties.getExpectationTimeout());

            final List<String> nonMergedCommands = new ArrayList<String>();
            for (String command : commands) {
                final String splitCommands[] = command.split("\\n");
                for (int index = 0; index < splitCommands.length; index++) {
                    nonMergedCommands.add(splitCommands[index]);
                }
            }

            final List<CommandExpectationGroup> commandExpectationGroups = new ArrayList<CommandExpectationGroup>();
            commandExpectationGroups.add(getSessionStartupGroup());
            commandExpectationGroups.add(getCclLaunchGroup());
            if (authenticate) {
                commandExpectationGroups.addAll(getAuthenticationGroups());
            }
            commandExpectationGroups.add(getFinalizeLoginGroup());
            commandExpectationGroups.add(getWaitForCcclReadyGroup());
            commandExpectationGroups.add(getCclSessionGroup(nonMergedCommands, hasCclOutputStream));
            commandExpectationGroups.add(getCclExitGroup());

            terminal.executeCommandGroups(commandExpectationGroups);
        } finally {
            point.collect();
        }
    }

    public  CclCommandTerminal(final TerminalProperties terminalProperties,
            final OutputStreamConfiguration streamConfiguration);

}