use of org.apache.storm.sql.javac.CompilingClassLoader in project storm by apache.
the class StormSqlImpl method packageTopology.
private void packageTopology(Path jar, AbstractStreamsProcessor processor) throws IOException {
Manifest manifest = new Manifest();
Attributes attr = manifest.getMainAttributes();
attr.put(Attributes.Name.MANIFEST_VERSION, "1.0");
attr.put(Attributes.Name.MAIN_CLASS, processor.getClass().getCanonicalName());
try (JarOutputStream out = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(jar.toFile())), manifest)) {
List<CompilingClassLoader> classLoaders = processor.getClassLoaders();
if (classLoaders != null && !classLoaders.isEmpty()) {
for (CompilingClassLoader classLoader : classLoaders) {
for (Map.Entry<String, ByteArrayOutputStream> e : classLoader.getClasses().entrySet()) {
out.putNextEntry(new ZipEntry(e.getKey().replace(".", "/") + ".class"));
out.write(e.getValue().toByteArray());
out.closeEntry();
}
}
}
}
}
use of org.apache.storm.sql.javac.CompilingClassLoader in project storm by apache.
the class StreamsPlanCreator method createScalarInstance.
public ExecutableExpression createScalarInstance(RexProgram program, String className) throws CompilingClassLoader.CompilerException, ClassNotFoundException, IllegalAccessException, InstantiationException {
String expr = rexCompiler.compile(program, className);
CompilingClassLoader classLoader = new CompilingClassLoader(getLastClassLoader(), className, expr, null);
ExecutableExpression instance = (ExecutableExpression) classLoader.loadClass(className).newInstance();
addClassLoader(classLoader);
return new DebuggableExecutableExpression(instance, expr);
}
Aggregations