public static IRemoteConnection[] getSuitableConnections() { IRemoteServicesManager manager = Activator.getService(IRemoteServicesManager.class); if (manager == null) return null; ArrayList<IRemoteConnection> suitableConnections = new ArrayList<>(); List<IRemoteConnection> allConnections = manager.getAllRemoteConnections(); for (IRemoteConnection conn : allConnections) { if (conn.hasService(IRemoteCommandShellService.class)) { suitableConnections.add(conn); } } return suitableConnections.toArray(new IRemoteConnection[] {}); }
public static IRemoteConnection getRemoteConnectionByName(String remoteConnection) { if (remoteConnection == null) return null; IRemoteServicesManager manager = Activator.getService(IRemoteServicesManager.class); if (manager == null) { return null; } List<IRemoteConnection> conns = manager.getAllRemoteConnections(); for (IRemoteConnection conn : conns) { if (conn.getName().contentEquals(remoteConnection)) { return conn; } } return null; }