This is what the test shows partially. The test shows the usage of a custom annotation, but doesn't do the additional step of checking the argument type.
At my job we use such implementation and it works for us. What you miss this way is the IEvent API - like stopping the event, for example. Additionally you will need a robust caching of the listeners because otherwise you will need to visit all components and behaviors again and again. On Tue, Jun 19, 2012 at 10:58 PM, Jeremy Thomerson <[email protected]> wrote: > Have we talked about adding an IEventDispatcher that dispatches events by > their class type based on event method signature? > > Example: > > class MyComponent { > > @EventListener // or some annotation > public void onUserAddedEvent(UserAddedEvent event) { > // do something here > } > > } > > Then when someone calls sink(new UserAddedEvent()) it gets dispatched to > only those methods that take a UserAddedEvent as their method argument? > > Would that be useful (it seems like it to me - it avoids the instanceof > checks)? Am I off track? Is there something like this or better already > built? > > An alternative would be that the annotation could take an argument of event > class(es) that it want's to be notified of. > > > > > -- > Jeremy Thomerson > http://wickettraining.com > *Need a CMS for Wicket? Use Brix! http://brixcms.org* > > > > On Tue, Jun 19, 2012 at 2:36 PM, Igor Vaynberg <[email protected]>wrote: > >> >> http://grepcode.com/file/repo1.maven.org/maven2/org.apache.wicket/wicket-core/6.0.0-beta1/org/apache/wicket/EventDispatcherTest.java#EventDispatcherTest >> >> -igor >> >> On Tue, Jun 19, 2012 at 12:31 PM, Douglas Ferguson <[email protected]> >> wrote: >> > Where's the source repository located? >> > >> > >> > On Jun 19, 2012, at 2:20 PM, Martin Grigorov wrote: >> > >> >> See org.apache.wicket.EventDispatcherTest in wicket-core's tests >> >> >> >> On Tue, Jun 19, 2012 at 9:58 PM, Douglas Ferguson <[email protected]> >> wrote: >> >>> Anybody have a good pattern for using Events without having lots of >> instanceOf, if/else, or switch statements? >> >>> --------------------------------------------------------------------- >> >>> To unsubscribe, e-mail: [email protected] >> >>> For additional commands, e-mail: [email protected] >> >>> >> >> >> >> >> >> >> >> -- >> >> Martin Grigorov >> >> jWeekend >> >> Training, Consulting, Development >> >> http://jWeekend.com >> >> >> >> --------------------------------------------------------------------- >> >> To unsubscribe, e-mail: [email protected] >> >> For additional commands, e-mail: [email protected] >> >> >> > >> > >> > --------------------------------------------------------------------- >> > To unsubscribe, e-mail: [email protected] >> > For additional commands, e-mail: [email protected] >> > >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
