| Hi Tom, 
 The idea with the EntityManagerFactoryBuilderService would be that you could retrieve the database credentials from the same place. 
 
 Just to make sure I got it right: I could e.g. create my own IDatabaseCredentialsService with one method getDBCredentials() : Map<String, String>. Afterwards I would inject this service everywhere I am using a persistence unit specific EntityManagerFactoryBuilderService. So rather providing redundant information as posted below I would retrieve them from the same place/my IDatabaseCredentialsService. 
 This solution will produce a little bit overhead with the service bindings but ok, I can live with it. 
 Perhaps I do not completely understand the problem you are facing. Do you have an example of how you would do this outside of OSGi?
 Unfortunately I don't have an example outside of OSGi, in our current project OSGi is fixed as the technology platform.
 Eugen 
 Am 29.11.2011 um 16:01 schrieb Tom Ware: The idea with the EntityManagerFactoryBuilderService would be that you could retrieve the database credentials from the same place.  I guess you could think of the fact that you have to pass them in to both getEntityManagerFactory() calls as redundant, but I'm not sure that's how I think about it. Perhaps I do not completely understand the problem you are facing. Do you have an example of how you would do this outside of OSGi? -Tom On 29/11/2011 9:52 AM, Eugen Reiswich wrote: I took a look at the EntityManagerFactoryBuilderService. As I understand there
 is one instance of that class for each persistence unit. So again I would have
 to provide that instance redundant data base credentials like:
 
 ServiceReference[] refs =
     context.getServiceReferences(
         EntityManagerFactoryBuilder.class.getName(),
         "(osgi.unit.name=Accounting)");
 
 if (refs != null) {
      EntityManagerFactoryBuilder emfBuilder =
          (EntityManagerFactoryBuilder) context.getService(refs[0]);
      if (emfBuilder != null) {
          Map<String,Object>  props = new HashMap<String,Object>();
          props.put("javax.persistence.jdbc.user", username1);
          props.put("javax.persistence.jdbc.password", password1);
          props.put("javax.persistence.jdbc.url", url1);
 
          EntityManagerFactory accountingEMF =
              emfBuilder.createEntityManagerFactory(props);
 
 
 The same code I would need to write for all other persistence units e.g.
 customers, orders. This is exactly what I would like to avoid. Any other hints?
 
 Eugen
 
 Am 28.11.2011 um 20:43 schrieb Tom Ware:
 
 Take a look at the EntityManagerFactoryBuilder Service. Some docs on this page:
 
 http://wiki.eclipse.org/Gemini/JPA/Documentation/JPAServices
 
 On 28/11/2011 1:39 PM, Eugen Reiswich wrote:
 Hi Tom,
 
 thanks for the jump start. After reading the documents there is one question I
 was not able to answer yet. In my outlined scenario I would like to put
 everything related to JPA in corresponding DAO bundles. As far as I understood
 my bundles will contain the following JPA related files:
 
 **.service.customer.dao*
 - customer-mapping.xml
 - persistence.xml
 
 **.service.account.dao*
 - account-mapping.xml
 - persistence.xml
 
 Both persistence.xml files contain duplicate database credentials. How can I
 provide those only once?
 
 Eugen
 
 
 Am 24.11.2011 um 18:58 schrieb Tom Ware:
 
 The best place to get started is the Gemini project. It includes the reference
 implementation for a number of Java EE technologies in OSGi.
 
 http://www.eclipse.org/gemini/
 
 The base of the JPA part of the project is here:
 
 http://www.eclipse.org/gemini/jpa/
 
 Documentation is on the wiki:
 
 http://wiki.eclipse.org/Gemini/JPA/Documentation
 
 -Tom
 
 
 On 24/11/2011 12:20 PM, Eugen Reiswich wrote:
 Hi folks,
 
 I googled now for two days to find an appropriate OSGi + EclipseLink example,
 but only found very basic ones.
 
 I've got an OSGi application with the following architecture:
 
 *Bundles:*
 *.ui.customer
 *.ui.account
 
 *.domain.customer // business objects like Customer.java, Address.java etc.
 *.domain.account // business objects like Account.java
 
 *.service.customer // customer logic
 *.service.account
 
 *.service.customer.dao // persistence logic
 *.service.account.dao
 
 Using this architecture I would like to:
 - use ORM.XML files in my *.dao-bundles rather that annotations in my business
 objects. This should keep my business objects and domain bundles free of any
 technology.
 - I would like to provide one DB-Connection credentials. I understand that a
 persistence.xml contains both: the persistence unit and DB-connection
 information. In my example I would need two persistence.xml files for customer
 and account bundles providing DB-connection information twice. Right?
 
 *My questions are:*
 1. assuming the above requirements/architecture what's the best way to make
 this
 work with EclipseLink + JPA 2.0?
 2. where do I have to put the persistence.xml file(s)?
 3. How can I tell EclipseLink that my DAO-bundles provide ORM mapping files?
 
 Regards,
 Eugen
 
 
 _______________________________________________
 eclipselink-users mailing list
 eclipselink-users@xxxxxxxxxxx
 https://dev.eclipse.org/mailman/listinfo/eclipselink-users
 _______________________________________________
 eclipselink-users mailing list
 eclipselink-users@xxxxxxxxxxx
 https://dev.eclipse.org/mailman/listinfo/eclipselink-users
 
 ________________________
 
 Dipl. Wi-Inf. Eugen Reiswich
 
 
 Universität Hamburg (UHH)
 Fakultät für Mathematik, Informatik
 und Naturwissenschaften (MIN-Fakultät)
 
 Department Informatik
 Zentrum für Architektur
 und Gestaltung von IT-Systemen (AGIS)
 
 Vogt-Koelln-Str. 30
 22527 Hamburg
 
 Tel: 040 / 42883 - 2307
 
 
 
 
 _______________________________________________
 eclipselink-users mailing list
 eclipselink-users@xxxxxxxxxxx
 https://dev.eclipse.org/mailman/listinfo/eclipselink-users
 _______________________________________________
 eclipselink-users mailing list
 eclipselink-users@xxxxxxxxxxx
 https://dev.eclipse.org/mailman/listinfo/eclipselink-users
 
 ________________________
 
 Dipl. Wi-Inf. Eugen Reiswich
 
 
 Universität Hamburg (UHH)
 Fakultät für Mathematik, Informatik
 und Naturwissenschaften (MIN-Fakultät)
 
 Department Informatik
 Zentrum für Architektur
 und Gestaltung von IT-Systemen (AGIS)
 
 Vogt-Koelln-Str. 30
 22527 Hamburg
 
 Tel: 040 / 42883 - 2307
 
 
 
 
 _______________________________________________
 eclipselink-users mailing list
 eclipselink-users@xxxxxxxxxxx
 https://dev.eclipse.org/mailman/listinfo/eclipselink-users
 _______________________________________________ eclipselink-users mailing listeclipselink-users@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/eclipselink-users
________________________ Dipl. Wi-Inf. Eugen Reiswich 
Universität Hamburg (UHH)
Fakultät für Mathematik, Informatik 
und Naturwissenschaften (MIN-Fakultät)  Department Informatik                        
Zentrum für Architektur                         
und Gestaltung von IT-Systemen (AGIS) Vogt-Koelln-Str. 30                             
22527 Hamburg Tel: 040 / 42883 - 2307 |