On 15/03/2011 16:06, [email protected] wrote:
Finally, I've got another problem now :) In one of my services I create a
new Thread which calls DomainObjectContainer methods. This works for me in
the dnd viewer but when I run it in the html view it gives me:
java.lang.IllegalStateException: No Session opened for this thread
Yup, that's gonna happen. The (default runtime for) Isis uses a class
called IsisContext that is used as a service locator for sessions. In
DnD, this is a singleton (called IsisContextStatic), but on HTML we use
an implementation that binds to the thread-local
(IsisContextThreadLocal). That's why you see no session.
In fact, it is possible - and relatively straightforward - to write your
own implementation of IsisContext, though you'd need to find a means to
recognize that the two threads are meant to share the same info. The
Wicket viewer, in fact, does have its own implementation, namely
IsisContextForWicket, which shares contexts on a Wicket Session. You
could use that for inspiration if you want.
Cheers
Dan
PS: it's this sort of complexity that is one of the reasons I want to
move to CDI/JSR-299. However, determining the "scope" of a session etc
will still be required, even under CDI.