use of org.jvnet.hk2.guice.bridge.api.GuiceIntoHK2Bridge in project dropwizard-guicey by xvik.
the class GuiceBridgeActivator method activate.
/**
* Activate hk guice bridge.
*/
public void activate() {
GuiceBridge.getGuiceBridge().initializeGuiceBridge(locator);
final GuiceIntoHK2Bridge guiceBridge = locator.getService(GuiceIntoHK2Bridge.class);
guiceBridge.bridgeGuiceInjector(injector);
}
use of org.jvnet.hk2.guice.bridge.api.GuiceIntoHK2Bridge in project mycore by MyCoRe-Org.
the class MCRJerseyDefaultConfiguration method setupGuiceBridge.
/**
* Adds the binding between guice and hk2. This binding is one directional.
* You can add guice services into hk2 (jersey) resources. You cannot add
* a hk2 service into guice.
* <p>
* <a href="https://hk2.java.net/guice-bridge/">about the bridge</a>
* </p>
*
* @param resourceConfig the jersey resource configuration
*/
protected void setupGuiceBridge(ResourceConfig resourceConfig) {
LogManager.getLogger().info("Initialize hk2 - guice bridge...");
resourceConfig.register(new AbstractContainerLifecycleListener() {
@Override
public void onStartup(Container container) {
ServiceLocator serviceLocator = container.getApplicationHandler().getServiceLocator();
Injector injector = MCRInjectorConfig.injector();
GuiceBridge.getGuiceBridge().initializeGuiceBridge(serviceLocator);
GuiceIntoHK2Bridge guiceBridge = serviceLocator.getService(GuiceIntoHK2Bridge.class);
guiceBridge.bridgeGuiceInjector(injector);
}
});
}
use of org.jvnet.hk2.guice.bridge.api.GuiceIntoHK2Bridge in project graylog2-server by Graylog2.
the class Graylog2ServiceLocatorGenerator method create.
@Override
public ServiceLocator create(String name, ServiceLocator parent) {
final ServiceLocator serviceLocator = super.create(name, parent);
final Injector injector = GuiceInjectorHolder.getInjector().createChildInjector(new HK2IntoGuiceBridge(serviceLocator));
GuiceBridge.getGuiceBridge().initializeGuiceBridge(serviceLocator);
final GuiceIntoHK2Bridge guiceBridge = serviceLocator.getService(GuiceIntoHK2Bridge.class);
guiceBridge.bridgeGuiceInjector(injector);
return serviceLocator;
}
Aggregations