Hi, i an wicket web app, where i use guice to inject the JPA
entitymanager. I have several DB's (scheduler, harvest), that i all
use through JPA. What i do to inject is this:
I create the injector:
protected GuiceComponentInjector getGuiceInjector() {
Module one = new PrivateModule() {
protected void configure() {
install(new SchedulerModule());
expose(ISchedulerDAO.class);
}
};
Module two = new PrivateModule() {
protected void configure() {
install(new HarvestModule());
expose(IHarvestDAO.class);
}
};
return new GuiceComponentInjector(this,
Guice.createInjector(one,
two));
}
public class SchedulerModule extends ServletModule {
@Override
protected void configureServlets() {
install(new JpaPersistModule("scheduler"));
filter("/*").through(PersistFilter.class);
bind(JPAInitializer.class).asEagerSingleton();
bind(ISchedulerDAO.class).to(SchedulerDAO.class);
}
}
public class HarvestModule extends ServletModule {
@Override
protected void configureServlets() {
install(new JpaPersistModule("harvest"));
filter("/*").through(PersistFilter.class);
bind(JPAInitializer.class).asEagerSingleton();
bind(IHarvestDAO.class).to(HarvestDAO.class);
}
}
@Singleton
public class JPAInitializer {
@Inject
public JPAInitializer(final PersistService service) {
service.start();
}
}
I sometimes get error "Entity not managed by this context" , so
there's something wrong.
thanks for help! duro
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.