On Thu, May 28, 2009 at 10:42, Vincent Massol <[email protected]> wrote: > > On May 28, 2009, at 10:37 AM, Vincent Massol wrote: > >> Note that what I proposed doesn't work since it's not possible to >> register a component with 2 roles (for the same component instance) >> in plexus AFAIK. Thus you'd need 2 components: one for the listener >> and another one for the main business logic. Then the pb arises of >> how to pass information from one to another... >> >> Still looking for a simple solution to that (I have one but it's too >> complex). If you have any idea, shoot. > > I spoke too fast. I think this solution could work: > > @Component > DefaultMacroManager implements MacroManager > { > private Map macros; > > public Macro getMacro(...) > {...} > > public void registerMacro(...) > {...} > ... > } > > @Component("macro") > MacroManagerListener implements ObservationListener > { > @Requirement > MacroManager mm; > > void onEvent(Event event) > { > mm.registerMacro(...); > ... > } > > The only "downside" is that it forces MacroManager (in our example) to > add a public method registerMacro which was not needed before. Is that > a problem? > > Is there a better solution?
I think in this use case it's not that bad to be able to register a macro programmaticaly anyway. Could be very useful. > > Thanks > -Vincent > >> On May 26, 2009, at 10:19 PM, Vincent Massol wrote: >> >>> Hi, >>> >>> There's a pb with the current implementation: >>> When we get the Observation manager implementation and list the >>> registered listeners we only get the components that have been >>> initialized *before* we get the Observation manager component. Thus >>> if we want to be sure all listeners will receive events we need to >>> ensure they're loaded first. This is hard to do. >>> >>> I'm proposing instead to modify the observation module: >>> >>> * Modify EventListener to be a @ComponentRole >>> * Add List<Event> EventListener.getEvents() (the events that the >>> listener handles) >>> * Inject List<EventListener> in DefaultObservationManager. Thus >>> when the Observation Manager is looked up, all listener components >>> are created and injected. >>> * Keep add/removeListener in ObservationManager so that listeners >>> can be manually added/removed (for ex if a new listener component >>> is added dynamically in the system) but with following signatures: >>> - addListener(EventListener); >>> - removeListener(EventListener); >>> >>> WDYT? >>> >>> Thanks >>> -Vincent >>> >> > > _______________________________________________ > devs mailing list > [email protected] > http://lists.xwiki.org/mailman/listinfo/devs > -- Thomas Mortagne _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs

