"vanyatka" wrote : ...if I only run one single facade method, and previous old
state doesn't bug me (all variables are re-initialized before used), can such
"temporal" use of fields be justified?
Sure, but you've set up a maintenance "gotcha" that is pretty easy to
violate and will be difficult to debug. Also, you'll be less likely to see the
inconsistencies exhibited in development, meaning it's likely that Peter's
"weird stuff" will happen in Production. So as a general rule, I'd avoid
this paradigm unless you can say:
1) There's no cleaner way
2) Document the hell out of it to make sure the instance var is cleansed upon each
invocation
"vanyatka" wrote : Imagine I have a chain of methods inside a SLSB.
| a calls b, b calls c, c calls d, etc.
|
| Facade method receives a parameter. I need to use that parameter down the chain of
execution. Should I put that parameter in each method declaration? Ouch ... Doesn't
look very appealing, don't you think
No, cluttered APIs are not pretty, though this approach *is* pretty foolproof.
You can also look into:
1) Store that parameter in a ThreadLocal
2) Each method looks to the ThreadLocal for the value
3) Apply an interceptor to, after invocation, clear the value of the ThreadLocal (as the
Thread will also be returned to a pool).
S,
ALR
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4171109#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...