Hello So I tried > @Reference(target = "(osgi.web.contextname=authservice)") > and that worked just fine: the setter was called and the @Activate > method was called and the bundle became active. >
I just checked what pax web is doing and it's: properties.put(WebContainerConstants.PROPERTY_SERVLETCONTEXT_NAME, context.getServletContext().getServletContextName()); PROPERTY_SERVLETCONTEXT_NAME == "osgi.web.contextname" I just checked specification 128.3.4 Publishing the Servlet Context (OSGi CMPN) and there's only "osgi.web.contextpath" property, no "osgi.web.contextname"... I'll review in Pax Web 8, but for now, you have the answer. If Pax Web registered not: context.getServletContext().getServletContextName(); but context.getServletContext().getContextPath(); you'd have the path. Now you have the name, so your @Reference(target = "(osgi.web.contextname=authservice)") should work. regards Grzegorz Grzybek pon., 23 mar 2020 o 22:34 Steinar Bang <[email protected]> napisał(a): > >>>>> Steinar Bang <[email protected]>: > > >> [snip!] > >>> objectClass = [javax.servlet.ServletContext] > >>> osgi.web.contextname = authservice > >>> osgi.web.contextpath = /authservice > >>> osgi.web.symbolicname = no.priv.bang.authservice.web.security > > >>> Hm... so why don't I get service injections when trying to filter on > the properties > > >> Because I tried the following: > >> osgi.web.symbolicname=authservice > >> osgi.web.contextpath=/authservice > > >> It's pretty obvious why osgi.web.symbolicname didn't work. :-) > > >> But osgi.web.contextpath should have worked. Why didn't it work? Did I > >> fool myself while testing? I think I will try that one again. > > > Didn't help. > > @Reference(target = "(osgi.web.webcontext=/authservice)") > > doesn't match. > > > A breakpoint in the setter is never triggered and the bundle is never > > activated (since the reference isn't satisfied). > > I started thinking maybe it was the leading / on the match value that > was the problem? Maybe the / has special significance for the LDAP > syntax? Maybe the match has to start with an alphanumeric character...? > Or something...? > > So I tried > @Reference(target = "(osgi.web.contextname=authservice)") > and that worked just fine: the setter was called and the @Activate > method was called and the bundle became active. > > The problem with using this was that osgi.web.contextname wasn't in the > list of properties mentioned in what I assume will be the next > generation of the web web whiteboard. > > So what to do? > > Presumably > @Reference(target = > "(osgi.web.symbolicname=no.priv.bang.authservice.web.security)") > will also work, but I don't like it (it's long, cluttered and sort of > misleading) > > -- > -- > ------------------ > 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/86ftdyu566.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/CAAdXmhoqS5iDO9G33ENtzjBOrUEzRPMmEjF96aaP0DiaU8m04A%40mail.gmail.com.
