Issue Type: Feature Request Feature Request
Assignee: Jozef Hartinger
Created: 13/Dec/12 11:03 AM
Description:

Sometimes we want to fit a parametrized injection point with your exact bean. The most common case is when you trying to inject a Class<>.

Let's see:

class Animal {

}

class Dog extends Animal {

}

class PitBull extends Dog {

}

class ShowClassName<T> {

@Inject
public ShowClassName(Class<T> clazz)

{ System.out.println(clazz.getName()); }

}

public class ExactlyTestCase {

@Inject
private ShowClassName<Animal> animalShowClassName;

@Inject
private ShowClassName<Dog> dogShowClassName;

@Inject
private ShowClassName<PitBull> pitBullShowClassName;

@Produces
public Class<Animal> createAnimalClass() { return Animal.class; }

@Produces
public Class<Dog> createDogClass() { return Dog.class; }

@Produces
public Class<PitBull> createPitBullClass() { return PitBull.class; }

}

Class<PitBull> fit with 3 and Class<Dog> fit with 2. I know this behavior is frequently expected but in some cases it's not, as I showed you. In theses cases use qualifiers does not help because i must have one qualifier for each Class and have one ShowClassName Bean for each Class with its especific qualifier annotated, wich does not provide reuse.

Have this will be very nice:

class ShowClassName<T> {

@Inject
public ShowClassName(@Exactly Class<T> clazz) { System.out.println(clazz.getName()); }

}

Thanks

Project: Weld
Priority: Major Major
Reporter: Bruno Hansen
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________
weld-issues mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/weld-issues

Reply via email to