本文整理汇总了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);
}
}
}
}
示例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();
}
示例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);
}
示例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();
}
}
});
}
示例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);
}
}
示例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();
}
示例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);
}
}
}
}
示例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");
}
示例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);
}
示例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);
}
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例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;
}
}
示例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;
}
}