mirror of https://github.com/elunez/eladmin
parent
8b7a1ab627
commit
5c4d0e46d4
|
@ -17,8 +17,10 @@ package me.zhengjie.modules.mnt.util;
|
||||||
|
|
||||||
import ch.ethz.ssh2.Connection;
|
import ch.ethz.ssh2.Connection;
|
||||||
import ch.ethz.ssh2.SCPClient;
|
import ch.ethz.ssh2.SCPClient;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
@ -29,20 +31,20 @@ import java.util.logging.Logger;
|
||||||
*/
|
*/
|
||||||
public class ScpClientUtil {
|
public class ScpClientUtil {
|
||||||
|
|
||||||
static private ScpClientUtil instance;
|
static private Map<String,ScpClientUtil> instance = Maps.newHashMap();
|
||||||
|
|
||||||
static synchronized public ScpClientUtil getInstance(String ip, int port, String username, String passward) {
|
static synchronized public ScpClientUtil getInstance(String ip, int port, String username, String password) {
|
||||||
if (instance == null) {
|
if (instance.get(ip) == null) {
|
||||||
instance = new ScpClientUtil(ip, port, username, passward);
|
instance.put(ip, new ScpClientUtil(ip, port, username, password));
|
||||||
}
|
}
|
||||||
return instance;
|
return instance.get(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScpClientUtil(String ip, int port, String username, String passward) {
|
public ScpClientUtil(String ip, int port, String username, String password) {
|
||||||
this.ip = ip;
|
this.ip = ip;
|
||||||
this.port = port;
|
this.port = port;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = passward;
|
this.password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getFile(String remoteFile, String localTargetDirectory) {
|
public void getFile(String remoteFile, String localTargetDirectory) {
|
||||||
|
|
Loading…
Reference in New Issue