Search in sources :

Example 1 with CharSequenceJavaCompiler

use of org.apache.sling.scripting.sightly.compiler.java.utils.CharSequenceJavaCompiler in project sling by apache.

the class JavaClassBackendCompilerTest method render.

private void render(StringWriter writer, ClassInfo classInfo, String source, RenderContext renderContext, Bindings arguments) throws Exception {
    ClassLoader classLoader = JavaClassBackendCompilerTest.class.getClassLoader();
    CharSequenceJavaCompiler<RenderUnit> compiler = new CharSequenceJavaCompiler<>(classLoader, null);
    Class<RenderUnit> newClass = compiler.compile(classInfo.getFullyQualifiedClassName(), source);
    RenderUnit renderUnit = newClass.newInstance();
    PrintWriter printWriter = new PrintWriter(writer);
    renderUnit.render(printWriter, renderContext, arguments);
}
Also used : RenderUnit(org.apache.sling.scripting.sightly.java.compiler.RenderUnit) CharSequenceJavaCompiler(org.apache.sling.scripting.sightly.compiler.java.utils.CharSequenceJavaCompiler) PrintWriter(java.io.PrintWriter)

Aggregations

PrintWriter (java.io.PrintWriter)1 CharSequenceJavaCompiler (org.apache.sling.scripting.sightly.compiler.java.utils.CharSequenceJavaCompiler)1 RenderUnit (org.apache.sling.scripting.sightly.java.compiler.RenderUnit)1