Hello Steinar Bang I just checked with pax-web 7 (In Fuse 6) and I could check the service properties of hawtio WAR:
JBossFuse:karaf@root> bundle-services -p 283 io.hawt.hawtio-web provides: ---------------------------------- bundle.id = 283 objectClass = [org.ops4j.pax.web.service.WebAppDependencyHolder] service.id = 794 ---- objectClass = [*javax.servlet.ServletContext*] osgi.web.contextpath = */hawtio* osgi.web.symbolicname = *io.hawt.hawtio-web* .... As you can see, the properties you're looking for are there. Please check `bundle-services -p` command (or Karaf 4 equivalent) to check what can you filter by. I only now see that Pax Web doesn't properly associate ServletContextHelper services with actual contexts - I'm working on it in Pax Web 8 and I hope to backport some important fixes down to Pax Web 7 later. regards Grzegorz Grzybek pon., 23 mar 2020 o 00:25 Steinar Bang <[email protected]> napisał(a): > >>>>> Grzegorz Grzybek <[email protected] > >: > > >> Will it be possible to get a ServletContext OSGi service injected into a > >> @Reference, when using the web whiteboard of OSGi 7? > >> > > > Sure - it's described in 128.3.4 Publishing the Servlet Context chapter > of > > CMPN specification and I think it should already be a case (at least > that's > > what I remember from JBoss Fuse (based on Karaf)). > > Thanks Grzegorz! > > I've been successful in injecting the service, but not in filtering to > get the right service. > > I got injections in this variant: > @Reference > public void setServletContext(ServletContext context) { > this.context = context; > } > > But I got no injections in: > @Reference(target = "(osgi.web.symbolicname=authservice)") > public void setServletContext(ServletContext context) { > this.context = context; > } > > And I got no injections in: > @Reference(target = "(osgi.web.contextpath=/authservice)") > public void setServletContext(ServletContext context) { > this.context = context; > } > > The ServletContextHelper creating the context, is: > @Component( > property= { > > HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME+"=authservice", > > HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH+"=/authservice"}, > service=ServletContextHelper.class, > immediate=true > ) > public class AuthserviceServletContextHelper extends ServletContextHelper > { } > > > About actual Whiteboard R7 annotations - support for those has yet to be > > added to Pax Web. > > Looking forward to this happening. > > Thanks again! > > -- > -- > ------------------ > 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]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ops4j/86zhc8t1ji.fsf%40dod.no. > -- -- ------------------ 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]. To view this discussion on the web visit https://groups.google.com/d/msgid/ops4j/CAAdXmhrxppzfpzJFHFsuyN9g4upiG5U4DSmTfg4R0PkEmTPBjw%40mail.gmail.com.
