@Override public void bindClient(ModelControllerClient newClient) { wrapped.bindClient(newClient); }
@Override public void bindClient(ModelControllerClient newClient) { wrapped.bindClient(newClient); }
public void bindClient(ModelControllerClient newClient) { delegate.bindClient(newClient); }
public void bindClient(ModelControllerClient newClient) { delegate.bindClient(newClient); }
protected CommandContext createContext(final ModelControllerClient client) { final CommandContext commandContext; try { commandContext = new ExtendedCommandContextImpl(); commandContext.bindClient(client); } catch (CliInitializationException e) { throw new IllegalStateException("Failed to initialize CLI context", e); } return commandContext; } }
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; }
/** * Creates the command context and binds the client to the context. * <p/> * If the client is {@code null}, no client is bound to the context. * * @param client current connected client * * @return the command line context * * @throws IllegalStateException if the context fails to initialize */ public static CommandContext create(final ModelControllerClient client) { final CommandContext commandContext; try { commandContext = CommandContextFactory.getInstance().newCommandContext(); commandContext.bindClient(client); } catch (CliInitializationException e) { throw new IllegalStateException("Failed to initialize CLI context", e); } return commandContext; }
ctx.bindClient(mcc);
private boolean connectUsingRemoting(CommandContext cmdCtx, RemotingMBeanServerConnection rmtMBeanSvrConn) throws IOException, CliInitializationException { Connection conn = rmtMBeanSvrConn.getConnection(); Channel channel; final IoFuture<Channel> futureChannel = conn.openChannel("management", OptionMap.EMPTY); IoFuture.Status result = futureChannel.await(5, TimeUnit.SECONDS); if (result == IoFuture.Status.DONE) { channel = futureChannel.get(); } else { futureChannel.cancel(); return false; } ModelControllerClient modelCtlrClient = ExistingChannelModelControllerClient.createReceiving(channel, createExecutor()); cmdCtx.bindClient(modelCtlrClient); return true; }
private boolean connectUsingRemoting(CommandContext cmdCtx, RemotingMBeanServerConnection rmtMBeanSvrConn) throws IOException, CliInitializationException { Connection conn = rmtMBeanSvrConn.getConnection(); Channel channel; final IoFuture<Channel> futureChannel = conn.openChannel("management", OptionMap.EMPTY); IoFuture.Status result = futureChannel.await(5, TimeUnit.SECONDS); if (result == IoFuture.Status.DONE) { channel = futureChannel.get(); } else { futureChannel.cancel(); return false; } ModelControllerClient modelCtlrClient = ExistingChannelModelControllerClient.createReceiving(channel, createExecutor()); cmdCtx.bindClient(modelCtlrClient); return true; }
cliContext.bindClient(client); } catch (CliInitializationException e) { try {
ctx.bindClient(mcc);
/** * Execute the commands. * <p/> * Note that the client is not closed during this execution. * * @param client the client used to execute the commands * * @throws IOException if the client has an IOException * @throws IllegalArgumentException if an command is invalid */ public final void execute(final ModelControllerClient client) throws IOException { final boolean hasCommands = hasCommands(); final boolean hasScripts = hasScripts(); if (hasCommands || hasScripts) { final NonClosingModelControllerClient c = new NonClosingModelControllerClient(client); final CommandContext ctx = create(c); try { if (isBatch()) { executeBatch(ctx); } else { executeCommands(ctx); } executeScripts(ctx); } finally { ctx.terminateSession(); ctx.bindClient(null); } } }