[Geoserver-devel] The REST based OGC services conundrum: is Spring MVC actually applicable?

Hi,
as you know we have a WFS 3.0 prototype implementation in community land. Right now it’s implemented
mostly as an internal proxy to WFS 2.0:

https://github.com/geoserver/geoserver/blob/master/src/community/wfs3/src/main/java/org/geoserver/wfs3/WFS3Filter.java

https://github.com/geoserver/geoserver/blob/master/src/community/wfs3/src/main/java/org/geoserver/wfs3/DefaultWebFeatureService30.java

The other possible alternative for implementation would have been to use Spring MVC… however that would have come
with a very high cost, as it would have broken solid all usage of DispatcherCallback, making WFS3 problematic to use
in the GeoServer ecosystem.
Here is a small recap of supported functionalities that would be broken by a WFS implemnetation not going go through the Dispatcher and does
not invoke DispatcherCallback:

  • Version negotiation
  • Workspace specific services
  • Monitor extension
  • Service security

And then add to that whatever extra callback is present in vendor implementations of GeoServer (in my experience it’s one
of the most used callbacks).

Now, not going throught the Dispatcher does not equate with not calling DispatcherCallback, but it’s pretty close.
The main issue is that not all callbacks are read only, and each method allows implementors to alter the call in many ways:

  • init allows to fiddle with kvp maps, allowing to alter them, or redefine them from scratch

  • serviceDispatcher allows to re-route to another service (we do that, for example, in the ncwms module, and I believe in the WFS NSG modules too)

  • operationDispatched allows to change the parsed request parameters, or to re-route to an entirely different call (done multiple times in vendor extensions, e.g., to bypass GeoServer completely and call other services in the infrastructure that could compute some GetMap responses with higher efficiency)

  • operationExecuted allows to rewrite the response object (e…g, to enrich/decorate/filter the response)

  • responseDispatched allows to change the response object that will encode the response (allows for alternate encoding implementation)

  • finished… is just finished, no changes allowed here :slight_smile:
    In Spring MVC I see none of this flexibility, yes one can add interceptors, but they are working at low level HTTP and would end up being shared with the configuration API, and believe one can build proxies around controllers, but their support of the above would seem rather limited compared to the above (change http kvp, change single method request and response objects). So even adding a proxy around the controller, the support for callback would be severely limited and would not fit the existing architecture, breaking them in case WFS 3 is used.

The above makes me believe MVC is not actually viable to implement OGC resource oriented services, as a result, I’ll probably continue
to work on the current proxy based approach, and see how deep the rabbit hole is.

But… I’d like to hear from others, that surely have more MVC famliarity than me, and see if there is any viable alternative

Cheers
Andrea

···

GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via di Montramito 3/A
55054 Massarosa (LU)
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003

Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for the attention and use of the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree June, 30 2003, no.196 - Italy’s New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying, distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the information in this message that has been received in error. The sender does not give any warranty or accept liability as the content, accuracy or completeness of sent messages and accepts no responsibility for changes made after they were sent or for other risks which arise as a result of e-mail transmission, viruses, etc.

Thanks for this discussion/background Andrea.

While I can think of bad ways to fake an interceptor kind of workflow (give each request a scratch area to work with, call all the interceptors and let them collaborate in the scratch area) it seems like a lot of effort to duplicate something we already have working with the dispatcher.

Other idea was to look for any examples of using spring mvc with OGC services … a long shot but I found: https://github.com/gvSIGAssociation/gvsig-web-fw

···


Jody Garnett

On Thu, Apr 26, 2018 at 7:05 AM, Jody Garnett <jody.garnett@anonymised.com>
wrote:

Thanks for this discussion/background Andrea.

While I can think of bad ways to fake an interceptor kind of workflow
(give each request a scratch area to work with, call all the interceptors
and let them collaborate in the scratch area) it seems like a lot of effort
to duplicate something we already have working with the dispatcher.

See again my first mail, the issue is not duplicating the work, it's that
afaik it's not possible to get into Spring MVC and then jump out of it if
any dispatcher
callback modifies the service, method, operation. If DispatcherCallback was
a read only interface it would have been possible to mock up something,
even if
just partially covering the actual needs.

Other idea was to look for any examples of using spring mvc with OGC
services ... a long shot but I found: https://github.com/
gvSIGAssociation/gvsig-web-fw

Did not think of that, good idea. Checked, that thing is a set of custom
services sitting between a thin client and a full OGC service,
providing spot information from the caps documents, e.g., "give me the list
of CRS supported by that WMTS".
Again, if designed from day one with Spring MVC, I guess we could have had
OGC services designed around that, the issue
is the richness of DispatcherCallback, along with its ability to reroute
requests, to alter the call in significant ways,
and the widespread usage we make of that both in GeoServer source code, and
in vendor customizations in general.

Cheers
Andrea

==

GeoServer Professional Services from the experts! Visit http://goo.gl/it488V
for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via di Montramito 3/A
55054 Massarosa (LU)
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003

Le informazioni contenute in questo messaggio di posta elettronica e/o
nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il
loro utilizzo è consentito esclusivamente al destinatario del messaggio,
per le finalità indicate nel messaggio stesso. Qualora riceviate questo
messaggio senza esserne il destinatario, Vi preghiamo cortesemente di
darcene notizia via e-mail e di procedere alla distruzione del messaggio
stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso,
divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od
utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for
the attention and use of the named addressee(s) and may be confidential or
proprietary in nature or covered by the provisions of privacy act
(Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection
Code).Any use not in accord with its purpose, any disclosure, reproduction,
copying, distribution, or either dissemination, either whole or partial, is
strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact
immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender
does not give any warranty or accept liability as the content, accuracy or
completeness of sent messages and accepts no responsibility for changes
made after they were sent or for other risks which arise as a result of
e-mail transmission, viruses, etc.