1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

Add host service for local connection.

Change-Id: I9ebf08e00839ec2d4e6affba5ccfeecadae9fc47
Signed-off-by: Greg Watson <g.watson@computer.org>
This commit is contained in:
Greg Watson 2015-05-14 11:33:48 -04:00
parent a278a865a1
commit 4ca5d9b494
2 changed files with 117 additions and 0 deletions

View file

@ -40,6 +40,11 @@
factory="org.eclipse.remote.internal.core.services.local.LocalCommandShellService$Factory" factory="org.eclipse.remote.internal.core.services.local.LocalCommandShellService$Factory"
service="org.eclipse.remote.core.IRemoteCommandShellService"> service="org.eclipse.remote.core.IRemoteCommandShellService">
</connectionService> </connectionService>
<connectionService
connectionTypeId="org.eclipse.remote.LocalServices"
factory="org.eclipse.remote.internal.core.services.local.LocalConnectionHostService$Factory"
service="org.eclipse.remote.core.IRemoteConnectionHostService">
</connectionService>
<processService <processService
connectionTypeId="org.eclipse.remote.LocalServices" connectionTypeId="org.eclipse.remote.LocalServices"
factory="org.eclipse.remote.internal.core.services.local.LocalProcess$Factory" factory="org.eclipse.remote.internal.core.services.local.LocalProcess$Factory"

View file

@ -0,0 +1,112 @@
/*******************************************************************************
* Copyright (c) 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.remote.internal.core.services.local;
import java.net.InetAddress;
import java.net.UnknownHostException;
import org.eclipse.remote.core.IRemoteConnection;
import org.eclipse.remote.core.IRemoteConnection.Service;
import org.eclipse.remote.core.IRemoteConnectionHostService;
public class LocalConnectionHostService implements IRemoteConnectionHostService {
private final IRemoteConnection connection;
public LocalConnectionHostService(IRemoteConnection connection) {
this.connection = connection;
}
public static class Factory implements IRemoteConnectionHostService.Factory {
@SuppressWarnings("unchecked")
@Override
public <T extends Service> T getService(IRemoteConnection remoteConnection, Class<T> service) {
if (service.equals(IRemoteConnectionHostService.class)) {
return (T) new LocalConnectionHostService(remoteConnection);
}
return null;
}
}
@Override
public IRemoteConnection getRemoteConnection() {
return this.connection;
}
@Override
public String getHostname() {
try {
return InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
return "unknown"; //$NON-NLS-1$
}
}
@Override
public int getPort() {
return 0;
}
@Override
public int getTimeout() {
return 0;
}
@Override
public boolean useLoginShell() {
return true;
}
@Override
public String getUsername() {
return System.getProperty("user.name"); //$NON-NLS-1$
}
@Override
public void setHostname(String hostname) {
// Ignored
}
@Override
public void setPassphrase(String passphrase) {
// Ignored
}
@Override
public void setPassword(String password) {
// Ignored
}
@Override
public void setPort(int port) {
// Ignored
}
@Override
public void setTimeout(int timeout) {
// Ignored
}
@Override
public void setUseLoginShell(boolean useLogingShell) {
// Ignored
}
@Override
public void setUsePassword(boolean usePassword) {
// Ignored
}
@Override
public void setUsername(String username) {
// Ignored
}
}