Wow guys, thanks indeed for your detailed help. I'm trying your recommendations right now.
Bests, Vicente El lunes 12 de marzo de 2012 23:46:48 UTC+1, scl escribió: > > I checked out kune but didn't get it to compile correctly. So I looked > into the code. Here are the 3 most obvious points I found: > If you need a more details then ask a more specific question :) > > 1) when you are using multiple data sources ALL your JpaPersistModules > must be installed in a private module. > > 2) when you are binding a class within a private module it can use all > bindings available in the public space as well as in the private space > defined by the private module. Therefore it is not necessary to expose the > EntityManager if you are only using it in classes which are binded within > the private module and you don't need to annotate the injection points with > @XxxDatasSource if you are binding the class within a private module. The > other instances of EntityManager are not visible since they are binded in a > different private module. > E.g.: don't expose the EntityManager from the > DataSourceOpenfirePersistModule and don't annotate EntityManager with > @DataSourceOpenfire in DataSourceOpenfireSessionProvider and > OpenfireXmppRosterProvider > This will even allow you to reuse the same SessionProvider for all data > sources since it does not contain any information about the data source. > The configuration which data source is used is done implicitly by binding > the SessionProvider in a private module which contains a JpaPersistModule. > You will have to expose the SessionProvider with an annotation if you want > to be injected into a class which is binded outside the private module. > You will have to expose the finders which are binded in the private > module. You don't have to expose them with an annotation if there are only > available in one data source. > > 3) you cannot bind the transaction interceptor within your private module. > This has to be done in the public space. The easiest way to do this is to > add a getter to your private module which will return the interceptor. The > Module who installs your private module can then obtain and bind the > interceptor which is provided by the private module. > If you don't mind that a transactional method will open a transaction on > ALL data sources you can use the default JpaLocalTxnInterceptor and the > default @Transactional binding. If you want to control on which data > sources a transaction is started you have to write your own > TransactionInterceptor which is capable of handling a custome transactional > annotation. > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-guice/-/7qAuAEVnJBYJ. 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.
