Search in sources :

Example 1 with Debugger

use of org.eclipse.che.api.debugger.server.Debugger in project che by eclipse.

the class JavaDebuggerFactory method create.

@Override
public Debugger create(Map<String, String> properties, Debugger.DebuggerCallback debuggerCallback) throws DebuggerException {
    Map<String, String> normalizedProps = properties.entrySet().stream().collect(toMap(e -> e.getKey().toLowerCase(), Map.Entry::getValue));
    String host = normalizedProps.get("host");
    if (host == null) {
        throw new DebuggerException("Can't establish connection: host property is unknown.");
    }
    String portProp = normalizedProps.get("port");
    if (portProp == null) {
        throw new DebuggerException("Can't establish connection: port property is unknown.");
    }
    int port;
    try {
        port = Integer.parseInt(portProp);
    } catch (NumberFormatException e) {
        throw new DebuggerException("Unknown port property format: " + portProp);
    }
    return new JavaDebugger(host, port, debuggerCallback);
}
Also used : DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) Debugger(org.eclipse.che.api.debugger.server.Debugger) DebuggerFactory(org.eclipse.che.api.debugger.server.DebuggerFactory) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map)

Example 2 with Debugger

use of org.eclipse.che.api.debugger.server.Debugger in project che by eclipse.

the class ZendDbgFactory method create.

@Override
public Debugger create(Map<String, String> properties, Debugger.DebuggerCallback debuggerCallback) throws DebuggerException {
    Map<String, String> normalizedProps = properties.entrySet().stream().collect(toMap(e -> e.getKey().toLowerCase(), Map.Entry::getValue));
    String breakAtFirstLineProp = normalizedProps.get("break-at-first-line");
    if (breakAtFirstLineProp == null) {
        throw new DebuggerException("Can't establish connection: debug break at first line property is unknown.");
    }
    boolean breakAtFirstLine = Boolean.valueOf(breakAtFirstLineProp);
    String clientHostIPProp = normalizedProps.get("client-host-ip");
    if (clientHostIPProp == null) {
        throw new DebuggerException("Can't establish connection: client host/IP property is unknown.");
    }
    String debugPortProp = normalizedProps.get("debug-port");
    if (debugPortProp == null) {
        throw new DebuggerException("Can't establish connection: debug port property is unknown.");
    }
    int debugPort;
    try {
        debugPort = Integer.parseInt(debugPortProp);
    } catch (NumberFormatException e) {
        throw new DebuggerException("Unknown debug port property format: " + debugPortProp);
    }
    String useSslEncryptionProp = normalizedProps.get("use-ssl-encryption");
    if (useSslEncryptionProp == null) {
        throw new DebuggerException("Can't establish connection: debug use SSL encryption property is unknown.");
    }
    boolean useSslEncryption = Boolean.valueOf(useSslEncryptionProp);
    return new ZendDebugger(new ZendDbgSettings(debugPort, clientHostIPProp, breakAtFirstLine, useSslEncryption), new ZendDbgLocationHandler(), debuggerCallback);
}
Also used : DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) Debugger(org.eclipse.che.api.debugger.server.Debugger) DebuggerFactory(org.eclipse.che.api.debugger.server.DebuggerFactory) ZendDbgSettings(org.eclipse.che.plugin.zdb.server.connection.ZendDbgSettings) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) ZendDbgSettings(org.eclipse.che.plugin.zdb.server.connection.ZendDbgSettings) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map)

Example 3 with Debugger

use of org.eclipse.che.api.debugger.server.Debugger in project che by eclipse.

the class GdbDebuggerFactory method create.

@Override
public Debugger create(Map<String, String> properties, Debugger.DebuggerCallback debuggerCallback) throws DebuggerException {
    Map<String, String> normalizedProps = properties.entrySet().stream().collect(toMap(e -> e.getKey().toLowerCase(), Map.Entry::getValue));
    String host = normalizedProps.get("host");
    int port;
    try {
        port = Integer.parseInt(normalizedProps.getOrDefault("port", "0"));
    } catch (NumberFormatException e) {
        throw new DebuggerException("Unknown port property format: " + normalizedProps.get("port"));
    }
    String file = normalizedProps.get("binary");
    if (file == null) {
        throw new DebuggerException("binary property is null. Debugger can't be started");
    }
    String sources = normalizedProps.get("sources");
    if (sources == null) {
        sources = Paths.get(file).getParent().toString();
    }
    return GdbDebugger.newInstance(host, port, file, sources, debuggerCallback);
}
Also used : DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) Collectors.toMap(java.util.stream.Collectors.toMap) Paths(java.nio.file.Paths) Map(java.util.Map) Debugger(org.eclipse.che.api.debugger.server.Debugger) DebuggerFactory(org.eclipse.che.api.debugger.server.DebuggerFactory) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map)

Example 4 with Debugger

use of org.eclipse.che.api.debugger.server.Debugger in project che by eclipse.

the class NodeJsDebuggerFactory method create.

@Override
public Debugger create(Map<String, String> properties, Debugger.DebuggerCallback debuggerCallback) throws DebuggerException {
    Map<String, String> normalizedProps = properties.entrySet().stream().collect(toMap(e -> e.getKey().toLowerCase(), Map.Entry::getValue));
    Integer pid = null;
    URI uri = null;
    String pidStr = normalizedProps.get("pid");
    if (!isNullOrEmpty(pidStr)) {
        try {
            pid = Integer.valueOf(pidStr);
        } catch (NumberFormatException e) {
            throw new DebuggerException(String.format("Illegal 'pid' format %s. Debugger can't be started.", pidStr));
        }
    }
    String uriStr = normalizedProps.get("uri");
    if (!isNullOrEmpty(uriStr)) {
        try {
            uri = URI.create(uriStr);
        } catch (IllegalArgumentException e) {
            throw new DebuggerException(String.format("Illegal 'uri' format %s. Debugger can't be started.", uriStr));
        }
    }
    String script = normalizedProps.get("script");
    if (!isNullOrEmpty(script) && !Files.exists(Paths.get(script))) {
        throw new DebuggerException(String.format("Script '%s' to debug not found. Debugger can't be started.", script));
    }
    if (isNullOrEmpty(pidStr) && isNullOrEmpty(uriStr) && isNullOrEmpty(script)) {
        throw new DebuggerException("Unrecognized debug connection options. Allowed only: pid, uri or script.");
    }
    return NodeJsDebugger.newInstance(pid, uri, script, debuggerCallback);
}
Also used : DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) Collectors.toMap(java.util.stream.Collectors.toMap) Files(java.nio.file.Files) Paths(java.nio.file.Paths) Map(java.util.Map) Debugger(org.eclipse.che.api.debugger.server.Debugger) DebuggerFactory(org.eclipse.che.api.debugger.server.DebuggerFactory) Strings.isNullOrEmpty(com.google.common.base.Strings.isNullOrEmpty) URI(java.net.URI) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) URI(java.net.URI)

Aggregations

Map (java.util.Map)4 Collectors.toMap (java.util.stream.Collectors.toMap)4 Debugger (org.eclipse.che.api.debugger.server.Debugger)4 DebuggerFactory (org.eclipse.che.api.debugger.server.DebuggerFactory)4 DebuggerException (org.eclipse.che.api.debugger.server.exceptions.DebuggerException)4 Paths (java.nio.file.Paths)2 Strings.isNullOrEmpty (com.google.common.base.Strings.isNullOrEmpty)1 URI (java.net.URI)1 Files (java.nio.file.Files)1 ZendDbgSettings (org.eclipse.che.plugin.zdb.server.connection.ZendDbgSettings)1