ctx.terminateSession(); } catch (Exception e) {
public JdrRunner(CLI cli, String protocol, String host, int port, String user, String pass) { this.env.setServerRunning(false); this.env.setUsername(user); this.env.setPassword(pass); this.env.setHost(cli.getCommandContext().getControllerHost()); this.env.setPort("" + cli.getCommandContext().getControllerPort()); this.env.setCli(cli); try { ctx = CommandContextFactory.getInstance().newCommandContext(constructUri(protocol, host, port), user, pass == null ? new char[0] : pass.toCharArray()); ctx.connectController(); this.env.setClient(ctx.getModelControllerClient()); } catch (Exception e) { ctx.terminateSession(); // the server isn't available, carry on } }
/** * Sends quit command to CLI. */ public synchronized void quit() { ctx.terminateSession(); }
@Override public void close() throws IOException { if ((cmdCtx != null)) { cmdCtx.terminateSession(); } }
@Override protected void doHandle(CommandContext ctx) { ctx.terminateSession(); } }
@Override protected void doHandle(CommandContext ctx) { ctx.terminateSession(); } }
@Override public void terminateSession() { wrapped.terminateSession(); }
/** * Sends quit command to CLI. * * @throws Exception */ public synchronized void quit() { ctx.terminateSession(); }
@Override protected void closeInternal() throws IOException { context.terminateSession(); context = null; }
@Override public void terminateSession() { wrapped.terminateSession(); }
@Override public void stop() { ctx.terminateSession(); }
@Override public void stop() { ctx.terminateSession(); }
public void terminateSession() { delegate.terminateSession(); }
public void terminateSession() { delegate.terminateSession(); }
/** * Terminate the current CommandContext. */ public void terminate() { if (!ctx.isTerminated()) { ctx.terminateSession(); } }
/** * Terminate the current CommandContext. */ public void terminate() { if (!ctx.isTerminated()) { ctx.terminateSession(); } }
private void doConnect(Callable<CommandContext> callable) { if (isConnected()) { throw new IllegalStateException("Already connected to server."); } CommandContext newContext = null; try { newContext = callable.call(); newContext.connectController(); } catch (Exception ex) { if (newContext != null) { newContext.terminateSession(); } if (ex instanceof CliInitializationException) { throw new IllegalStateException("Unable to initialize " + "command context.", ex); } if (ex instanceof CommandLineException) { throw new IllegalStateException("Unable to connect " + "to controller.", ex); } throw new IllegalStateException(ex); } // We have a new connected context, terminate the current one. terminate(); ctx = newContext; }
private CommandContext createCommandContext(final ModelControllerClient client) { CommandContext commandContext = null; try { commandContext = CommandContextFactory.getInstance().newCommandContext(); commandContext.bindClient(client); } catch (CommandLineException e) { throw new IllegalStateException("Failed to initialize CLI context", e); } catch (Exception e) { // Terminate the session if we've encountered an error if (commandContext != null) { commandContext.terminateSession(); } throw new IllegalStateException("Failed to initialize CLI context", e); } return commandContext; }
@After public void after() throws Exception { if(ctx != null) { ctx.terminateSession(); } if(bytesOs != null) { bytesOs = null; } }
@After public void after() throws Exception { if(ctx != null) { ctx.terminateSession(); } if(bytesOs != null) { bytesOs = null; } }