Hello everyone.
Sorry for my bad English.
I have a problem with injection condition. There is custom made
MultitenancyPersistence and I want to use different persistence units for
different repository.
Here is my code:
I've got:
public class MultiTenantPersistServiceImpl implements PersistService {
...
@Inject
public MultiTenantPersistServiceImpl(@Named(PersistConsts.JPA_UNIT_NAME)
String jpaUnitName) { ... }
...
}
and:
public class MultiTenantUnitOfWorkImpl implements UnitOfWork,
EntityManagerProvider {
...
@Inject
public MultiTenantUnitOfWorkImpl(MultiTenantPersistServiceImpl
persistService) {}
...
}
which is used throw Provider at repo:
public abstract class AbstractRepo {
...
@Inject
private EntityManagerProvider entityManagerProvider;
protected EntityManager getEntityManager() {
return entityManagerProvider.get();
}
...
}
and extended by:
public abstract class AbstractFirstDbRepo extends AbstractRepo { ... }
public abstract class AbstractSecondDbRepo extends AbstractRepo { ... }
and binded at module:
public class MultiTenantPersistModule extends PersistModule {
...
@Override
protected void configurePersistence() {
bind(PersistService.class).to(MultiTenantPersistServiceImpl.class);
ThrowingProviderBinder.create(binder()).
bind(EntityManagerFactoryProvider.class, EntityManagerFactory.class).
to(MultiTenantPersistServiceImpl.class);
bind(UnitOfWork.class).to(MultiTenantUnitOfWorkImpl.class);
ThrowingProviderBinder.create(binder()).
bind(EntityManagerProvider.class, EntityManager.class).
to(MultiTenantUnitOfWorkImpl.class);
...
}
So, at last, my question.
What is the simpliest way to specify jpaUnitName at
MultiTenantPersistServiceImpl depending on Repo (AbstractFirstDbRepo or
AbstractSecondDbRepo )?
Thanks a lot.
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.