This content has been marked as final.
Show 3 replies
-
1. Re: Adding Observers dynamically in seam Event Mechanisum
cash1981 Mar 12, 2010 12:34 PM (in response to devika.nrgh)I am not sure if this will work. But you can try this:
Init.instance().addObserverMethod(eventType, method, component, create)
-
2. Re: Adding Observers dynamically in seam Event Mechanisum
devika.nrgh Mar 12, 2010 12:38 PM (in response to devika.nrgh)Thanks for the reply.
pls can u send me some sample code.
Regards
Devika.N -
3. Re: Adding Observers dynamically in seam Event Mechanisum
cash1981 Mar 12, 2010 12:54 PM (in response to devika.nrgh)I just did.
You just need to fill out whatever you want.
This is taken from Component.java (source of seam)
There you see how observers are registered using reflectionif ( method.isAnnotationPresent(Observer.class) ) { //can't use Init.instance() here because of unit tests Init init = (Init) applicationContext.get(Seam.getComponentName(Init.class)); Observer observer = method.getAnnotation(Observer.class); for ( String eventType : observer.value() ) { if ( eventType.length()==0 ) eventType = method.getName(); //TODO: new defaulting rule to map @Observer onFooEvent() -> event type "fooEvent" init.addObserverMethod( eventType, method, this, observer.create() ); } }