![JAR search and dependency download from the Maven repository](/logo.png)
bdi.glue.ssh.common.SshWorld Maven / Gradle / Ivy
package bdi.glue.ssh.common;
import java.util.Stack;
/**
* @author @aloyer
*/
public class SshWorld {
private SshSessionBuilder sessionBuilder;
private SshGateway sshGateway = new SshGateway();
private final Stack sessionStack = new Stack<>();
public SshSessionBuilder currentSessionBuilder() {
if (sessionBuilder == null) {
sessionBuilder = new SshSessionBuilder();
}
return sessionBuilder;
}
public void defineSshGateway(SshGateway sshGateway) {
this.sshGateway = sshGateway;
}
public SshGateway getSshGateway() {
return sshGateway;
}
public void pushSession(SshSession session) {
sessionStack.push(session);
}
public boolean hasSession() {
return !sessionStack.isEmpty();
}
public SshSession peekSession() {
if (hasSession()) {
return sessionStack.peek();
}
else {
throw new SshException("No session registered");
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy