I'm using Eclipse 3.7 with Eclipse Gemini JPA / DBAccess. I implemented a declarative ServiceComponent which references EntityManagerBuilderFactory. The bind method looks like this:
public void bindEntityManagerFactoryBuilder(EntityManagerFactoryBuilder emfBuilder) {
emfFactoryBuilders.add(emfBuilder);
}
However I need the ServiceReference to obtain the properties of this service, like:
ServiceReference ref = ...
String unitName = (String)ref.getProperty(EntityManagerFactoryBuilder.JPA_UNIT_NAME);
Do I have to search the ServiceRegistry for this ServiceReference, or is there a more elegant approach?
cheers, Muki
If you are using Declarative Services 1.1 (the most recent spec version), you can change the signature of your bind method to:
public void bindEntityManagerFactoryBuilder(EntityManagerFactoryBuilder emfBuilder, Map properties)
The map will contain the service properties of the bound service.
If you like to have access to ServiceReference object you can use this way (it's supported by 1.0 and 1.1 DS):
public void bindEntityManagerFactoryBuilder(ServiceReference reference)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With