This content has been marked as final.
Show 3 replies
-
1. Re: Is it possible to unsubscribe an @Observes annotated methode?
ibek Nov 23, 2012 10:49 AM (in response to mojoo)Hi,
I think, it's not possible with the Observes annotation but you can use MessageBus subscribe/unsubscribe instead. Look at the JBoss Errai reference (e.g. 2.2.4) here http://docs.jboss.org/errai/2.1.1.Final/errai/reference/html_single/#sid-5931280
Regards,
Ivo
-
2. Re: Is it possible to unsubscribe an @Observes annotated methode?
cbrock Nov 23, 2012 12:53 PM (in response to ibek)1 of 1 people found this helpfulThat's not exactly true. It is possible to unsubcribe an observer by destroying the bean of which it is a member.
For instance: if you have a dependent bean called ObserveBean
@Dependent public class ObserverBean { public void observes(@Observes Foo foo) { } }
You then create this bean dynamically from another bean:
ObserverBean bean = beanManager.lookupBean(ObserverBean.class).newInstance();
The observer is now listening.
beanManager.destroyBean(bean);
Now it is not.
-
3. Re: Is it possible to unsubscribe an @Observes annotated methode?
mojoo Nov 26, 2012 8:25 AM (in response to cbrock)i forgot to mention in my post that i need the bean to survive, so this is not an option. thank you