You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@openwebbeans.apache.org by Tamás Kimmel <ku...@gmail.com> on 2017/02/06 21:12:49 UTC
Beans and PassivationCapable
Hi.
I'm experimenting with a custom cdi context.
I've found all Beans for non-Serializable classes are PassivationCapable (
org.apache.webbeans.component.ManagedBean).
getId returns an id, and beanManager.getPassivationCapableBean works on it.
- checked Weld, and works same too -
Are there any circumstances a Bean not instance of PassivationCapable?
Is it something i can rely on?
For example use the passivation id for key in my contextual storage even
for beans with non-serializable beanClasses.
I know bean classes, interceptors, and decorators have to be Serializable
for a working passivation.
Thanks in advance,
Kimmel Tamás
Re: Beans and PassivationCapable
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi
2017-02-06 22:12 GMT+01:00 Tamás Kimmel <ku...@gmail.com>:
> Hi.
>
> I'm experimenting with a custom cdi context.
> I've found all Beans for non-Serializable classes are PassivationCapable (
> org.apache.webbeans.component.ManagedBean).
> getId returns an id, and beanManager.getPassivationCapableBean works on
> it.
> - checked Weld, and works same too -
> Are there any circumstances a Bean not instance of PassivationCapable?
>
>
If not serializable for instance or its graph (with interceptors etc) is
not.
> Is it something i can rely on?
>
What's the intent? This kind of implementation is kind of required by CDI
> For example use the passivation id for key in my contextual storage even
> for beans with non-serializable beanClasses.
> I know bean classes, interceptors, and decorators have to be Serializable
> for a working passivation.
>
>
If you have a multi scope storage no otherwise yes but keep in mind this is
for specific scopes and not all so depends your Context implementation and
scope definition.
> Thanks in advance,
> Kimmel Tamás
>
>
Re: Beans and PassivationCapable
Posted by Mark Struberg <st...@yahoo.de>.
Indeed, it's not required by the spec.
But actually the only thing which makes sense is to *always* have Bean<T> also implements PassivationCapable.
All OpenWebBeans built-in beans are PassivationCapable.
LieGrue,
strub
> Am 08.02.2017 um 00:01 schrieb Romain Manni-Bucau <rm...@gmail.com>:
>
>
>
> Le 7 févr. 2017 23:51, "Tamás Kimmel" <ku...@gmail.com> a écrit :
> Thanks for the answers.
> It was not clear to me bean passivation and instance serialization is totally different stories.
>
> It seems to me BeanManager stores all beans as PassivationCapable.
> Does beanManager.getBeans(anyclass) always return PassivationCapable bean(s) ?
> Ok, i feel it's implementation specific...
>
> Doesnt have too.
>
>
> Thanks in advance,
> Kimmel Tamás
>
>
>
> 2017-02-07 11:35 GMT+01:00 Mark Struberg <st...@yahoo.de>:
> Hi Tamás!
>
> I strongly recommend that EVERY Bean<T> should implement PassivationCapable!
>
> The reason is the following: we need that information to serialise the proxies.
>
> Consider you have an
>
> @ApplicationScoped
> public class MailService {....}
>
> Of course this class doesn't need to be Serializable, because it doesn't leave the server, right?
>
> Now you take a
>
> @SessionScoped
> public class MailForm implements Serializable {
> private @Inject MailService mailSvc;
> ...
> }
>
> So the MailForm instances might get serialised to another node.
> With this the MailService Contextual Reference (the PROXY!) get's also serialised along as well.
>
> So while the MailService Contextual Instance (the actual 'application-singleton') does NOT get serialised, the Contextual Reference (the proxy) *will*.
>
> That means that the Bean needs to be PassivationCapable.
> Ofc only the Bean<MailService>, not the Contextual Instance of the MailService!
>
> hth.
>
> LieGrue,
> strub
>
>
> > Am 06.02.2017 um 22:12 schrieb Tamás Kimmel <ku...@gmail.com>:
> >
> > Hi.
> >
> > I'm experimenting with a custom cdi context.
> > I've found all Beans for non-Serializable classes are PassivationCapable ( org.apache.webbeans.component.ManagedBean).
> > getId returns an id, and beanManager.getPassivationCapableBean works on it.
> > - checked Weld, and works same too -
> > Are there any circumstances a Bean not instance of PassivationCapable?
> >
> > Is it something i can rely on?
> > For example use the passivation id for key in my contextual storage even for beans with non-serializable beanClasses.
> > I know bean classes, interceptors, and decorators have to be Serializable for a working passivation.
> >
> > Thanks in advance,
> > Kimmel Tamás
> >
>
>
>
Re: Beans and PassivationCapable
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Le 7 févr. 2017 23:51, "Tamás Kimmel" <ku...@gmail.com> a écrit :
Thanks for the answers.
It was not clear to me bean passivation and instance serialization is
totally different stories.
It seems to me BeanManager stores all beans as PassivationCapable.
Does beanManager.getBeans(anyclass) always return PassivationCapable
bean(s) ?
Ok, i feel it's implementation specific...
Doesnt have too.
Thanks in advance,
Kimmel Tamás
2017-02-07 11:35 GMT+01:00 Mark Struberg <st...@yahoo.de>:
> Hi Tamás!
>
> I strongly recommend that EVERY Bean<T> should implement
> PassivationCapable!
>
> The reason is the following: we need that information to serialise the
> proxies.
>
> Consider you have an
>
> @ApplicationScoped
> public class MailService {....}
>
> Of course this class doesn't need to be Serializable, because it doesn't
> leave the server, right?
>
> Now you take a
>
> @SessionScoped
> public class MailForm implements Serializable {
> private @Inject MailService mailSvc;
> ...
> }
>
> So the MailForm instances might get serialised to another node.
> With this the MailService Contextual Reference (the PROXY!) get's also
> serialised along as well.
>
> So while the MailService Contextual Instance (the actual
> 'application-singleton') does NOT get serialised, the Contextual Reference
> (the proxy) *will*.
>
> That means that the Bean needs to be PassivationCapable.
> Ofc only the Bean<MailService>, not the Contextual Instance of the
> MailService!
>
> hth.
>
> LieGrue,
> strub
>
>
> > Am 06.02.2017 um 22:12 schrieb Tamás Kimmel <ku...@gmail.com>:
> >
> > Hi.
> >
> > I'm experimenting with a custom cdi context.
> > I've found all Beans for non-Serializable classes are PassivationCapable
> ( org.apache.webbeans.component.ManagedBean).
> > getId returns an id, and beanManager.getPassivationCapableBean works on
> it.
> > - checked Weld, and works same too -
> > Are there any circumstances a Bean not instance of PassivationCapable?
> >
> > Is it something i can rely on?
> > For example use the passivation id for key in my contextual storage even
> for beans with non-serializable beanClasses.
> > I know bean classes, interceptors, and decorators have to be
> Serializable for a working passivation.
> >
> > Thanks in advance,
> > Kimmel Tamás
> >
>
>
Re: Beans and PassivationCapable
Posted by Tamás Kimmel <ku...@gmail.com>.
Thanks for the answers.
It was not clear to me bean passivation and instance serialization is
totally different stories.
It seems to me BeanManager stores all beans as PassivationCapable.
Does beanManager.getBeans(anyclass) always return PassivationCapable
bean(s) ?
Ok, i feel it's implementation specific...
Thanks in advance,
Kimmel Tamás
2017-02-07 11:35 GMT+01:00 Mark Struberg <st...@yahoo.de>:
> Hi Tamás!
>
> I strongly recommend that EVERY Bean<T> should implement
> PassivationCapable!
>
> The reason is the following: we need that information to serialise the
> proxies.
>
> Consider you have an
>
> @ApplicationScoped
> public class MailService {....}
>
> Of course this class doesn't need to be Serializable, because it doesn't
> leave the server, right?
>
> Now you take a
>
> @SessionScoped
> public class MailForm implements Serializable {
> private @Inject MailService mailSvc;
> ...
> }
>
> So the MailForm instances might get serialised to another node.
> With this the MailService Contextual Reference (the PROXY!) get's also
> serialised along as well.
>
> So while the MailService Contextual Instance (the actual
> 'application-singleton') does NOT get serialised, the Contextual Reference
> (the proxy) *will*.
>
> That means that the Bean needs to be PassivationCapable.
> Ofc only the Bean<MailService>, not the Contextual Instance of the
> MailService!
>
> hth.
>
> LieGrue,
> strub
>
>
> > Am 06.02.2017 um 22:12 schrieb Tamás Kimmel <ku...@gmail.com>:
> >
> > Hi.
> >
> > I'm experimenting with a custom cdi context.
> > I've found all Beans for non-Serializable classes are PassivationCapable
> ( org.apache.webbeans.component.ManagedBean).
> > getId returns an id, and beanManager.getPassivationCapableBean works on
> it.
> > - checked Weld, and works same too -
> > Are there any circumstances a Bean not instance of PassivationCapable?
> >
> > Is it something i can rely on?
> > For example use the passivation id for key in my contextual storage even
> for beans with non-serializable beanClasses.
> > I know bean classes, interceptors, and decorators have to be
> Serializable for a working passivation.
> >
> > Thanks in advance,
> > Kimmel Tamás
> >
>
>
Re: Beans and PassivationCapable
Posted by Mark Struberg <st...@yahoo.de>.
Hi Tamás!
I strongly recommend that EVERY Bean<T> should implement PassivationCapable!
The reason is the following: we need that information to serialise the proxies.
Consider you have an
@ApplicationScoped
public class MailService {....}
Of course this class doesn't need to be Serializable, because it doesn't leave the server, right?
Now you take a
@SessionScoped
public class MailForm implements Serializable {
private @Inject MailService mailSvc;
...
}
So the MailForm instances might get serialised to another node.
With this the MailService Contextual Reference (the PROXY!) get's also serialised along as well.
So while the MailService Contextual Instance (the actual 'application-singleton') does NOT get serialised, the Contextual Reference (the proxy) *will*.
That means that the Bean needs to be PassivationCapable.
Ofc only the Bean<MailService>, not the Contextual Instance of the MailService!
hth.
LieGrue,
strub
> Am 06.02.2017 um 22:12 schrieb Tamás Kimmel <ku...@gmail.com>:
>
> Hi.
>
> I'm experimenting with a custom cdi context.
> I've found all Beans for non-Serializable classes are PassivationCapable ( org.apache.webbeans.component.ManagedBean).
> getId returns an id, and beanManager.getPassivationCapableBean works on it.
> - checked Weld, and works same too -
> Are there any circumstances a Bean not instance of PassivationCapable?
>
> Is it something i can rely on?
> For example use the passivation id for key in my contextual storage even for beans with non-serializable beanClasses.
> I know bean classes, interceptors, and decorators have to be Serializable for a working passivation.
>
> Thanks in advance,
> Kimmel Tamás
>