Search in sources :

Example 1 with ServiceFinder

use of org.glassfish.jersey.internal.ServiceFinder in project jersey by jersey.

the class ServiceFinderTest method createServiceFinder.

private ServiceFinder<?> createServiceFinder(final ClassLoader cl, final String serviceName) throws IOException {
    final ClassLoader ocl = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(cl);
    try {
        final Class<?> prc = cl.loadClass("org.glassfish.jersey.internal.ServiceFinder");
        final Method m = prc.getMethod("find", String.class);
        return (ServiceFinder<?>) m.invoke(null, serviceName);
    // return new PackagesResourceConfig(packages);
    } catch (final Exception e) {
        throw new RuntimeException(e);
    } finally {
        Thread.currentThread().setContextClassLoader(ocl);
    }
}
Also used : ServiceFinder(org.glassfish.jersey.internal.ServiceFinder) URLClassLoader(java.net.URLClassLoader) Method(java.lang.reflect.Method) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 Method (java.lang.reflect.Method)1 URLClassLoader (java.net.URLClassLoader)1 ServiceFinder (org.glassfish.jersey.internal.ServiceFinder)1