Hi Steinar.
The problem is, that JSF doesn`t provide any means to handle OSGi services.
CDI would solve this but at the moment it is not possible to use
CDI-Annotations in a JSF-Controller (UkelonnController) because JSF inside
Pax-Web cannot resolve beans within an BeanManager from an EL-Expression
[1]. If this bug would be solved you could just use the CDI-Extensions
provided by Pax-CDI.
IMHO, the only solution at the moment is to get an OSGi-service using the
framework-api, execute it, and release it. With Java 8 you can achieve this
without a lot of noise using Lambdas
public static void executeWithOsgiServiceDelegate(Consumer<
OsgiServiceDelegate> x){
final BundleContext context = FrameworkUtil.getBundle(this.getClass()).
getBundleContext();
// get-service, execute function, and unget-service
ServiceReference<OsgiServiceDelegate> serviceRef = context.
getServiceReference(OsgiServiceDelegate.class);
if (serviceRef != null) {
OsgiServiceDelegate service = context.getService(serviceRef);
if (service != null) {
x.accept(service);
service = null;
}
context.ungetService(serviceRef);
}
}
Now you can use this like
executeWithOsgiServiceDelegate(service -> this.var = service.delegateMethod
());
[1] https://ops4j1.jira.com/browse/PAXCDI-210
regards
Marc
Am Montag, 22. August 2016 17:10:21 UTC+2 schrieb Steinar Bang:
>
> I now have a PAX Web application running with a primefaces GUI and mock
> data in the beans:
> https://github.com/steinarb/ukelonn/tree/using-primefaces/ukelonn.bundle
>
> https://github.com/steinarb/ukelonn/blob/using-primefaces/ukelonn.bundle/src/main/webapp/ukelonn.xhtml
>
>
> https://github.com/steinarb/ukelonn/blob/using-primefaces/ukelonn.bundle/src/main/java/no/priv/bang/ukelonn/impl/UkelonnController.java
>
>
> The next step is to populate the bean(s) using JDBC and save changes
> using JDBC.
>
> My question is: what is the simplest/best way to get a PAX JDBC service
> into the UkelonnController bean?
>
> Thanks!
>
>
--
--
------------------
OPS4J - http://www.ops4j.org - [email protected]
---
You received this message because you are subscribed to the Google Groups
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.