Community
Participate
Working Groups
Some people would like to decouple the persistence configuration from the persistence unit bundle by storing some or all of the persistence properties in the config admin service. It would be nice to have an integration such that a given pid was specified in the persistence descriptor and Gemini JPA looked up the given config and incremented the descriptor with additional properties found there. Only then would it proceed to register the services, etc.
I'm one of those that want this feature. But in my opinion it would be valid only if the punit created using the CM properties were considered a PUnit complete, where EMF and Datasource lifecycles would be tracked...
Mike, what is the name of PID ? it will be a factory one ? what properties should be handled ?
(In reply to comment #2) > Mike, > what is the name of PID ? > it will be a factory one ? > what properties should be handled ? How about gemini.jpa.<unit-name> ? Any properties in the config would override the same ones in the persistence descriptor, but would be overriden by properties passed in at runtime in the createEntityManagerFactory method on the builder. Make sense?
I wrote something similar when Gemini first came out, so I post it here. Could give some ideas, or can be used as is before this enhancement is closed. It's a quite simple bundle. For each EMFB service found in the registry, a new EMF service is created and published in the registry as well. Properties comes from the config admin (the PID is the bundle symbolic name, so "jpa.emfcreator"). Nothing is done if an EMF already exists so complete and incomplete units can be safely used together. Only one set of properties can be provided, but it can be easily extended. The advantage is that this bundle should work with any OSGi JPA implementation (no dependency on Gemini). Sources are included.
Created attachment 218098 [details] Simple bundle to get PU properties from the ConfigAdmin
After some experiments, I think that one good approach would be to implement ManagedServiceFactory, possibly in EclipseLinkOSGiProvider or PersistenceBundleExtender or in a new specific one. The managed service should be started at EclipseLinkOSGiProvider start() method. That would given us the possibility to setup/modify a PU even without read any xml.
Added the ability to create either an "incremental configuration" to specify persistence unit properties (such as driver props, etc), or a basic "standalone configuration" that contains enough information necessary to create a persistence unit without any XML descriptor in the persistence bundle.
(In reply to comment #7) > "standalone configuration" For some reason I can't ge the stand alone cfg working, I use the following config: [ gemini.jpa.punit-1357206819390-0, location: initial@reference:file:../eclipse/gemini-jpa-1.1.0.RELEASE/org.eclipse.gemini.jpa_1.1.0.RELEASE.jar/ ] eclipselink.target-database = org.eclipse.persistence.platform.database.H2Platform eclipselink.weaving = false gemini.jpa.punit.bsn = my.bundle.name gemini.jpa.punit.classes = class1,class2,class3 gemini.jpa.punit.excludeUnlistedClasses = true gemini.jpa.punit.name = company.db.0 gemini.jpa.punit.refresh = false javax.persistence.jdbc.driver = org.h2.Driver javax.persistence.jdbc.password = somepassword javax.persistence.jdbc.url = jdbc:h2:/database javax.persistence.jdbc.user = someuser service.factoryPid = gemini.jpa.punit service.pid = gemini.jpa.punit-1357206819390-0 (this is a debug dump from the config admin service) As you can see the configuration is bound to the gemini bundle, no error/warning occurs, but no EMF or EMFB is registered. BTW: I would suggest to support for property gemini.jpa.punit.classes either a commaseparated string or an array of strings.
Laeubi, Please enter issues as a separate bug. This one describes a feature enhancement and is completed/closed. Thanks, -Mike