You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by ma...@daimlerchrysler.com on 2005/08/26 11:59:39 UTC
Thread-safety of JSF DataModel / TreeModel
Hi,
as no one on the user list responded I will post my question / observation
here:
I was thinking about to improve the TreeModel for the tree2 but came to a
more general problem regarding thread-safety.
When a component (UIData / UITreeData) uses a local model there are no
problems at all, everything runs in one thread per request.
Now if you move your model to any higher scope than request (e.g.
providing a session scoped DataModel) as far as I can see there are
potentially problems with threadsafety ... in a multi-threaded servlet
environment. Two views with different components using the same model
could interfere each other - setting different rows in the DataModel. The
user could provide a special model but with the concept of setting a row
and than retrieving data about that row its somehow impossible to do a
synchronization in the model itself, so that every component gets the
right data for its row currently processing.
Is this a flaw in the spec or do I miss something here? I have found no
comments about that in the spec. The component implementation does no
synchronization nor this is done in any DataModel impl.
Does anybody has experience with not-request-scoped DataModel?
Your comments?
Regards,
Mathias Werlitz
Re: Thread-safety of JSF DataModel / TreeModel
Posted by Manfred Geiler <ma...@gmail.com>.
Sorry for bothering, just saw that Sean already has replied to this mail.
-Manfred
2005/9/7, Manfred Geiler <ma...@gmail.com>:
> Any tree expert has an idea about this?
> Mathias Werlitz, any new perception?
> -Manfred
>
> 2005/8/26, mathias.werlitz@daimlerchrysler.com
> <ma...@daimlerchrysler.com>:
> >
> > Hi,
> >
> > as no one on the user list responded I will post my question / observation
> > here:
> >
> > I was thinking about to improve the TreeModel for the tree2 but came to a
> > more general problem regarding thread-safety.
> > When a component (UIData / UITreeData) uses a local model there are no
> > problems at all, everything runs in one thread per request.
> > Now if you move your model to any higher scope than request (e.g. providing
> > a session scoped DataModel) as far as I can see there are potentially
> > problems with threadsafety ... in a multi-threaded servlet environment. Two
> > views with different components using the same model could interfere each
> > other - setting different rows in the DataModel. The user could provide a
> > special model but with the concept of setting a row and than retrieving data
> > about that row its somehow impossible to do a synchronization in the model
> > itself, so that every component gets the right data for its row currently
> > processing.
> >
> > Is this a flaw in the spec or do I miss something here? I have found no
> > comments about that in the spec. The component implementation does no
> > synchronization nor this is done in any DataModel impl.
> > Does anybody has experience with not-request-scoped DataModel?
> >
> > Your comments?
> >
> >
> > Regards,
> > Mathias Werlitz
>
Re: Thread-safety of JSF DataModel / TreeModel
Posted by Manfred Geiler <ma...@gmail.com>.
Any tree expert has an idea about this?
Mathias Werlitz, any new perception?
-Manfred
2005/8/26, mathias.werlitz@daimlerchrysler.com
<ma...@daimlerchrysler.com>:
>
> Hi,
>
> as no one on the user list responded I will post my question / observation
> here:
>
> I was thinking about to improve the TreeModel for the tree2 but came to a
> more general problem regarding thread-safety.
> When a component (UIData / UITreeData) uses a local model there are no
> problems at all, everything runs in one thread per request.
> Now if you move your model to any higher scope than request (e.g. providing
> a session scoped DataModel) as far as I can see there are potentially
> problems with threadsafety ... in a multi-threaded servlet environment. Two
> views with different components using the same model could interfere each
> other - setting different rows in the DataModel. The user could provide a
> special model but with the concept of setting a row and than retrieving data
> about that row its somehow impossible to do a synchronization in the model
> itself, so that every component gets the right data for its row currently
> processing.
>
> Is this a flaw in the spec or do I miss something here? I have found no
> comments about that in the spec. The component implementation does no
> synchronization nor this is done in any DataModel impl.
> Does anybody has experience with not-request-scoped DataModel?
>
> Your comments?
>
>
> Regards,
> Mathias Werlitz
Re: Thread-safety of JSF DataModel
Posted by Sean Schofield <se...@gmail.com>.
Mathias,
Sorry its taken so long to respond. Its been busy the past few days.
I'm not sure how two views with different components could access a
session bean at the same time. Can you be more specific about this?
Are you thinking about an iframe or some other situation where the
user has two near simultaneous requests to be completed?
I haven't given this problem too much thought. (I've also renamed the
subject and truncated the tree reference b/c we don't want people to
think this is a tree2 specific question.) Perhaps you could also post
on the Sun forum and see what people say.
Keep us posted. I'm definitely curious about what you find out.
sean
On 8/26/05, mathias.werlitz@daimlerchrysler.com
<ma...@daimlerchrysler.com> wrote:
>
> Hi,
>
> as no one on the user list responded I will post my question / observation
> here:
>
> I was thinking about to improve the TreeModel for the tree2 but came to a
> more general problem regarding thread-safety.
> When a component (UIData / UITreeData) uses a local model there are no
> problems at all, everything runs in one thread per request.
> Now if you move your model to any higher scope than request (e.g. providing
> a session scoped DataModel) as far as I can see there are potentially
> problems with threadsafety ... in a multi-threaded servlet environment. Two
> views with different components using the same model could interfere each
> other - setting different rows in the DataModel. The user could provide a
> special model but with the concept of setting a row and than retrieving data
> about that row its somehow impossible to do a synchronization in the model
> itself, so that every component gets the right data for its row currently
> processing.
>
> Is this a flaw in the spec or do I miss something here? I have found no
> comments about that in the spec. The component implementation does no
> synchronization nor this is done in any DataModel impl.
> Does anybody has experience with not-request-scoped DataModel?
>
> Your comments?
>
>
> Regards,
> Mathias Werlitz