-
1. Re: Component-driven events scope
gavin.king Nov 15, 2006 12:06 PM (in response to cavani)Events are processed in the scope of the conversation that raised them (except for async events).
Anyway, the docs are outofdate, the latest releases do actually support arbitrary event objects. -
2. Re: Component-driven events scope
cavani Nov 15, 2006 1:03 PM (in response to cavani)nice, very nice... now, my code can be much more loosely and pretty...
thanks a lot, -
3. Re: Component-driven events scope
cavani Nov 29, 2006 8:27 PM (in response to cavani)I realize now that I misundestood the concept of this kind of event.
Originally, my idea was that I should create Components in one conversation context and a raised event just reached this created components that observe it.
But, this doesn't work that way!
Reading the Seam code (this help a lot!!), I realize that any component that observe the same event will be invoked, and created in same conversation when there isn't one.
Any way to raise an event observed by many components, but that afects only sort of created components in same conversation?
Thanks, -
4. Re: Component-driven events scope
cavani Nov 30, 2006 7:36 AM (in response to cavani)I try this and it works good!
I alter Events from Seam Core to:private void eventProcessing(boolean create, String type, Object... parameters) { log.debug("Processing event:" + type); List<MethodBinding> list = listeners.get(type); if (list!=null) { for (MethodBinding listener: list ) { listener.invoke(parameters); } } List<Init.ObserverMethod> observers = Init.instance().getObservers(type); if (observers!=null) { for (ObserverMethod observer: observers) { Object listener = Component.getInstance( observer.component.getName(), create ); if (listener == null) continue; observer.component.callComponentMethod(listener, observer.method, parameters); } } } public void raiseEvent(String type, Object... parameters) { eventProcessing(true, type, parameters); } public void sendEvent(String type, Object... parameters) { eventProcessing(false, type, parameters); }
Gavin, any chances to have this or something like?
Thanks, -
5. Re: Component-driven events scope
gavin.king Dec 11, 2006 1:07 AM (in response to cavani)Add a feature request to JIRA, sounds like a good idea.
-
6. Re: Component-driven events scope
cavani Dec 11, 2006 7:01 AM (in response to cavani)Done!
http://jira.jboss.org/jira/browse/JBSEAM-579
Thanks, -
7. Re: Component-driven events scope
cavani Dec 11, 2006 7:13 AM (in response to cavani)I want suggest a second approach for the same feature:
@Observer(String[] value, boolean create)
Where the "boolean create" indicate if that component should be create when it not exists.
I dig a little on Seam code and conclude that this is very easy to do. This information could be setted on Init.ObserverMethod and Event.raiseEvent() could be changed to consider that.
This is less power than previous approach but is simple too.