On Mon, Jan 8, 2018 at 11:51 AM, Clément Aubin
<aubincleme(a)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/xwi…
[2]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwi…