package de.ids_mannheim.korap.config;

import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.WebApplicationContext;

/**
 * A hack to inject the application context generated by
 * SpringJUnit4ClassRunner in the test suite.
 * 
 * @author margaretha
 *
 */
public class StaticContextLoaderListener extends ContextLoaderListener {

    public static WebApplicationContext applicationContext;

    public StaticContextLoaderListener () {
        super(applicationContext);
    }


}

@@ -32,16 +32,59 @@
 onfig;%0A%0A
+import javax.servlet.ServletContextEvent;%0A%0A
 import o
@@ -137,16 +137,16 @@
 stener;%0A
-
 import o
@@ -475,16 +475,61 @@
 ntext;%0A%0A
+    private ClassLoader contextClassLoader;%0A%0A
     publ
@@ -606,11 +606,970 @@
 %0A    %7D%0A%0A
+%09@Override%0A%09public void contextInitialized(ServletContextEvent event) %7B%0A        contextClassLoader = Thread.currentThread().getContextClassLoader();%0A        super.contextInitialized(event);%0A%09%7D%0A%0A%09@Override%0A%09public void contextDestroyed(ServletContextEvent event) %7B%0A        // Perform the destruction with the same contextual ClassLoader that was present%0A        // during initialization.%0A        // This a workaround for a bug in org.glassfish.grizzly.servlet.WebappContext%0A        // that causes a memory leak in org.springframework.web.context.ContextLoader.%0A        // This logic should be moved to WebappContext.contextDestroyed(). Until this%0A        // is fixed in Grizzly; This is a good solution.%0A        ClassLoader loader = Thread.currentThread().getContextClassLoader();%0A        Thread.currentThread().setContextClassLoader(contextClassLoader);%0A%0A        super.contextDestroyed(event);%0A%0A        Thread.currentThread().setContextClassLoader(loader);%0A%09%7D
 %0A%7D%0A

Jersey 2: Solve a memory leak