My other question would be if you are "Unregistering " the default context should it still show up in the HttpServiceRuntime.getRuntimeDTO().servletContextDTOs ? It does now
Dave On Sunday, September 18, 2022 at 8:43:33 AM UTC-5 [email protected] wrote: > It will be a little tricky to send my whole project in , let me see what I > can do , however I have reviewed the test cases in the link provided and it > looks like you are not covering my case ... > > I do not see a test where ... > > Register the default handler -> HttpContext defaultContext = wc. > createDefaultHttpContext(); , not sure if this also creates a > ServletContextHelper > wrapper as well > > Then create a servlet that attaches to it , but do not call the servlet , > just check it is added > > Register the default override with a high service ranking . > > See if this happens > org.ops4j.pax.web.service.spi.servlet.OsgiServletContext - Unegistering > OsgiServletContext{model=OsgiContextModel{WB,id=OCM-1,name='default',path='/' > org.ops4j.pax.web.service.spi.servlet.OsgiServletContext - Registering > OsgiServletContext{model=OsgiContextModel{WB,id=OCM-2,name='default',path='/', > > And then see if the servlet is in the new context ... > > The override testcases seem to all create the override first before the > first servlet is registered OR you are changing the path in the default > context ... > > Dave > > > > On Sun, Sep 18, 2022 at 8:06 AM Grzegorz Grzybek <[email protected]> > wrote: > >> Hello >> >> Actually, the initial reason of entire Pax Web 8 refactoring was the >> context handling - ability to register one servlet into multiple contexts >> and multiple servlets into one context. >> There are really lot of integration tests that show exactly this. >> >> I'd have to see your example and check what's the problem there - you >> seem to correctly override "default" whiteboard context with "/" path and >> higher ranking, so it should work. >> >> >> https://github.com/ops4j/org.ops4j.pax.web/tree/web-8.0.9/samples/samples-whiteboard/whiteboard-ds >> >> is and example of SCR registration of multiple web elements and contexts. >> >> This integration test ( >> https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.9/pax-web-itest/pax-web-itest-server/src/test/java/org/ops4j/pax/web/itest/server/whiteboard/WhiteboardAndHttpServiceTest.java#L198) >> >> - overridenDefaultContextsWithWhiteboardServlet() shows how "default" + >> "/" context is overriden. >> >> Could you please share your project? It can be attached to an issue in >> https://github.com/ops4j/org.ops4j.pax.web/issues >> >> kind regards >> Grzegorz Grzybek >> >> niedz., 18 wrz 2022 o 14:16 Dave Smith <[email protected]> napisaĆ(a): >> >>> What is the correct way to override the default servlet context? I am >>> doing this... >>> >>> @Component(service = ServletContextHelper.class,property = { >>> Constants.SERVICE_RANKING+":Integer="+Integer.MAX_VALUE}) >>> @HttpWhiteboardContext(name = "default",path = "/") >>> public class NoSecurityContextImpl extends ServletContextHelper >>> { >>> >>> What I am seeing is if a servlet is registered BEFORE the new default >>> context it just seems to disappear, anything after gets put in the new >>> default. When I call HttpServiceRuntime.servletDTOs I see the original >>> default context with no servlets attached to it and my overridden one with >>> the servlets that were registered after. >>> failedServletDTOs,failedServletContextDTOs are empty. If I remove my >>> override the servlets appear. >>> >>> What is weird is it looks like the servlet is getting put into the right >>> context if I read the log correctly ... >>> >>> Registering >>> ServletModel{id=ServletModel-4,name='com.candatag.k8s.zoo.servlet.ReadyProbe',urlPatterns=[/osgi/started],contexts=[{WB,OCM-2,default,/}]} >>> >>> INFO org.ops4j.pax.web.service.spi.servlet.OsgiServletContext - >>> Unegistering >>> OsgiServletContext{model=OsgiContextModel{WB,id=OCM-1,name='default',path='/',bundle=org.ops4j.pax.web.pax-web-extender-whiteboard,context=(supplier)}} >>> >>> as OSGi service for "/" context path >>> >>> Registering >>> OsgiServletContext{model=OsgiContextModel{WB,id=OCM-2,name='default',path='/',bundle=com.candatag.web.util,ref={org.osgi.service.http.context.ServletContextHelper}={ >>> service.id=57, osgi.http.whiteboard.context.name=default, >>> service.bundleid=19, service.scope=bundle, service.ranking=2147483647 >>> <(214)%20748-3647>, >>> component.name=com.candatag.web.util.zoo.impl.NoSecurityContextImpl, >>> osgi.http.whiteboard.context.path=/, component.id=22}}} as OSGi service >>> for "/" context path >>> >>> Dave >>> >>> >>> >>> -- >>> -- >>> ------------------ >>> 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/CA%2BFCLu2SbiSKmN7W3-ZQqHLYCA67vF104UCVWtU77-63tcarUA%40mail.gmail.com >>> >>> <https://groups.google.com/d/msgid/ops4j/CA%2BFCLu2SbiSKmN7W3-ZQqHLYCA67vF104UCVWtU77-63tcarUA%40mail.gmail.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- >> -- >> ------------------ >> 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/CAAdXmhrMU6_5ABFc0oxevK%2BjuZVhOzxdK0cqvyTz6pCWZAM7Yg%40mail.gmail.com >> >> <https://groups.google.com/d/msgid/ops4j/CAAdXmhrMU6_5ABFc0oxevK%2BjuZVhOzxdK0cqvyTz6pCWZAM7Yg%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > -- -- ------------------ 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/00dbfa7e-affe-46bc-919b-afd100d65960n%40googlegroups.com.
