For the time being, either by using Event.select(...), respectively BeanManager.fireEvent(...), it is not possible to fire an event whose runtime type is a dynamic parameterized type, as specified in The Event interface:
If the container is unable to resolve the parameterized type of the event object, it uses the specified type to infer the parameterized type of the event types.
If the runtime type of the event object contains an unresolvable type variable, an IllegalArgumentException is thrown.
Respectively in Firing an event:
If the runtime type of the event object contains a type variable, an IllegalArgumentException is thrown.
While, it is possible to pass a TypeLiteral to the Event.select(...) method, e.g.:
It is not possible to pass a type variable known at runtime as the TypeLiteral class relies on the declared type variable and does not permit to override that behavior as the TypeLiteral.getType() method is declared final.
Yet, there are use cases where that need is valid, for example:
In the example above, the TypeLiteral class could have a constructor taking the dynamic type as argument.
Another alternative would be to enrich the BeanManager SPI with the following method: