All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.robe.guice.HK2Linker Maven / Gradle / Ivy

There is a newer version: 0.5.0.0-1039
Show newest version
package io.robe.guice;

import com.google.inject.Injector;
import com.squarespace.jersey2.guice.BootstrapUtils;
import org.glassfish.hk2.api.ServiceLocator;
import javax.inject.Inject;

//Copied from https://github.com/HubSpot/dropwizard-guice/blob/master/src/main/java/com/hubspot/dropwizard/guice/HK2Linker.java
//Inspired by gwizard-jersey - https://github.com/stickfigure/gwizard
/**
 * Binding this as an eager singleton provides the second step of linking Guice back into HK2.
 * (the first step was to install the HK2 BootstrapModule in the Guice module).
 *
 * This needs to happen before anything else related to Jersey starts.
 */
public class HK2Linker {
    @Inject
    public HK2Linker(Injector injector, ServiceLocator locator) {
        BootstrapUtils.link(locator, injector);
        BootstrapUtils.install(locator);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy