I've wired a bi-directional guice-bridge with:
Module allModules[] = new Module[modules.length + 1];
ServiceLocator serviceLocator =
ServiceLocatorUtilities.createAndPopulateServiceLocator("mw-serviceLoca
tor");
allModules[0] = new HK2IntoGuiceBridge(serviceLocator);
for (int lcv = 0; lcv < modules.length; lcv++) {
allModules[lcv + 1] = modules[lcv];
}
Injector guiceInjector = Guice.createInjector(allModules);
GuiceBridge.getGuiceBridge().initializeGuiceBridge(serviceLocator);
GuiceIntoHK2Bridge g2h =
serviceLocator.getService(GuiceIntoHK2Bridge.class);
g2h.bridgeGuiceInjector(guiceInjector);
return guiceInjector;
I attempt to inject the Guice-managed DataSource in this simple
resource:
@Path("/hello")
public class HelloResource {
@Inject
@Named(value = "default")
private DataSource dataSource;
@GET
@Produces("text/plain")
public String handleGreeting() {
System.out.println(dataSource);
return "Hello World";
}
}
But I'm getting the following exception:
@Path("/hello")
public class HelloResource {
@Inject
@Named(value = "default")
private DataSource dataSource;
@GET
@Produces("text/plain")
public String handleGreeting() {
System.out.println(dataSource);
return "Hello World";
}
}
Any advice on what I might be doing wrong?