Search in sources :

Example 1 with JerseyGuiceModule

use of com.squarespace.jersey2.guice.JerseyGuiceModule in project API by ca-cwds.

the class JerseyGuiceRule method before.

@Override
protected void before() throws Throwable {
    Injector baseInjector = Guice.createInjector(Stage.PRODUCTION, new ServletModule());
    JerseyGuiceUtils.install(new ServiceLocatorGenerator() {

        @Override
        public ServiceLocator create(String name, ServiceLocator parent) {
            if (!name.startsWith("__HK2_Generated_")) {
                return null;
            }
            return baseInjector.createChildInjector(new JerseyGuiceModule(name)).getInstance(ServiceLocator.class);
        }
    });
}
Also used : ServiceLocator(org.glassfish.hk2.api.ServiceLocator) ServiceLocatorGenerator(org.glassfish.hk2.extension.ServiceLocatorGenerator) Injector(com.google.inject.Injector) JerseyGuiceModule(com.squarespace.jersey2.guice.JerseyGuiceModule) ServletModule(com.google.inject.servlet.ServletModule)

Aggregations

Injector (com.google.inject.Injector)1 ServletModule (com.google.inject.servlet.ServletModule)1 JerseyGuiceModule (com.squarespace.jersey2.guice.JerseyGuiceModule)1 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)1 ServiceLocatorGenerator (org.glassfish.hk2.extension.ServiceLocatorGenerator)1