Search in sources :

Example 1 with JspRuntimeContext

use of org.apache.sling.scripting.jsp.jasper.compiler.JspRuntimeContext in project sling by apache.

the class JspScriptEngineFactory method renewJspRuntimeContext.

/**
     * Renew the jsp runtime context.
     * A new context is created, the old context is destroyed in the background
     */
private void renewJspRuntimeContext() {
    final JspRuntimeContext jrc;
    synchronized (this) {
        jrc = this.jspRuntimeContext;
        this.jspRuntimeContext = null;
    }
    final Thread t = new Thread() {

        @Override
        public void run() {
            destroyJspRuntimeContext(jrc);
        }
    };
    t.start();
}
Also used : JspRuntimeContext(org.apache.sling.scripting.jsp.jasper.compiler.JspRuntimeContext)

Example 2 with JspRuntimeContext

use of org.apache.sling.scripting.jsp.jasper.compiler.JspRuntimeContext in project sling by apache.

the class JspScriptEngineFactory method getJspWrapper.

private JspServletWrapper getJspWrapper(final String scriptName, final SlingBindings bindings) throws SlingException {
    JspRuntimeContext rctxt = this.getJspRuntimeContext();
    JspServletWrapper wrapper = rctxt.getWrapper(scriptName);
    if (wrapper != null) {
        if (wrapper.isValid()) {
            return wrapper;
        }
        synchronized (this) {
            rctxt = this.getJspRuntimeContext();
            wrapper = rctxt.getWrapper(scriptName);
            if (wrapper != null) {
                if (wrapper.isValid()) {
                    return wrapper;
                }
                this.renewJspRuntimeContext();
                rctxt = this.getJspRuntimeContext();
            }
        }
    }
    wrapper = new JspServletWrapper(servletConfig, options, scriptName, false, rctxt, defaultIsSession);
    wrapper = rctxt.addWrapper(scriptName, wrapper);
    return wrapper;
}
Also used : JspServletWrapper(org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper) JspRuntimeContext(org.apache.sling.scripting.jsp.jasper.compiler.JspRuntimeContext)

Example 3 with JspRuntimeContext

use of org.apache.sling.scripting.jsp.jasper.compiler.JspRuntimeContext in project sling by apache.

the class JspcMojo method initServletContext.

// ---------- Additional Settings ------------------------------------------
private void initServletContext() throws IOException, DependencyResolutionRequiredException {
    if (loader == null) {
        initClassLoader();
    }
    context = new JspCServletContext(getLog(), new URL("file:" + uriSourceRoot.replace('\\', '/') + '/'));
    tldLocationsCache = new JspCTldLocationsCache(context, true, loader);
    JavaCompiler compiler = new EclipseJavaCompiler();
    ClassLoaderWriter writer = new JspCClassLoaderWriter(loader, new File(outputDirectory));
    IOProvider ioProvider = new JspCIOProvider(loader, compiler, writer);
    rctxt = new JspRuntimeContext(context, this, ioProvider);
    jspConfig = new JspConfig(context);
    tagPluginManager = new TagPluginManager(context);
}
Also used : ClassLoaderWriter(org.apache.sling.commons.classloader.ClassLoaderWriter) JspConfig(org.apache.sling.scripting.jsp.jasper.compiler.JspConfig) EclipseJavaCompiler(org.apache.sling.commons.compiler.impl.EclipseJavaCompiler) TagPluginManager(org.apache.sling.scripting.jsp.jasper.compiler.TagPluginManager) JavaCompiler(org.apache.sling.commons.compiler.JavaCompiler) EclipseJavaCompiler(org.apache.sling.commons.compiler.impl.EclipseJavaCompiler) URL(java.net.URL) JspRuntimeContext(org.apache.sling.scripting.jsp.jasper.compiler.JspRuntimeContext) IOProvider(org.apache.sling.scripting.jsp.jasper.IOProvider) JarFile(java.util.jar.JarFile) File(java.io.File)

Aggregations

JspRuntimeContext (org.apache.sling.scripting.jsp.jasper.compiler.JspRuntimeContext)3 File (java.io.File)1 URL (java.net.URL)1 JarFile (java.util.jar.JarFile)1 ClassLoaderWriter (org.apache.sling.commons.classloader.ClassLoaderWriter)1 JavaCompiler (org.apache.sling.commons.compiler.JavaCompiler)1 EclipseJavaCompiler (org.apache.sling.commons.compiler.impl.EclipseJavaCompiler)1 IOProvider (org.apache.sling.scripting.jsp.jasper.IOProvider)1 JspConfig (org.apache.sling.scripting.jsp.jasper.compiler.JspConfig)1 TagPluginManager (org.apache.sling.scripting.jsp.jasper.compiler.TagPluginManager)1 JspServletWrapper (org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper)1