use of javax.enterprise.util.TypeLiteral in project camel by apache.
the class CdiEventEndpoint method createProducer.
@Override
public Producer createProducer() throws IllegalAccessException {
// FIXME: to be replaced once event firing with dynamic parameterized type
// is properly supported (see https://issues.jboss.org/browse/CDI-516)
TypeLiteral<T> literal = new TypeLiteral<T>() {
};
for (Field field : TypeLiteral.class.getDeclaredFields()) {
if (field.getType().equals(Type.class)) {
field.setAccessible(true);
field.set(literal, type);
break;
}
}
InjectionTarget<AnyEvent> target = manager.createInjectionTarget(manager.createAnnotatedType(AnyEvent.class));
CreationalContext<AnyEvent> ctx = manager.createCreationalContext(null);
AnyEvent instance = target.produce(ctx);
target.inject(instance, ctx);
return new CdiEventProducer<>(this, instance.event.select(literal, qualifiers.stream().toArray(Annotation[]::new)));
}
Aggregations