You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Carsten Ziegeler <cz...@apache.org> on 2021/09/29 16:40:39 UTC
Add builders to create request/response objects
Hi,
in https://issues.apache.org/jira/browse/SLING-10840 we have some
lengthy discussion about the servlet helpers bundle, where and how it
should be used and the problem with it implementing ProviderType interfaces.
The gist of it, is that the main purpose of this bundle is to be used in
tests. It provides mocks for several things.
Due to it implementing ProviderType it is a little bit more dangerouns
to use it in production as it constantly needs to be updated whenever
the Sling api changes (the relevant packages have changes).
Now, as suggested in that ticket, we should probably have some proper
API to create an initial request and response without backing it out or
wrapping an existing request / response.
The suggestion is to provide two builder classes (similar or same) as in
the servlet helpers bundle but make it more prominent. All required
implementation classes would be private.
We could either move these to the API bundle, where the interfaces are
defined. Or to the Engine bundle which contains the processor interface
which is probably the most common use case for these.
I don't have any real preference, API is probably the better location as
this is general purpose functionality which can be used without the
processor.
WDYT?
Regards
Carsten
--
Carsten Ziegeler
Adobe
cziegeler@apache.org
Re: Add builders to create request/response objects
Posted by Oliver Lietz <ap...@oliverlietz.de>.
On Wednesday, 29 September 2021 18:40:39 CEST Carsten Ziegeler wrote:
> Hi,
>
> in https://issues.apache.org/jira/browse/SLING-10840 we have some
> lengthy discussion about the servlet helpers bundle, where and how it
> should be used and the problem with it implementing ProviderType interfaces.
>
> The gist of it, is that the main purpose of this bundle is to be used in
> tests. It provides mocks for several things.
> Due to it implementing ProviderType it is a little bit more dangerouns
> to use it in production as it constantly needs to be updated whenever
> the Sling api changes (the relevant packages have changes).
>
> Now, as suggested in that ticket, we should probably have some proper
> API to create an initial request and response without backing it out or
> wrapping an existing request / response.
>
> The suggestion is to provide two builder classes (similar or same) as in
> the servlet helpers bundle but make it more prominent. All required
> implementation classes would be private.
>
> We could either move these to the API bundle, where the interfaces are
> defined. Or to the Engine bundle which contains the processor interface
> which is probably the most common use case for these.
>
> I don't have any real preference, API is probably the better location as
> this is general purpose functionality which can be used without the
> processor.
>
> WDYT?
+1 for builders in API bundle
O.
> Regards
> Carsten
Re: Add builders to create request/response objects
Posted by Bertrand Delacretaz <bd...@apache.org>.
On Thu, Sep 30, 2021 at 10:23 AM Carsten Ziegeler <cz...@apache.org> wrote:
> ...I'll probably create a prototype in the whiteboard which we then can
> further discuss..
+1, and note that the InternalRequest and child classes at [1] already
define a "builder protocol" that can probably apply in the same way to
creating a Request object. We'll probably need to unify those, maybe
create a Java interface for that builder that both variants implement.
-Bertrand
Re: Add builders to create request/response objects
Posted by Carsten Ziegeler <cz...@apache.org>.
Hi,
Am 30.09.2021 um 09:47 schrieb Bertrand Delacretaz:
> Hi,
>
> On Wed, Sep 29, 2021 at 6:40 PM Carsten Ziegeler <cz...@apache.org> wrote:
>> ...we should probably have some proper
>> API to create an initial request and response without backing it out or
>> wrapping an existing request / response...
>
> IIUC you mean a service or utility class that provides objects that
> implement SlingHttpServletRequest and SlingHttpServletResponse and can
> be used for example with the SlingRequestProcessor service?
>
> That works for me, just wanted to make sure I understand.
>
yes, right - I guess some builder classes we add to the API that create
objects implementing SlingHttpServletRequest and SlingHttpServletResponse
I'll probably create a prototype in the whiteboard which we then can
further discuss
Regards
Carsten
>> ...I don't have any real preference, API is probably the better location as
>> this is general purpose functionality which can be used without the
>> processor...
>
> I agree that the API bundle is a good place, with the new class or
> service in its own package to avoid interference with other things.
>
> -Bertrand
>
--
Carsten Ziegeler
Adobe
cziegeler@apache.org
Re: Add builders to create request/response objects
Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,
On Wed, Sep 29, 2021 at 6:40 PM Carsten Ziegeler <cz...@apache.org> wrote:
> ...we should probably have some proper
> API to create an initial request and response without backing it out or
> wrapping an existing request / response...
IIUC you mean a service or utility class that provides objects that
implement SlingHttpServletRequest and SlingHttpServletResponse and can
be used for example with the SlingRequestProcessor service?
That works for me, just wanted to make sure I understand.
> ...I don't have any real preference, API is probably the better location as
> this is general purpose functionality which can be used without the
> processor...
I agree that the API bundle is a good place, with the new class or
service in its own package to avoid interference with other things.
-Bertrand
Re: Add builders to create request/response objects
Posted by Carsten Ziegeler <cz...@apache.org>.
I've created an issue and did a first step at the implementation at
https://issues.apache.org/jira/browse/SLING-10871
The api is based on what we have in servlet helpers today, with some
fixes and minor changes. In addition I added some methods which allow to
reuse parts of an existing request like the http context, the request
dispatcher or the session. All optional of course.
My plan is to apply the PR to the main branch and then we can see
whether we need more fine tuning additions before a first release.
Regards
Carsten
Am 29.09.2021 um 18:40 schrieb Carsten Ziegeler:
> Hi,
>
> in https://issues.apache.org/jira/browse/SLING-10840 we have some
> lengthy discussion about the servlet helpers bundle, where and how it
> should be used and the problem with it implementing ProviderType
> interfaces.
>
> The gist of it, is that the main purpose of this bundle is to be used in
> tests. It provides mocks for several things.
> Due to it implementing ProviderType it is a little bit more dangerouns
> to use it in production as it constantly needs to be updated whenever
> the Sling api changes (the relevant packages have changes).
>
> Now, as suggested in that ticket, we should probably have some proper
> API to create an initial request and response without backing it out or
> wrapping an existing request / response.
>
> The suggestion is to provide two builder classes (similar or same) as in
> the servlet helpers bundle but make it more prominent. All required
> implementation classes would be private.
>
> We could either move these to the API bundle, where the interfaces are
> defined. Or to the Engine bundle which contains the processor interface
> which is probably the most common use case for these.
>
> I don't have any real preference, API is probably the better location as
> this is general purpose functionality which can be used without the
> processor.
>
> WDYT?
>
>
> Regards
> Carsten
--
Carsten Ziegeler
Adobe
cziegeler@apache.org