当前位置: 首页>>代码示例>>Java>>正文


Java Environment类代码示例

本文整理汇总了Java中org.apache.sshd.server.Environment的典型用法代码示例。如果您正苦于以下问题:Java Environment类的具体用法?Java Environment怎么用?Java Environment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Environment类属于org.apache.sshd.server包,在下文中一共展示了Environment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateSize

import org.apache.sshd.server.Environment; //导入依赖的package包/类
public void updateSize(Environment env) {
    String columns = env.getEnv().get(Environment.ENV_COLUMNS);
    String lines = env.getEnv().get(Environment.ENV_LINES);
    if (lines != null && columns != null) {
        Size size;
        try {
            int width = Integer.parseInt(columns);
            int height = Integer.parseInt(lines);
            size = new Size(width, height);
        }
        catch (Exception ignore) {
            size = null;
        }
        if (size != null) {
            this.size = size;
            if (sizeHandler != null) {
                sizeHandler.accept(size);
            }
        }
    }
}
 
开发者ID:aeshell,项目名称:aesh-readline,代码行数:22,代码来源:TtyCommand.java

示例2: start

import org.apache.sshd.server.Environment; //导入依赖的package包/类
@Override
public void start(Environment env) throws IOException {
    new Thread() {
        @Override
        public void run() {
            try {
                copySshdFilesToContentDirectory(source, dest);
            }
            catch (IOException e) {
                throw new RuntimeException(e);
            }
            finally {
                callback.onExit(0);
            }
        }
    }.start();


}
 
开发者ID:kantega,项目名称:respiro,代码行数:20,代码来源:TestSshdPlugin.java

示例3: start

import org.apache.sshd.server.Environment; //导入依赖的package包/类
@Override
public void start(Environment env) throws IOException {
  Context old = sshScope.set(context);
  String message;
  try {
    message = messageFactory.get().getMessage();
  } finally {
    sshScope.set(old);
  }
  err.write(Constants.encode(message));
  err.flush();

  in.close();
  out.close();
  err.close();
  exit.onExit(127);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:18,代码来源:NoShell.java

示例4: start

import org.apache.sshd.server.Environment; //导入依赖的package包/类
@Override
public void start(Environment env) throws IOException {
  startThread(
      new CommandRunnable() {
        @Override
        public void run() throws Exception {
          parseCommandLine();
          stdout = toPrintWriter(out);
          stderr = toPrintWriter(err);
          try {
            SshCommand.this.run();
          } finally {
            stdout.flush();
            stderr.flush();
          }
        }
      });
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:19,代码来源:SshCommand.java

示例5: start

import org.apache.sshd.server.Environment; //导入依赖的package包/类
@Override
public void start(Environment env) {
  Context ctx = context.subContext(newSession(), context.getCommandLine());
  final Context old = sshScope.set(ctx);
  try {
    startThread(
        new ProjectCommandRunnable() {
          @Override
          public void executeParseCommand() throws Exception {
            parseCommandLine();
          }

          @Override
          public void run() throws Exception {
            AbstractGitCommand.this.service();
          }

          @Override
          public Project.NameKey getProjectName() {
            return projectState.getNameKey();
          }
        });
  } finally {
    sshScope.set(old);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:27,代码来源:AbstractGitCommand.java

示例6: start

import org.apache.sshd.server.Environment; //导入依赖的package包/类
@Override
public void start(Environment env) throws IOException {
    new Thread("command-wrapper") {
        @Override
        public void run() {
            int code = 0;
            try {
                code = CommandWrapper.this.run(in, out, err);
            } catch (Exception e) {
                code = 1;
                logger.error("command failed", e);
            } finally {
                closeQuietly(out, err);
                callback.onExit(code);
            }
        }
    }.start();
}
 
开发者ID:FauxFaux,项目名称:ssh-key-capture,代码行数:19,代码来源:CommandWrapper.java

示例7: updateSize

import org.apache.sshd.server.Environment; //导入依赖的package包/类
public void updateSize(Environment env) {
  String columns = env.getEnv().get(Environment.ENV_COLUMNS);
  String lines = env.getEnv().get(Environment.ENV_LINES);
  if (lines != null && columns != null) {
    Vector size;
    try {
      int width = Integer.parseInt(columns);
      int height = Integer.parseInt(lines);
      size = new Vector(width, height);
    }
    catch (Exception ignore) {
      size = null;
    }
    if (size != null) {
      this.size = size;
      if (sizeHandler != null) {
        sizeHandler.accept(size);
      }
    }
  }
}
 
开发者ID:termd,项目名称:termd,代码行数:22,代码来源:TtyCommand.java

示例8: start

import org.apache.sshd.server.Environment; //导入依赖的package包/类
@Override
public void start(Environment env) throws IOException {
    log.info("Starting");

    ExecutorService service = ThreadUtils.newSingleThreadExecutor(getClass().getSimpleName() + "-" + POOL_COUNT.incrementAndGet());
    executorHolder.set(service);

    futureHolder.set(service.submit(new Runnable() {
        @SuppressWarnings("synthetic-access")
        @Override
        public void run() {
            log.info("Start heavy load sending " + sendCount + " messages of " + msg.length + " bytes");
            for (int i = 0; i < sendCount; i++) {
                pendingWrapper.write(new ByteArrayBuffer(msg));
            }
            log.info("Sending EOF signal");
            pendingWrapper.write(new ByteArrayBuffer(new byte[]{eofSignal}));
        }
    }));
    log.info("Started");
}
 
开发者ID:termd,项目名称:termd,代码行数:22,代码来源:WindowAdjustTest.java

示例9: start

import org.apache.sshd.server.Environment; //导入依赖的package包/类
@Override
public void start(Environment environment) throws IOException {

	//TODO Make with prototype bean
	Terminal terminal = new LanternaSshTerminal(inputStream, outputStream, Charset.forName(System
			.getProperty("file.encoding")), environment);
	LanternaRunner runner = new LanternaRunner();
	runner.setTerminal(terminal);
	runner.setSession(session);
	runner.setRootMenuList(getRootMenus());
	runner.setWindowManagerService(windowManagerService);
	runner.setDictionaryService(dictionaryService);
	runner.setUidaoService(uidaoService);
	runner.setWindowActionService(windowActionService);
	taskExecutor.execute(runner);

}
 
开发者ID:frincon,项目名称:openeos,代码行数:18,代码来源:LanternaSshFactory.java

示例10: start

import org.apache.sshd.server.Environment; //导入依赖的package包/类
@Override
public void start(Environment env) throws IOException {
    List<String> commandParts = Arrays.asList(this.command.split("\\s+"));
    ProcessBuilder processBuilder = new ProcessBuilder(commandParts);
    processBuilder.environment().putAll(env.getEnv());
    LOG.debug("running command: " + processBuilder.command());
    try {
        Process process = processBuilder.start();
        // close stdin
        process.getOutputStream().close();
        readProcessOutput(process);

        LOG.debug("waiting for process to quit");
        int exitCode = process.waitFor();
        LOG.debug("process exited with code: " + exitCode);
        if (this.callback != null) {
            this.callback.onExit(exitCode);
        }
    } catch (Exception e) {
        String errorMessage = format("failed to run command: %s", e.getMessage());
        this.errorStream.write((errorMessage + "\n").getBytes());
        this.errorStream.flush();
        this.callback.onExit(1, errorMessage);
    }
}
 
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:26,代码来源:ExternalProcessCommand.java

示例11: start

import org.apache.sshd.server.Environment; //导入依赖的package包/类
@Override
public void start(Environment environment) throws IOException {
    final Shell commander = new Shell(inputStream, outputStream, "commander");
    thread = new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                commander.run();
                exitCallback.onExit(0);
            } catch (Exception ex) {
                exitCallback.onExit(1, ex.getMessage());
            }
        }
    });
    thread.start();
}
 
开发者ID:nikolavp,项目名称:commander-shell,代码行数:17,代码来源:CommanderSshCommand.java

示例12: start

import org.apache.sshd.server.Environment; //导入依赖的package包/类
public void start(Environment env) throws IOException {

            try {
                consoleReader = new ConsoleReader(in, new FlushyOutputStream(out), new SshTerminal());
                consoleReader.setExpandEvents(true);
                consoleReader.addCompleter(new ConsoleCommandCompleter());

                StreamHandler streamHandler = new FlushyStreamHandler(out, new ConsoleLogFormatter(), consoleReader);
                streamHandlerAppender = new StreamHandlerAppender(streamHandler);

                ((Logger) LogManager.getRootLogger()).addAppender(streamHandlerAppender);

                environment = env;
                thread = new Thread(this, "SSHD ConsoleShell " + env.getEnv().get(Environment.ENV_USER));
                thread.start();
            } catch (Exception e) {
                throw new IOException("Error starting shell", e);
            }
        }
 
开发者ID:rmichela,项目名称:Bukkit-SSHD,代码行数:20,代码来源:ConsoleShellFactory.java

示例13: run

import org.apache.sshd.server.Environment; //导入依赖的package包/类
public void run() {
    try {
        printPreamble(consoleReader);
        while (true) {
            String command = consoleReader.readLine("\r>", null);
            if (command != null) {
                if (command.equals("exit")) {
                    break;
                }
                SshdPlugin.instance.getLogger().info("<" + environment.getEnv().get(Environment.ENV_USER) + "> " + command);
                Bukkit.getScheduler().runTask(SshdPlugin.instance, () -> {
                    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
                });
            }
        }
    } catch (IOException e) {
        SshdPlugin.instance.getLogger().severe("Error processing command from SSH");
    } finally {
        callback.onExit(0);
    }
}
 
开发者ID:rmichela,项目名称:Bukkit-SSHD,代码行数:22,代码来源:ConsoleShellFactory.java

示例14: getWidth

import org.apache.sshd.server.Environment; //导入依赖的package包/类
@Override
public int getWidth() {
	Environment environment = retrieveEnvironment();
	try {
		return parseInt(environment.getEnv().get("COLUMNS"));
	} catch (NumberFormatException e) {
		return DEFAULT_WIDTH;
	}
}
 
开发者ID:jesse-gallagher,项目名称:xsp-groovy-shell,代码行数:10,代码来源:SshTerminal.java

示例15: getHeight

import org.apache.sshd.server.Environment; //导入依赖的package包/类
@Override
public int getHeight() {
	Environment environment = retrieveEnvironment();
	try {
		return parseInt(environment.getEnv().get("LINES"));
	} catch (NumberFormatException e) {
		return DEFAULT_HEIGHT;
	}
}
 
开发者ID:jesse-gallagher,项目名称:xsp-groovy-shell,代码行数:10,代码来源:SshTerminal.java


注:本文中的org.apache.sshd.server.Environment类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。