users@glassfish.java.net

CDI events - strange behavior

From: <forums_at_java.net>
Date: Sun, 9 Oct 2011 03:36:04 -0500 (CDT)

CDI events is a nice feature, but I discovered a strange behavior in
Glassfish 3.1.1.
An event generated by a ApplicationScoped bean will not be propagated to all
SessionScoped bean listener methods.
For example: supose that you call ‘fire(“text”)’ on Producer bean,
and we have 2 instances of Consumer bean. The ‘fired’ method on Consumer
bean will be invoked only for one instance. The second Consumer instance will
not be notificated.
@Named
@ApplicationScoped
public class Producer {
@Inject @Any
private Event event;
public void fire(String message) {
event.fire(message);
}
}
@Named
@SessionScoped
public class Consumer {
public void fired(@Observes String event) {
// do something…
}
}
I think that there is something wrong. Maybe with Weld? I don't know yet.
What do you think?


--
[Message sent by forum member 'averri']
View Post: http://forums.java.net/node/851554