Hi, was hoping someone could clarify this for me.
I have an EJB Singleton, onto which I inject a managed bean:
@LocalBean @Startup @Singleton public class EventManagementEJBSingleton { @Inject protected TypeAEventFirer eventFirerA;
This bean fires an event:
@Inject @TypeA private Event<String> event; public void fireEvent(){ event.fire(name+" FIRED"); }
There's an observer method on the EJB Singleton that I think should be notified when the event fires:
public void onEvent(@Observes @Any String eventMsg) { System.out.println(String.format(name+" received event: [%s]", eventMsg)); setAnyEventReceived(true); }
However it isn't. Is my syntax incorrect somewhere? I believe this behaviour DID work in AS6 (although I didn't have this exact test written then, hence the typo paranoia).
If I add notifyObserver = Reception.IF_EXISTS to the Observes annotation on the Singleton, Weld tells me that it's not allowed, because the bean is @DependentScoped. Does this mean the EJB Singletons were treated as 'ApplicationScoped' in AS6, but are no longer? As an aside, I can see that ApplicationScoped beans CAN observe the event I'm firing, just not EJB Singletons.
The upshot of this is that EJB Singleton observer methods I wrote as part of our CDI framework for AS6 are no longer notified, which pretty much breaks it. I need the beans to be EJB Singletons so I can have them created @Startup and bound into JNDI - I don't believe either of these are possible in AS7 with ApplicationScoped beans.
Any help much appreciated!
Thanks,
Ben