[PAX-WEB] "Transactional" approach to register web items in HS/WS

11 views
Skip to first unread message

Grzegorz Grzybek

unread,
Jun 18, 2018, 6:59:16 AM6/18/18
to op...@googlegroups.com
Hello

I'm wondering about one scenario...

Background

We have:
 - org.osgi.service.http.HttpService, aka HS, which may be used to register servlets only (including "resources")
 - org.ops4j.pax.web.service.WebContainer, aka WC, which may be used to register other web items - filters, listeners, welcome files, error pages, login configurations, security constraints, etc - most (if not all) items that can be declared in WEB-INF/web.xml

The problem

While this worked for a long time and is fundamental to pax-web, I see some flaws here:
 - pax-web-extender-war, when parsing/processing WEB-INF/web.xml, acts in kind of "transactional" way - it uses visitor pattern "surounded" by calls to WebContainer#begin() and WebContainer#end() - this is not everything, the important check is org.ops4j.pax.web.service.internal.HttpServiceStarted#isWebAppWebContainerContext() which is a hacky way to check if we're actually inside "transaction" - it prevents starting the context after each servlet/filter/... from web.xml
 - non pax-web-extender-war usage is a series of registrations - and if we register, say, 10 servlets in a row, the underlying web context is restarted 10 time (see e.g., org.ops4j.pax.web.service.undertow.internal.Context#addServlet())

The proposal

I'd like to make this behavior less implicit - so we can manually "demarcate transactioins" related to web item registration - avoiding, if possible, changes to org.ops4j.pax.web.service.WebContainer interface.

What do you think?

best regards
Grzegorz Grzybek

Achim Nierbeck

unread,
Jun 19, 2018, 12:31:02 AM6/19/18
to op...@googlegroups.com
Hi Grzegorz,

AFAICR the transactional part was needed to make sure we don't restart the web-application with every change while executing the web.xml configuration.
If you find better ways. Go for it :)

regards, Achim

--
--
------------------
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

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>

Software Architect / Project Manager / Scrum Master 

Grzegorz Grzybek

unread,
Jun 19, 2018, 12:38:37 AM6/19/18
to op...@googlegroups.com
Hi

2018-06-19 6:31 GMT+02:00 'Achim Nierbeck' via OPS4J <op...@googlegroups.com>:
Hi Grzegorz,

AFAICR the transactional part was needed to make sure we don't restart the web-application with every change while executing the web.xml configuration.
If you find better ways. Go for it :)

Yes - it works with web.xml only (pax-web-extender-war and its visitors). Without changing API of WebContainer we can't do much - but (referring to my 2nd email), I can create a ManagedServiceFactory that monitors etc/org.ops4j.pax.web.context-<name>.cfg factory PIDs and uses the configs to alter http contexts of choice - and because it'll be (that's my plan) part of pax-web-runtime bundle, I can use protected and non exposed methods of serviceController to "demarcate" transactions.

The WebContainer.end() method is perfect to ... end the transaction, but WebContainer.begin() is called only by pax-web-extender-war visitors and it'll be tricky to make it more generic - but maybe I can think of something.

regards
Grzegorz Grzybek

françois papon

unread,
Jul 16, 2018, 12:41:52 AM7/16/18
to op...@googlegroups.com
Hi,

I'm very interested by this and I like the idea of the ManagedServiceFactory !

Let me know if I can help :)

regards,

François

Grzegorz Grzybek

unread,
Jul 16, 2018, 1:06:33 AM7/16/18
to op...@googlegroups.com
Hello

I just got back from my holidays. Actually the ManagedServiceFactory idea is implemented and described here: https://ops4j1.jira.com/wiki/spaces/paxweb/pages/354025473/HTTP+Context+processing

If you think there's place for improvements (and there surely is!), please suggest/implement.

Thanks!
best regards
Grzegorz Grzybek

françois papon

unread,
Jul 16, 2018, 1:17:49 AM7/16/18
to op...@googlegroups.com
Great !

I take a look ;)

Thanks !

François
Reply all
Reply to author
Forward
0 new messages