Hi Guillaume,

As already discussed, Blueprint is not a compiler but a runtime library. Once 
compiled there is no more generics as Java is a type erasure language. 
Moreover, I’m not too sure how Blueprint may handle injection with things like 
<S> S getSomething() where in java you can write myinstance.<Boolean> 
getSomething().

I still do have issues with injection and generics, so a global flag to defeat 
Blueprint checking would be greatly appreciated :)

JP

De : Guillaume Nodet [mailto:[email protected]]
Envoyé : lundi 3 avril 2017 14:31
À : user
Objet : Re: Blueprint fails instantiating bean with generic constructor

 There are 2 different issues.
One is type erasure, i.e. allow the invocation of a method taking a 
List<String> with a List<Integer> for example.  That's ARIES-1607, and I really 
think that's a bad idea, unless someone show me a good example where it makes 
sense.  At least by default (well, it's against the blueprint spec anyway).  A 
flag to turn on such a behavior (on a bean or globally) could be an acceptable 
way, though.

Another issue is ARIES-960 where the same thing written in java would work.  
That's a problem of type assignability verification and I'm willing to fix 
those.  I think that's more your use case.  There's a branch I created a while 
ago with some changes.  Could you check if your use case works with the code 
there ?

In all cases, a workaround is always to provide a custom blueprint converter, 
as this would allow converting whatever you want to whatever is needed.



2017-04-03 11:23 GMT+02:00 CLEMENT Jean-Philippe 
<[email protected]<mailto:[email protected]>>:
Hi Setya,

It might be related to an issue I opened last year: 
https://issues.apache.org/jira/browse/ARIES-1607

At that time I was told to add a custom converter as a workaround. No update on 
the Jira since then; maybe you may vote for it :)

Regards,
JP

-----Message d'origine-----
De : Setya [mailto:[email protected]<mailto:[email protected]>]
Envoyé : vendredi 31 mars 2017 19:09
À : [email protected]<mailto:[email protected]>
Objet : Blueprint fails instantiating bean with generic constructor

Hi all,

Aries Blueprint fails to instantiate bean with the following constructors:

public AggregateAnnotationCommandHandler(Class<T> aggregateType, Repository<T> 
repository) { }

It seems to have problems with the second argument since it contains generic 
parameter.

While it successfully instantiates the following bean:

public EventSourcingRepository(AggregateFactory<T> aggregateFactory, EventStore 
eventStore) { }

I'm using Apache Karaf 4.0.8.

Any insight would be greatly appreciated.

Thanks & Regards,
Setya



--
View this message in context: 
http://karaf.922171.n3.nabble.com/Blueprint-fails-instantiating-bean-with-generic-constructor-tp4049986.html
Sent from the Karaf - User mailing list archive at Nabble.com.



--
------------------------
Guillaume Nodet

Reply via email to