use of com.oracle.truffle.tools.chromeinspector.objects.Inspector in project graal by oracle.
the class InspectorInstrument method onCreate.
@Override
protected void onCreate(Env env) {
OptionValues options = env.getOptions();
if (options.hasSetOptions()) {
HostAndPort hostAndPort = options.get(Inspect);
connectionWatcher = new ConnectionWatcher();
try {
server = new Server(env, "Main Context", hostAndPort, options.get(Attach), options.get(Suspend), options.get(WaitAttached), options.get(HideErrors), options.get(Internal), options.get(Initialization), options.get(Path), options.hasBeenSet(Secure), options.get(Secure), new KeyStoreOptions(options), options.get(SourcePath), connectionWatcher);
} catch (IOException e) {
throw new InspectorIOException(hostAndPort.getHostPort(), e);
}
}
env.registerService(new Inspector(env, server != null ? server.getConnection() : null, new InspectorServerConnection.Open() {
@Override
// The parameters port and host should not be assigned
@SuppressWarnings("all")
public synchronized InspectorServerConnection open(int port, String host, boolean wait) {
if (server != null && server.wss != null) {
return null;
}
HostAndPort hostAndPort = options.get(Inspect);
if (port < 0) {
port = hostAndPort.port;
}
if (host == null) {
host = hostAndPort.host;
}
connectionWatcher = new ConnectionWatcher();
hostAndPort = new HostAndPort(host, port);
try {
server = new Server(env, "Main Context", hostAndPort, false, false, wait, options.get(HideErrors), options.get(Internal), options.get(Initialization), null, options.hasBeenSet(Secure), options.get(Secure), new KeyStoreOptions(options), options.get(SourcePath), connectionWatcher);
} catch (IOException e) {
PrintWriter info = new PrintWriter(env.err());
info.println(new InspectorIOException(hostAndPort.getHostPort(), e).getLocalizedMessage());
info.flush();
}
return server != null ? server.getConnection() : null;
}
}, new Supplier<InspectorExecutionContext>() {
@Override
public InspectorExecutionContext get() {
if (server != null) {
return server.getConnection().getExecutionContext();
} else {
PrintWriter err = (options.get(HideErrors)) ? null : new PrintWriter(env.err(), true);
return new InspectorExecutionContext("Main Context", options.get(Internal), options.get(Initialization), env, Collections.emptyList(), err);
}
}
}));
}
Aggregations