You seem to mix CDI Extensions with producers. First, if you want to have a producer, the factory method should return a NewsListView
, not a generic type. Using @Producer
along with a qualifier annotation will bind with the annotated type. So there is no need to annotate NewsListView
with @FXMLManaged
. Then you inject your NewsListView
somewhere in a bean.
Producing the view:
public class FXMLManagedProducer {
@Produces @FXMLManaged
public NewsListView getFXMLManagedInstance() {
return new NewsListView();
}
}
Using the producer:
public class SomeBean {
@Inject @FXMLManaged
NewsListView view;
}
But my guess is that this is not what you are looking for. I think you might want to create a CDI Extension
public class YourExtension implements Extension {
<T> void processAnnotatedType(@Observes ProcessAnnotatedType<T> pat) {
if(pat.getAnnotatedType().isAnnotationPresent(FXMLManaged.class)) {
// do your stuff here
}
}
}
This way you would process your annotated NewsListView
. You may want to have a look at other methods to hook into the lifecycle, so you can create the bean and inject dependencies if neccessary.