Hi,
On Mon, Apr 6, 2015 at 2:07 PM, Mark Struberg <struberg_at_yahoo.de> wrote:
> When the discussion was about ‚producer methods‘ I was thinking about, well a ‚Producer Method‘:
Well, we actually said "producer", not "producer method", but I
understand what your mean.
Personally I think the term "bean" for what is effectively a factory
for some type is somewhat difficult to get in to. When you casually
talk about a bean, people think about a JavaBean, and in a JSF/CDI
context something like a backing bean with an @Named and
@RequestScoped annotation or so.
But alas, that ship has sailed ;)
Kind regards,
Arjan Tijms
>
> @Produces
> @Dependent
> public FacesContext getFacesContext() { ..}
>
> something like that. That’s why I said that the interface of the producermethod has not that much impact but the return type at runtime needs to be Serializable.
>
> LieGrue,
> strub
>
>
>> Am 06.04.2015 um 12:58 schrieb arjan tijms <arjan.tijms_at_gmail.com>:
>>
>> Hi,
>>
>> On Mon, Apr 6, 2015 at 9:40 AM, Mark Struberg <struberg_at_yahoo.de> wrote:
>>> I don’t look at the Mojarra code to make sure that everything I write at MyFaces is really ‚clean room‘.
>>
>> Ah, I didn't know that. TIL ;)
>>
>>> 2.) Serialisation of the Contextual Reference. This is what blows up in your case. And it is independent on whether your own contextual instance gets serialized or not. Consider an @ApplicationScoped MyService which is not serializable. And now you inject this into a @SessionScoped MyView. When MyView gets serialized (cluster) then the proxy for MyService which got injected into MyView gets serialized as well. And this proxy (the Contextual Reference) just serializes the passivationId over to the other node. We cannot serialize the whole Bean<T> as it usually contains refs to a lot of Class<?>, Method<?>, Field<?> etc. On the other node this gets ‚connected‘ to the Bean<T> again via BeanManager#getPassivationCapableBean(String id)
>>
>> I guessed something like this was the case indeed, but I got somewhat
>> confused by you saying before:
>>
>>> a.) The interface doesn’t matter at all. The only thing which counts is that the return type must not be a final non-serilizable class.
>>
>> But I guess we were just talking about different things there.
>>
>> For OmniFaces I ran into the exact same issue and there I just applied
>> the interface, without worrying too much about potential unforeseen
>> side effects, but for the JSF spec I (via Manfred) wanted to be a
>> little bit more careful here.
>>
>> But indeed, an explanation like your 2) above in the javadoc and/or
>> spec text for PassivationCapable would have helped a lot.
>>
>> The interface is thus intended to effectively re-obtain a Bean<T> with
>> a given class type and constructor arguments. If only the class type
>> mattered, then CDI wouldn't really have needed the bother with the
>> PassivationCapable interface, but the constructor arguments can matter
>> as well.
>>
>>> Hope that helps a bit.
>>
>> It does, thanks a lot for the thorough explanation. I'll prepare a
>> changebundle for Mojarra and/or discuss it with Manfred.
>>
>> Kind regards,
>> Arjan Tijms
>>
>>
>>>
>>> LieGrue,
>>> strub
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>> Am 05.04.2015 um 22:49 schrieb arjan tijms <arjan.tijms_at_gmail.com>:
>>>>
>>>> Hi,
>>>>
>>>> On Sunday, April 5, 2015, Mark Struberg <struberg_at_yahoo.de> wrote:
>>>>
>>>>> Am 05.04.2015 um 21:07 schrieb arjan tijms <arjan.tijms_at_gmail.com>:
>>>>>
>>>>> If this does not implement javax.enterprise.inject.spi.PassivationCapable (http://docs.oracle.com/javaee/7/api/javax/enterprise/inject/spi/PassivationCapable.html) then the injection in session scoped beans fails.
>>>>>
>>>>
>>>> Yes, and that is simply a bug. There is nothing wrong with CDI in general, just a simple bug in Mojarra.
>>>>
>>>>
>>>> Just to be sure, do you mean it's a bug in Mojarra that the FacesContextProducer does not implement the PassivationCapable interface?
>>>>
>>>> Kind regards,
>>>> Arjan Tijms
>>>>
>>>>
>>>>
>>>>
>>>> Ed, feel free to ping me and I’ll explain. Or we sit together over a coffee next week and I help you fixing this.
>>>>
>>>> LieGrue,
>>>> strub
>>>
>