Seems, nice. +1 2018-01-08 23:01 GMT+01:00 Clément Aubin <aubincl...@gmail.com>:
> On 01/08/2018 12:29 PM, Thomas Mortagne wrote: > > Sounds good. > > > > +1 for RedirectResponse interface > > Nice; just created XWIKI-14948 to deal with this particular interface. > We should be able to find more decorators in the near future. > > > On Mon, Jan 8, 2018 at 11:51 AM, Clément Aubin <aubincl...@gmail.com> > wrote: > >> Hi devs, > >> > >> This proposal is related to the following discussion on IRC : > >> https://botbot.me/freenode/xwiki/2018-01-08/?msg=95495049&page=5 > >> > >> Abstract: We currently have an abstraction of the notion of a > >> "container" defined in xwiki-platform-container-api [1]. This > >> abstraction is very basic, but allows XWiki to support two different > >> types of containers : Servlet and Portlet, and maybe support other types > >> in the future. > >> > >> Problem: As those abstractions are very basic, it's quite hard to use > >> them without downcasting them. A common example is the following: if I > >> want to send a redirection in a Response object [2], I will need either > >> to forge my own output that returns the correct HTTP code, with the > >> correct header, etc … or I can downcast the given Response to all of its > >> possible implementations and, for each implementation, find the correct > >> method to use for sending a redirect. > >> > >> In order to avoid such tricks in the future, we could implement > >> decorators that will allow Request and Response implementations to > >> handle certain actions. In my previous example, a Response implementing > >> RedirectResponse would expose a method `#sendRedirect(String url)`. The > >> advantage here is that we don't really need to know on which Response > >> implementation we are working on. > >> > >> WDYT ? > >> > >> Thanks, > >> > >> Clément > >> > >> [1] > >> https://github.com/xwiki/xwiki-platform/tree/master/ > xwiki-platform-core/xwiki-platform-containers/xwiki- > platform-container-api/src/main/java/org/xwiki/container > >> > >> [2] > >> https://github.com/xwiki/xwiki-platform/blob/master/ > xwiki-platform-core/xwiki-platform-containers/xwiki- > platform-container-api/src/main/java/org/xwiki/container/Response.java > > > > > > > -- Guillaume Delhumeau (guillaume.delhum...@xwiki.com) Research & Development Engineer at XWiki SAS Committer on the XWiki.org project