use of com.twosigma.beakerx.kernel.Classpath in project beakerx by twosigma.
the class SQLEvaluator method configureSqlEvaluator.
protected void configureSqlEvaluator(EvaluatorParameters kernelParameters) {
SQLKernelParameters params = new SQLKernelParameters(kernelParameters);
Optional<Collection<String>> cp = params.getClassPath();
if (cp.isPresent()) {
if (cp.get() == null || cp.get().isEmpty()) {
classPath = new Classpath();
} else {
for (String line : cp.get()) {
if (!line.trim().isEmpty()) {
classPath.add(new PathToJar(line));
}
}
}
jdbcClient.loadDrivers(classPath.getPathsAsStrings());
}
if (params.defaultDatasource().isPresent()) {
this.defaultConnectionString = new ConnectionStringHolder(params.defaultDatasource().orElse(""), jdbcClient);
}
if (params.datasources().isPresent()) {
this.namedConnectionString = new HashMap<>();
Scanner sc = new Scanner(params.datasources().orElse(""));
while (sc.hasNext()) {
String line = sc.nextLine();
int i = line.indexOf('=');
if (i < 1 || i == line.length() - 1) {
logger.warn("Error in datasource line, this line will be ignored: {}.", line);
continue;
}
String name = line.substring(0, i).trim();
String value = line.substring(i + 1).trim();
if (value.startsWith("\"") && value.endsWith("\"")) {
value = value.substring(1, value.length() - 1);
}
namedConnectionString.put(name, new ConnectionStringHolder(value, jdbcClient));
}
}
}
Aggregations