Skip to content

Instantly share code, notes, and snippets.

@ansell
Forked from anonymous/gist:602448
Created February 29, 2012 23:40
Show Gist options
  • Save ansell/1945499 to your computer and use it in GitHub Desktop.
Save ansell/1945499 to your computer and use it in GitHub Desktop.
import org.restlet.Context;
import org.restlet.Request;
import org.restlet.Response;
import org.restlet.data.Reference;
import org.restlet.resource.Directory;
public class ClassLoaderDirectory extends Directory {
private ClassLoader _cl;
public ClassLoaderDirectory(Context context, Reference rootLocalReference, ClassLoader cl) {
super(context, rootLocalReference);
this._cl = cl;
}
@Override
public void handle(Request request, Response response) {
final ClassLoader saveCL = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(_cl);
super.handle(request, response);
Thread.currentThread().setContextClassLoader(saveCL);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment