You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@deltaspike.apache.org by Karl Kildén <ka...@gmail.com> on 2016/06/21 09:24:24 UTC

Is it truly impossible to lookup @ViewScoped etc with BeanProvider?

Hello!

If a project made a mistake in the architecture and needs to lookup JSF
scoped instances from the BeanProvider, is this possible in any way
(however hacky?).

The problem is that since the request thread is needed to lookup the
instance it does not work from a thread.

cheers

Re: Is it truly impossible to lookup @ViewScoped etc with BeanProvider?

Posted by Thomas Frühbeck <fr...@aon.at>.
Karl,
this sounds a bit strange indeed :-)

your write: "this thread is also disconnected from my Bean and it fails 
to look it up"

Anything in the session/view scopes will have to be serializable, and a 
thread isnt.
A solution I could imagine is an @ApplicationScoped bean as 
ThreadReferenceHolder HashMap<String,Runnable> to hold and manage the 
spawned threads.
Your ViewScoped beans then only need to hold the thread reference keys - 
now they are Serializable.

The ThreadReferenceHolder will be injected on each invocation of your 
ViewScoped beans.

So you have a reference from ViewScoped beans to the threads, the other 
way round I cannot imagine it will work correctly..

w.d.y.t?

Am 21.06.2016 um 14:10 schrieb Karl Kild�n:
> So it is impossible then :-)
>
> The problem is that several slow things needs to be done from a JSF Bean. I
> can't async it because the service the bean calls is @ViewAccessScoped and
> stateful.
>
> I have a Bean that I want to start the thread from the Bean it is not a
> problem but when I create a new thread this thread is also disconnected
> from my Bean and it fails to look it up...
>
> Will take me ages to fix this project properly so desperate times calls for
> strange hacks :-)
>
> On 21 June 2016 at 12:39, Thomas Andraschko <an...@gmail.com>
> wrote:
>
>> BeanProvider should work fine with any scope.
>> Of course you can't receive a viewscoped bean from another thread/request.
>>
>> 2016-06-21 11:52 GMT+02:00 Karl Kild�n <ka...@gmail.com>:
>>
>>> I have a RequestScoped Bean that needs to split the workload basically
>> and
>>> the thread needs to lookup using the Bean that starts the thread so to
>>> speak...
>>>
>>> On 21 June 2016 at 11:24, Karl Kild�n <ka...@gmail.com> wrote:
>>>
>>>> Hello!
>>>>
>>>> If a project made a mistake in the architecture and needs to lookup JSF
>>>> scoped instances from the BeanProvider, is this possible in any way
>>>> (however hacky?).
>>>>
>>>> The problem is that since the request thread is needed to lookup the
>>>> instance it does not work from a thread.
>>>>
>>>> cheers
>>>>


Re: Is it truly impossible to lookup @ViewScoped etc with BeanProvider?

Posted by "John D. Ament" <jo...@apache.org>.
Karl,

Do you mean you're trying to maintain the state of the view scoped bean in
the async request?

John

On Tue, Jun 21, 2016 at 8:10 AM Karl Kildén <ka...@gmail.com> wrote:

> So it is impossible then :-)
>
> The problem is that several slow things needs to be done from a JSF Bean. I
> can't async it because the service the bean calls is @ViewAccessScoped and
> stateful.
>
> I have a Bean that I want to start the thread from the Bean it is not a
> problem but when I create a new thread this thread is also disconnected
> from my Bean and it fails to look it up...
>
> Will take me ages to fix this project properly so desperate times calls for
> strange hacks :-)
>
> On 21 June 2016 at 12:39, Thomas Andraschko <an...@gmail.com>
> wrote:
>
> > BeanProvider should work fine with any scope.
> > Of course you can't receive a viewscoped bean from another
> thread/request.
> >
> > 2016-06-21 11:52 GMT+02:00 Karl Kildén <ka...@gmail.com>:
> >
> > > I have a RequestScoped Bean that needs to split the workload basically
> > and
> > > the thread needs to lookup using the Bean that starts the thread so to
> > > speak...
> > >
> > > On 21 June 2016 at 11:24, Karl Kildén <ka...@gmail.com> wrote:
> > >
> > > > Hello!
> > > >
> > > > If a project made a mistake in the architecture and needs to lookup
> JSF
> > > > scoped instances from the BeanProvider, is this possible in any way
> > > > (however hacky?).
> > > >
> > > > The problem is that since the request thread is needed to lookup the
> > > > instance it does not work from a thread.
> > > >
> > > > cheers
> > > >
> > >
> >
>

Re: Is it truly impossible to lookup @ViewScoped etc with BeanProvider?

Posted by Karl Kildén <ka...@gmail.com>.
So it is impossible then :-)

The problem is that several slow things needs to be done from a JSF Bean. I
can't async it because the service the bean calls is @ViewAccessScoped and
stateful.

I have a Bean that I want to start the thread from the Bean it is not a
problem but when I create a new thread this thread is also disconnected
from my Bean and it fails to look it up...

Will take me ages to fix this project properly so desperate times calls for
strange hacks :-)

On 21 June 2016 at 12:39, Thomas Andraschko <an...@gmail.com>
wrote:

> BeanProvider should work fine with any scope.
> Of course you can't receive a viewscoped bean from another thread/request.
>
> 2016-06-21 11:52 GMT+02:00 Karl Kildén <ka...@gmail.com>:
>
> > I have a RequestScoped Bean that needs to split the workload basically
> and
> > the thread needs to lookup using the Bean that starts the thread so to
> > speak...
> >
> > On 21 June 2016 at 11:24, Karl Kildén <ka...@gmail.com> wrote:
> >
> > > Hello!
> > >
> > > If a project made a mistake in the architecture and needs to lookup JSF
> > > scoped instances from the BeanProvider, is this possible in any way
> > > (however hacky?).
> > >
> > > The problem is that since the request thread is needed to lookup the
> > > instance it does not work from a thread.
> > >
> > > cheers
> > >
> >
>

Re: Is it truly impossible to lookup @ViewScoped etc with BeanProvider?

Posted by Thomas Andraschko <an...@gmail.com>.
BeanProvider should work fine with any scope.
Of course you can't receive a viewscoped bean from another thread/request.

2016-06-21 11:52 GMT+02:00 Karl Kildén <ka...@gmail.com>:

> I have a RequestScoped Bean that needs to split the workload basically and
> the thread needs to lookup using the Bean that starts the thread so to
> speak...
>
> On 21 June 2016 at 11:24, Karl Kildén <ka...@gmail.com> wrote:
>
> > Hello!
> >
> > If a project made a mistake in the architecture and needs to lookup JSF
> > scoped instances from the BeanProvider, is this possible in any way
> > (however hacky?).
> >
> > The problem is that since the request thread is needed to lookup the
> > instance it does not work from a thread.
> >
> > cheers
> >
>

Re: Is it truly impossible to lookup @ViewScoped etc with BeanProvider?

Posted by Karl Kildén <ka...@gmail.com>.
I have a RequestScoped Bean that needs to split the workload basically and
the thread needs to lookup using the Bean that starts the thread so to
speak...

On 21 June 2016 at 11:24, Karl Kildén <ka...@gmail.com> wrote:

> Hello!
>
> If a project made a mistake in the architecture and needs to lookup JSF
> scoped instances from the BeanProvider, is this possible in any way
> (however hacky?).
>
> The problem is that since the request thread is needed to lookup the
> instance it does not work from a thread.
>
> cheers
>