You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Lukasz Lenart <lu...@apache.org> on 2014/12/13 09:37:41 UTC

Few ideas related to Struts 3

Hi,

I would like to share few ideas I have that should be
implemented/introduced in Struts 3.

Request/Response wrappers
Right now user can access raw Request or Response which is quite often
a bad idea. I would like to wrap them with custom interfaces with
default implementation - this will allow simplify testing but also do
things like replacing request parameters with new set (ie. to perform
sanity check).

No more Strings
We are passing Strings all over the framework - they represents
expressions, parameters and other different things. Quite often we mix
Strings with different meaning in the same List or Map - it's very
confusing trying to figure out if I can treat given value safe (can it
be an expression?) or if it's a raw value (I need access to request
param).
To avoid such situations I want to introduce dedicated interfaces that
will represents meaning of its value (RequestParam,
InterceptorExpression, UserExpression, etc)

wdyt?


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Few ideas related to Struts 3

Posted by Lukasz Lenart <lu...@apache.org>.
2014-12-15 17:23 GMT+01:00 Ken McWilliams <ke...@gmail.com>:
> +1 for the request/response wrappers. Have you had a chance to check out:
> https://tiles.apache.org/tiles-request/   ?

Thanks, will do!

> +1 for getting rid of Strings. Could see the benefit of what you say, but
> if you only meant getting rid of const Strings in favour of enums that
> alone would be pretty nice.

That (constants) also should be cleaned up - Enums or Singleton
instances - not sure which is better. With singleton users can
implement they own constants' behaviour ie.

interface DevMode extends StrutsConstant {...}

class MyDevMode implements DevMode {...}

and it's easier to inject instance of an interfaces than String ;-)


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Few ideas related to Struts 3

Posted by Dave Newton <da...@gmail.com>.
Steven Benitez wrote:
> I said:
>> I prefer strong decoupling between layers; accessing Servlet spec artifacts smells.
> [...] wouldn't the servlet API and Struts actions be considered controllers?

I think my view of an S2 action is that it's more of a command handler,
coincidentally called most often from the web layer.

By the time my actions are hit I don't want to care about the web any more.
I only want to care about the data I'm taking in, and the data I'm spitting out.

If I need to pre- or post-process something in that process I feel
like I'm probably
either doing it wrong, or I need to extract logic even further, or I
should use an
interceptor if it's across the app (things like etags or consistent
data munging fall
into this category, and I generally use interceptors and configuration
for that), etc.

I should note that I tend to not use the S2 annotations at all ever,
which may color
this discussion somewhat. I find them intrusive and ugly, and prefer
either convention,
or XML, precisely because I want to separate (even if only in my head)
what they're
doing vs. the nature of how data gets in and out.

YMMV, and I realize I may be a tiny minority here.

d.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Few ideas related to Struts 3

Posted by Lukasz Lenart <lu...@apache.org>.
2014-12-16 0:11 GMT+01:00 Steven Benitez <st...@gmail.com>:
>>> I much prefer a strong decoupling between layers, and accessing Servlet spec
> artifacts is a smell.
>
> Decoupling between layers is definitely a good thing, but wouldn't the
> servlet API and Struts actions both be considered the controller layer?
> Assuming so, why do you think accessing the Servlet API from the controller
> layer is a smell? I could see a facade being good if it provides a better,
> more modern API (Servlet is pretty old), but I don't see how its a smell.

I want to have wrappers to better handle different internal use cases
or to allow override them, ie. another RCE security vulnerability was
discovered and instead of preparing a new release (that also) we can
post a workaround which is basically a new wrapper implementation that
will eliminate the vulnerability even if you cannot migrate to the
latest release.


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Few ideas related to Struts 3

Posted by Steven Benitez <st...@gmail.com>.
>> I much prefer a strong decoupling between layers, and accessing Servlet spec
artifacts is a smell.

Decoupling between layers is definitely a good thing, but wouldn't the
servlet API and Struts actions both be considered the controller layer?
Assuming so, why do you think accessing the Servlet API from the controller
layer is a smell? I could see a facade being good if it provides a better,
more modern API (Servlet is pretty old), but I don't see how its a smell.

On Mon, Dec 15, 2014 at 6:03 PM, Dave Newton <da...@gmail.com> wrote:
>
> I think it's just that-a last ditch fallback.
>
> I much prefer a strong decoupling between layers, and accessing Servlet
> spec artifacts is a smell.
> On Dec 15, 2014 5:49 PM, "Paul Benedict" <pb...@apache.org> wrote:
>
> > Why do you guys find it bad to access the raw request/response? I haven't
> > found a problem doing that as a fallback. I'd like to know what you
> think.
> >
> >
> > Cheers,
> > Paul
> >
> > On Mon, Dec 15, 2014 at 10:23 AM, Ken McWilliams <
> ken.mcwilliams@gmail.com
> > >
> > wrote:
> > >
> > > +1 for the request/response wrappers. Have you had a chance to check
> out:
> > > https://tiles.apache.org/tiles-request/   ?
> > > +1 for getting rid of Strings. Could see the benefit of what you say,
> but
> > > if you only meant getting rid of const Strings in favour of enums that
> > > alone would be pretty nice.
> > >
> > >
> > >
> > > On Sun, Dec 14, 2014 at 9:22 AM, Dave Newton <da...@gmail.com>
> > > wrote:
> > > >
> > > > Lukasz Lenart wrote:
> > > > >
> > > > > Request/Response wrappers
> > > > > Right now user can access raw Request or Response [...]
> > > >
> > > >
> > > > Seems reasonable, although I wonder if the appearance of not being
> able
> > > to
> > > > get the raw request/response will make people run away--they're very
> > used
> > > > to doing things icky.
> > > >
> > > >
> > > > > No more Strings
> > > > > We are passing Strings all over the framework - they represents
> > > > > expressions, parameters and other different things.
> > > >
> > > >
> > > > Strings are horrible things; +bunches.
> > > >
> > > > Even if they're just thin wrappers, so-called "micro types" can help
> a
> > > lot
> > > > when trying to understand what's happened, and why.
> > > >
> > > > d.
> > > >
> > >
> >
>

Re: Few ideas related to Struts 3

Posted by Dave Newton <da...@gmail.com>.
I think it's just that-a last ditch fallback.

I much prefer a strong decoupling between layers, and accessing Servlet
spec artifacts is a smell.
On Dec 15, 2014 5:49 PM, "Paul Benedict" <pb...@apache.org> wrote:

> Why do you guys find it bad to access the raw request/response? I haven't
> found a problem doing that as a fallback. I'd like to know what you think.
>
>
> Cheers,
> Paul
>
> On Mon, Dec 15, 2014 at 10:23 AM, Ken McWilliams <ken.mcwilliams@gmail.com
> >
> wrote:
> >
> > +1 for the request/response wrappers. Have you had a chance to check out:
> > https://tiles.apache.org/tiles-request/   ?
> > +1 for getting rid of Strings. Could see the benefit of what you say, but
> > if you only meant getting rid of const Strings in favour of enums that
> > alone would be pretty nice.
> >
> >
> >
> > On Sun, Dec 14, 2014 at 9:22 AM, Dave Newton <da...@gmail.com>
> > wrote:
> > >
> > > Lukasz Lenart wrote:
> > > >
> > > > Request/Response wrappers
> > > > Right now user can access raw Request or Response [...]
> > >
> > >
> > > Seems reasonable, although I wonder if the appearance of not being able
> > to
> > > get the raw request/response will make people run away--they're very
> used
> > > to doing things icky.
> > >
> > >
> > > > No more Strings
> > > > We are passing Strings all over the framework - they represents
> > > > expressions, parameters and other different things.
> > >
> > >
> > > Strings are horrible things; +bunches.
> > >
> > > Even if they're just thin wrappers, so-called "micro types" can help a
> > lot
> > > when trying to understand what's happened, and why.
> > >
> > > d.
> > >
> >
>

Re: Few ideas related to Struts 3

Posted by Ken McWilliams <ke...@gmail.com>.
Well if you're implementing a custom result type for which a currently
defined method does not exists, then you'll probably touch the response.
Although everything normal is covered. But why would you need to touch the
request (the raw request object and not an Aware-Interface) when using
Struts2? It just makes things more complicated. Also if you need the actual
request and start to pass it around it makes testing harder. Then because
of those issues people wrap the request but with the array of tools out
there everyone creates their own slightly different wrapper, the
aforementioned request framework (tiles-request) tries to find middle
ground and tries to translate between the known common types.

On Mon, Dec 15, 2014 at 3:49 PM, Paul Benedict <pb...@apache.org> wrote:
>
> Why do you guys find it bad to access the raw request/response? I haven't
> found a problem doing that as a fallback. I'd like to know what you think.
>
>
> Cheers,
> Paul
>
> On Mon, Dec 15, 2014 at 10:23 AM, Ken McWilliams <ken.mcwilliams@gmail.com
> >
> wrote:
> >
> > +1 for the request/response wrappers. Have you had a chance to check out:
> > https://tiles.apache.org/tiles-request/   ?
> > +1 for getting rid of Strings. Could see the benefit of what you say, but
> > if you only meant getting rid of const Strings in favour of enums that
> > alone would be pretty nice.
> >
> >
> >
> > On Sun, Dec 14, 2014 at 9:22 AM, Dave Newton <da...@gmail.com>
> > wrote:
> > >
> > > Lukasz Lenart wrote:
> > > >
> > > > Request/Response wrappers
> > > > Right now user can access raw Request or Response [...]
> > >
> > >
> > > Seems reasonable, although I wonder if the appearance of not being able
> > to
> > > get the raw request/response will make people run away--they're very
> used
> > > to doing things icky.
> > >
> > >
> > > > No more Strings
> > > > We are passing Strings all over the framework - they represents
> > > > expressions, parameters and other different things.
> > >
> > >
> > > Strings are horrible things; +bunches.
> > >
> > > Even if they're just thin wrappers, so-called "micro types" can help a
> > lot
> > > when trying to understand what's happened, and why.
> > >
> > > d.
> > >
> >
>

RE: Few ideas related to Struts 3

Posted by Martin Gainty <mg...@hotmail.com>.


> Date: Mon, 15 Dec 2014 16:49:32 -0600
> Subject: Re: Few ideas related to Struts 3
> From: pbenedict@apache.org
> To: dev@struts.apache.org
> 
> Why do you guys find it bad to access the raw request/response? I haven't
> found a problem doing that as a fallback. I'd like to know what you think.
MG>More than once i've had to dig out Request and Response from Struts usually to fiddle eTag
MG>or to finagle the Response for some proprietary JSON conversion 
MG>+1 for easy access to raw Request and Response
> 
> 
> Cheers,
> Paul
MG>Can we hear from the other participants?
MG>Cheers,
MG>Martin
> 
> On Mon, Dec 15, 2014 at 10:23 AM, Ken McWilliams <ke...@gmail.com>
> wrote:
> >
> > +1 for the request/response wrappers. Have you had a chance to check out:
> > https://tiles.apache.org/tiles-request/   ?
> > +1 for getting rid of Strings. Could see the benefit of what you say, but
> > if you only meant getting rid of const Strings in favour of enums that
> > alone would be pretty nice.
> >
> >
> >
> > On Sun, Dec 14, 2014 at 9:22 AM, Dave Newton <da...@gmail.com>
> > wrote:
> > >
> > > Lukasz Lenart wrote:
> > > >
> > > > Request/Response wrappers
> > > > Right now user can access raw Request or Response [...]
> > >
> > >
> > > Seems reasonable, although I wonder if the appearance of not being able
> > to
> > > get the raw request/response will make people run away--they're very used
> > > to doing things icky.
> > >
> > >
> > > > No more Strings
> > > > We are passing Strings all over the framework - they represents
> > > > expressions, parameters and other different things.
> > >
> > >
> > > Strings are horrible things; +bunches.
> > >
> > > Even if they're just thin wrappers, so-called "micro types" can help a
> > lot
> > > when trying to understand what's happened, and why.
> > >
> > > d.
> > >
> >
 		 	   		  

Re: Few ideas related to Struts 3

Posted by Paul Benedict <pb...@apache.org>.
Why do you guys find it bad to access the raw request/response? I haven't
found a problem doing that as a fallback. I'd like to know what you think.


Cheers,
Paul

On Mon, Dec 15, 2014 at 10:23 AM, Ken McWilliams <ke...@gmail.com>
wrote:
>
> +1 for the request/response wrappers. Have you had a chance to check out:
> https://tiles.apache.org/tiles-request/   ?
> +1 for getting rid of Strings. Could see the benefit of what you say, but
> if you only meant getting rid of const Strings in favour of enums that
> alone would be pretty nice.
>
>
>
> On Sun, Dec 14, 2014 at 9:22 AM, Dave Newton <da...@gmail.com>
> wrote:
> >
> > Lukasz Lenart wrote:
> > >
> > > Request/Response wrappers
> > > Right now user can access raw Request or Response [...]
> >
> >
> > Seems reasonable, although I wonder if the appearance of not being able
> to
> > get the raw request/response will make people run away--they're very used
> > to doing things icky.
> >
> >
> > > No more Strings
> > > We are passing Strings all over the framework - they represents
> > > expressions, parameters and other different things.
> >
> >
> > Strings are horrible things; +bunches.
> >
> > Even if they're just thin wrappers, so-called "micro types" can help a
> lot
> > when trying to understand what's happened, and why.
> >
> > d.
> >
>

Re: Few ideas related to Struts 3

Posted by Ken McWilliams <ke...@gmail.com>.
+1 for the request/response wrappers. Have you had a chance to check out:
https://tiles.apache.org/tiles-request/   ?
+1 for getting rid of Strings. Could see the benefit of what you say, but
if you only meant getting rid of const Strings in favour of enums that
alone would be pretty nice.



On Sun, Dec 14, 2014 at 9:22 AM, Dave Newton <da...@gmail.com> wrote:
>
> Lukasz Lenart wrote:
> >
> > Request/Response wrappers
> > Right now user can access raw Request or Response [...]
>
>
> Seems reasonable, although I wonder if the appearance of not being able to
> get the raw request/response will make people run away--they're very used
> to doing things icky.
>
>
> > No more Strings
> > We are passing Strings all over the framework - they represents
> > expressions, parameters and other different things.
>
>
> Strings are horrible things; +bunches.
>
> Even if they're just thin wrappers, so-called "micro types" can help a lot
> when trying to understand what's happened, and why.
>
> d.
>

Re: Few ideas related to Struts 3

Posted by Dave Newton <da...@gmail.com>.
Lukasz Lenart wrote:
>
> Request/Response wrappers
> Right now user can access raw Request or Response [...]


Seems reasonable, although I wonder if the appearance of not being able to
get the raw request/response will make people run away--they're very used
to doing things icky.


> No more Strings
> We are passing Strings all over the framework - they represents
> expressions, parameters and other different things.


Strings are horrible things; +bunches.

Even if they're just thin wrappers, so-called "micro types" can help a lot
when trying to understand what's happened, and why.

d.

Re: Few ideas related to Struts 3

Posted by Paul Benedict <pb...@apache.org>.
+1 to get rid of "do" support.


Cheers,
Paul

On Mon, Dec 22, 2014 at 12:34 AM, Lukasz Lenart <lu...@apache.org>
wrote:

> 2014-12-21 23:19 GMT+01:00 Paul Benedict <pb...@apache.org>:
> > Why do we support the "do" prefix at all? I don't know the answer. I'd
> just
> > like to know how it came to be.
>
> No idea :)
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>

Re: Few ideas related to Struts 3

Posted by Lukasz Lenart <lu...@apache.org>.
2014-12-21 23:19 GMT+01:00 Paul Benedict <pb...@apache.org>:
> Why do we support the "do" prefix at all? I don't know the answer. I'd just
> like to know how it came to be.

No idea :)


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Few ideas related to Struts 3

Posted by Paul Benedict <pb...@apache.org>.
Why do we support the "do" prefix at all? I don't know the answer. I'd just
like to know how it came to be.

PS: I am in favor of simplifying the internals of Struts. I don't like
having multiple ways of naming an execution method.


Cheers,
Paul

On Sun, Dec 21, 2014 at 1:24 PM, Lukasz Lenart <lu...@apache.org>
wrote:

> What do you think about throwing away support for the "do" prefix? If
> an action method cannot be found, the framework will prepend the "do"
> prefix to it and will try again, this pushes a bit of hassle into flow
> logic. Dropping support will allow simplify code in few places.
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>

Re: Few ideas related to Struts 3

Posted by Dave Newton <da...@gmail.com>.
+1, no real need for it.

On Sun, Dec 21, 2014 at 2:24 PM, Lukasz Lenart <lu...@apache.org> wrote:
> What do you think about throwing away support for the "do" prefix? If
> an action method cannot be found, the framework will prepend the "do"
> prefix to it and will try again, this pushes a bit of hassle into flow
> logic. Dropping support will allow simplify code in few places.
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>



-- 
e: davelnewton@gmail.com
m: 908-380-8699
s: davelnewton_skype
t: @dave_newton
b: Bucky Bits
g: davelnewton
so: Dave Newton

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Few ideas related to Struts 3

Posted by Lukasz Lenart <lu...@apache.org>.
What do you think about throwing away support for the "do" prefix? If
an action method cannot be found, the framework will prepend the "do"
prefix to it and will try again, this pushes a bit of hassle into flow
logic. Dropping support will allow simplify code in few places.


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org