[PAX WEB] Unique ID for ServletEvent

3 views
Skip to first unread message

Miroslav Beranič

unread,
Feb 7, 2020, 8:19:24 PM2/7/20
to op...@googlegroups.com
Hi all,

I am back at the existing PAX Web Whiteboard sample, located at:

In the example HttpContextMapping service has different name, all four of them; also all four related URL Patterns are all different from each other - /whiteboard, /whiteboard2, and /whiteboard3, /whiteboard4.
For now, let's say there are only two with context path defined - foo and bar.

When deployed in Karaf and checked from inside Karaf shell with command http:list it prints all of the endpoints, but the Context path ( prefix ) is missing.

It just lists endpoints without the context path. Before you start to say, this is a problem inside Karaf, let me explain.

If we imagine for the moment, if one would change/align all the endpoint URL Patterns to the same url pattern = /whiteboard, the expected output would be something/exactly like this:

/foo/whiteboard
/bar/whiteboard

but it is not, it is just one line with endpoint:

/whiteboard

I've checked Karaf's source code, and this is a topic for another mailing list, but for now what I can say is -- the client ( in this case Karaf ) can not tell one servlet event from another.

Because there is no "unique id" to distinguish one from another, when it goes from one state to another. I would say, this is a root cause for how Karaf ( incorrectly ) handles Servlet list.

I would recommend that the already existing ID from ServletModel is re-used, in a way, that additional field is added to the ServletEvent class as final and set in the constructor ( final String id ). This has to be updated in one place only - class HttpServiceStarted, in method servletEvent, where servlet event is created from servlet model.

I've changed this and with some minor updates in Karaf, I can see different endpoints.

/foo/whiteboard
/bar/whiteboard

In Karaf, Servlet Events are stored in a map, by servlet name as a key. Here is just a short rundown of some other updates I've done, but this is for Karaf mailing list. But all was routed from this, that there is no way, to identify one Servlet event from another - if they have the same Servlet name and alias or url pattern -- but they are not the same, as the context path is different.

I ask here if this sounds like a valid solution/path or do you guys have some other ways to go about this? If this sounds ok to you, I would be glad to share my code changes.

Apache Karaf 4.3.0
PAX Web 7.2.13 ( but the code is the same in the master branch also )


Kind Regards,
Miroslav

Grzegorz Grzybek

unread,
Feb 26, 2020, 5:27:55 AM2/26/20
to op...@googlegroups.com
Hello

Thanks for the analysis. I've created https://ops4j1.jira.com/browse/PAXWEB-1253 to track this issue.

I'm in the process of OSGi CMPN R7 implementation in Pax Web 8 and the model has changed slightly (servlet model may be associated with more osgi context models / servlet context models), so I need to reflect this change in Karaf commands as well...

regards
Grzegorz Grzybek

--
--
------------------
OPS4J - http://www.ops4j.org - op...@googlegroups.com

---
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 ops4j+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ops4j/CA%2B3Fds5EK8HaNU%3D3e32JxkO8StRjfCRhJ_vP-YVyD4LSPN405A%40mail.gmail.com.

Achim Nierbeck

unread,
Feb 26, 2020, 6:09:13 AM2/26/20
to op...@googlegroups.com
Hi,

yes sounds like a "corner" case I didn't think of when implementing the karaf commands and making sure the servlet events where according to the spec.
thanks for pointing that out.

regards, Achim




--

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Reply all
Reply to author
Forward
0 new messages