Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdi-dev] Regarding annotations

I never said it cannot, they are both in fact implemented as subclasses in Weld but they are two substantially different ones.
Proxy is also an overloaded term, so I wanted to make it clear that the two are not interchangeable.

Matej

----- Original Message -----
> From: "Mark Struberg" <struberg@xxxxxxxx>
> To: "cdi developer discussions" <cdi-dev@xxxxxxxxxxx>
> Cc: "Matej Novotny" <manovotn@xxxxxxxxxx>
> Sent: Tuesday, December 29, 2020 10:26:36 PM
> Subject: Re: [cdi-dev] Regarding annotations
> 
> The real point here is actually the definition of 'implicit bean archive'
> which referencs to 'Bean defining annotations' as criteria.
> 
> * Normal Scopes
> * @Dependent
> * Interceptor or Decorator
> * any stereotype annoation (even if it has no scope or no normalscope)
> 
> @javax.inject.Singleton doesn't fall under those criteria. Funnily
> @javax.ejb.Singleton does due to it's implicit @Dependent behaviour ;)
> 
> And @Matej: in fact a proxy *can* be implemented as a subclass. And for most
> cases aside (non-NIV) EJBs (where java.lang.reflect interface proxies can be
> used) that's the way it works.
> 
> LieGrue,
> strub
> 
> 
> > Am 15.12.2020 um 11:24 schrieb Emily Jiang <emijiang6@xxxxxxxxxxxxxx>:
> > 
> > okay, thanks Matej! Proxy is an overused word. Just try to understand what
> > you meant by proxy. I treat the normal scoped bean and the intercepted
> > bean as two different proxies. Calling them proxy and subclass sound
> > better.
> > 
> > Emily
> > 
> > On Tue, Dec 15, 2020 at 9:38 AM Matej Novotny <manovotn@xxxxxxxxxx
> > <mailto:manovotn@xxxxxxxxxx>> wrote:
> > No, interceptors have nothing to do with normal/pseudo scope behaviour.
> > Adding an interceptor in practice means creating a subclass of the bean
> > that is aware of the interception logic.
> > 
> > Those two are different concepts. If you have proxied bean (app scoped for
> > instance) and add an interceptor to it, then you will have to create both
> > - a proxy and a subclass.
> > 
> > Matej
> > 
> > ----- Original Message -----
> > > From: "Emily Jiang" <emijiang6@xxxxxxxxxxxxxx
> > > <mailto:emijiang6@xxxxxxxxxxxxxx>>
> > > To: "cdi developer discussions" <cdi-dev@xxxxxxxxxxx
> > > <mailto:cdi-dev@xxxxxxxxxxx>>, "Matej Novotny" <manovotn@xxxxxxxxxx
> > > <mailto:manovotn@xxxxxxxxxx>>
> > > Sent: Monday, December 14, 2020 7:53:36 PM
> > > Subject: Re: [cdi-dev] Regarding annotations
> > > 
> > > Straightly speaking, if you attach an interceptor on the bean with
> > > `@Singleton`, you will get a proxy, right @Matej Novotny
> > > <manovotn@xxxxxxxxxx <mailto:manovotn@xxxxxxxxxx>> ?
> > > 
> > > Thanks
> > > Emily
> > > 
> > > On Mon, Dec 14, 2020 at 3:06 PM arjan tijms <arjan.tijms@xxxxxxxxx
> > > <mailto:arjan.tijms@xxxxxxxxx>> wrote:
> > > 
> > > > Hi,
> > > >
> > > > On Mon, Dec 14, 2020 at 4:00 PM Matej Novotny <manovotn@xxxxxxxxxx
> > > > <mailto:manovotn@xxxxxxxxxx>> wrote:
> > > >
> > > >> I would be -1 to remove Singleton, I see it used pretty commonly. The
> > > >> main difference from app scoped is that while they are both "one
> > > >> instance
> > > >> per container", application scope uses proxies, whereas singleton
> > > >> doesn't.
> > > >> This usually doesn't matter, but there are cases (more prominent in
> > > >> build
> > > >> time environment, or when it comes to serialization, or where you want
> > > >> lazy
> > > >> init, ...) in which the difference matters and being able to choose is
> > > >> nice.
> > > >> If anything, I would rather add Singleton as a bean defining
> > > >> annotation
> > > >> into CDI.
> > > >>
> > > >
> > > > +1 for that latter, and make it clear in the documentation that in
> > > > CDI @Singleton is not proxied, where @ApplicationScoped is.
> > > >
> > > > Kind regards,
> > > > Arjan
> > > >
> > > >
> > > > _______________________________________________
> > > > cdi-dev mailing list
> > > > cdi-dev@xxxxxxxxxxx <mailto:cdi-dev@xxxxxxxxxxx>
> > > > To unsubscribe from this list, visit
> > > > https://www.eclipse.org/mailman/listinfo/cdi-dev
> > > > <https://www.eclipse.org/mailman/listinfo/cdi-dev>
> > > >
> > > 
> > > 
> > > --
> > > Thanks
> > > Emily
> > > 
> > 
> > 
> > 
> > --
> > Thanks
> > Emily
> > 
> > _______________________________________________
> > cdi-dev mailing list
> > cdi-dev@xxxxxxxxxxx <mailto:cdi-dev@xxxxxxxxxxx>
> > To unsubscribe from this list, visit
> > https://www.eclipse.org/mailman/listinfo/cdi-dev
> > <https://www.eclipse.org/mailman/listinfo/cdi-dev>
> 



Back to the top