[cdi-dev] Constructor dependency

Romain Manni-Bucau rmannibucau at gmail.com
Tue Jul 7 10:57:11 EDT 2015


Hi

I d love to have it portable as well and dont really see a big blocker
technically.

It wouldnt break backward compatibility in practise.
 Le 7 juil. 2015 07:09, "Sebastian Łaskawiec" <slaskawi at redhat.com> a
écrit :

> Thanks Martin for the explanation!
>
> Are there any plans to propagate this behavior to the spec?
>
> Thanks
> Sebastian
>
> On 07/07/2015 02:26 PM, Martin Kouba wrote:
> > Hi Sebastian,
> >
> > the "superfluous" constructor is required for client proxies (i.e. for
> > normal-scoped beans). Weld may use non-portable JVM APIs that allow to
> > allocate proxy instances without this constructor (Unsafe). The
> > feature is called "Relaxed construction" [1]. Again, this feature is
> > not portable.
> >
> > Martin
> >
> > [1]
> >
> http://docs.jboss.org/weld/reference/latest/en-US/html/configure.html#relaxedConstruction
> >
> >
> > Dne 7.7.2015 v 14:18 Sebastian Łaskawiec napsal(a):
> >> Hey!
> >>
> >> I've seen CDI 2.0 Early Draft - congratulations! Looks very promising!
> >>
> >> I would like to ask about something slightly different than CDI 2.0 -
> >> constructor injection. I'm a big fan of using it because I can easily
> >> inject mocks into tested objects. This way I can limit the number of
> >> Arquillian tests and speed up testing phase in my project.
> >>
> >> However the drawback is that need 2 constructors in my beans:
> >>
> >> @ApplicationScoped
> >> public class MyBean {
> >>       public MyBean() {
> >>       }
> >>
> >>       @Inject
> >>       public MyBean(OtherBean bean) {
> >>       }
> >> }
> >>
> >> Is it possible to get rid of the zero-parameter constructor? I can
> >> imagine that it may be required by dependency resolution mechanism (for
> >> example instantiating beans with cyclic dependencies A -> B -> C -> A),
> >> but on the other hand we actually can create an instance without calling
> >> a constructor - using Unsafe (but using Unsafe is always questionable).
> >>
> >> Could you please tell me if there are any plans around this topic?
> >>
> >> Thanks
> >> Sebastian
> >> _______________________________________________
> >> cdi-dev mailing list
> >> cdi-dev at lists.jboss.org
> >> https://lists.jboss.org/mailman/listinfo/cdi-dev
> >>
> >> Note that for all code provided on this list, the provider licenses
> >> the code under the Apache License, Version 2
> >> (http://www.apache.org/licenses/LICENSE-2.0.html). For all other
> >> ideas provided on this list, the provider waives all patent and other
> >> intellectual property rights inherent in such information.
> >>
> >
>
> _______________________________________________
> cdi-dev mailing list
> cdi-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/cdi-dev
>
> Note that for all code provided on this list, the provider licenses the
> code under the Apache License, Version 2 (
> http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas
> provided on this list, the provider waives all patent and other
> intellectual property rights inherent in such information.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20150707/e24c8d81/attachment.html 


More information about the cdi-dev mailing list