>>>>> Steinar Bang <[email protected]>: > I already have OSGi service injections, and I would have been able to > hand those over to a servlet. [snip!] > But the problem is how to get the captured OSGi services into the > beans that are created on need by the JSF servlet...?
> I could stuff them into some singleton that the beans query from their > constructor, but singletons with static accessors always feels > wrong... An update after reading about JSF and beans: One possibility would have been to use an @ApplicationScope'd bean, and added a reference to my local activator object, holding the injected OSGi services. Then I could set up all of the other beans to have the application scoped bean injected, and they would all get access to the OSGi services through that. But to an the application scoped bean I would need to have the servletcontext of the JSF FacesServlet. And I don't have that context, nor do I have any way of retrieving it, since the FacesServlet is created by some war-magic behind the scenes. The Pax Web FAQ recommends using a static method to get the BundleContext: https://ops4j1.jira.com/wiki/display/ops4j/Pax+Web+Extender+-+War+-+FAQ#PaxWebExtender-War-FAQ-NowthatIdeployedmywar,howcanIgetaservicefromOSGiServiceRegistry? I don't need the bundle context, since any services I need will already be resolved for me, but I can use the static method approach to get a local reference to the resolved services. Not pretty... but at least I *know* this will work...:-) (But if someone can tell me how to get the ServletContext of the FacesServlet, I will try the application scoped bean approach) -- -- ------------------ 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.
