[
https://issues.apache.org/jira/browse/LABS-301?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Simone Gianni resolved LABS-301.
--------------------------------
Resolution: Fixed
Fix Version/s: (was: Next)
Current
The Binder is not at work anymore, instead there is an OnDemandBinder.
It works on property access, so no need for getters and setters anymore. If a
web handler has a correctly named field (like private User sessionUser), when
there is a read on the field, it is fetched from the proper context space (in
the example, session), and the opposite happens when it is written.
This brings a number of advantages. First of all it fixes this bug. It also
brings the conversion on demand, saving resources in the case a handler
declares a number of fields but a certain doMethod uses only a few.
Since I was there, I also set up a cache to avoid continuous conversions. Right
now it is at work only on the session, probably making it work also on the
request could be an option, while it is unneded on read only or write only
areas, like parameters, headers and so on.
Having it still a declarative style (fields must be declared), it keeps the
caching option open.
While this is a great simplification and improves performances, we had to weave
a few functionalities :
- Using getters and setters it was possible to specify validation. This was
nice, but in reality rarely used, we don't want our web users to see an
exception, so usually this is handled manually anyway. Also, every web
developer is used to check if a given attribute is present or not in the
session or in a cookie.
- Using getters and setters we had a single point to eventually provide default
values. This is not present anymore. This was an interesting point, so it
should be reimplemented.
- When composing using aspects, there is no way to add a field if not declaring
it public, which is not nice, so getters and setters are a good way to add a
property to an existing class using an aspect. This is why validation,
formatters etc.. work on getter and setters and not on properties. This is
another important point, which should be reimplemented.
So, to give access to these two advantages of using getters and setters,
LABS-305 tracks reimplementation of it.
While setters are not a problem at all (when fetching, if a setter is present,
call the setter with the value, instead of returning it directly, which
basically is a lazy-setter-call similar to the one implemented my many ORMs),
getters could be a bit more tricky. When a field is written to, instead of
using that value, call the getter instead .. easy to implement, but not easy to
understand from a user POV.
> [web] Binding does not work intuitively when a call to another handler is made
> ------------------------------------------------------------------------------
>
> Key: LABS-301
> URL: https://issues.apache.org/jira/browse/LABS-301
> Project: Labs
> Issue Type: Bug
> Components: Magma
> Affects Versions: Current
> Reporter: Simone Gianni
> Assignee: Simone Gianni
> Fix For: Current
>
>
> The web binder calls getters on the handler after a do or handle methods
> returns. Unfortunately, this means that the following code :
> HandlerA.doSomething
> this.sessionData = "usethis";
> root().handleB().doSomethingElse();
> HandlerB.doSomethingElse
> System.out.println(this.sessionData);
> will not work as expected by the user. Since doSomethingElse is called before
> the end of doSomething, the session will not contain the value when it is
> accessed from there.
> Another approach is required to achieve this functionality.
> A good idea is to weave the getters and setters, and instead ask the user to
> declare the environment variables in handlers as public fields.
> This way, the possibility to cache web stuff is still preserved, cause which
> environment variables could be used will still be visible. Also, unit testing
> is still applicable. Moreover, declaring getters and setters would still be
> possible to accomodate other IOC systems.
> The Binder would act on get and set joinpoints. This would both solve this
> bug, increase performances because only needed variables are converted, and
> simplify all the web handler mechanics, both for the user and for developers.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]