Open GoogleCodeExporter opened 9 years ago
I have multimodule structure of aplication where structure is as follows: BootstrapModule | +-DashbordModule => /#!dashboard/start +-ChildModule1 => /#!module1/list +-ChildModule2 => /#!module2/list +-AdminModule => /#!admin/start Here is my BootstrapEventBus: @Events(startPresenter = BootstrapPresenter.class, historyOnStart = true, ginModules = BootstrapGinModule.class) @ChildModules({ @ChildModule(moduleClass = DashboardModule.class), @ChildModule(moduleClass = Module1Module.class), @ChildModule(moduleClass = Module2Module.class), @ChildModule(moduleClass = AdminModule.class)}) @Debug(logLevel = Debug.LogLevel.SIMPLE) @Filters(filterClasses = EntitlementEventFilter.class) public interface BootstrapEventBus extends EventBusWithLookup { @Start @InitHistory @Event(handlers = BootstrapPresenter.class) public void init(); @Event(forwardToModules = DashboardModule.class, navigationEvent = true) public void startDashboard(); @Event(forwardToModules = Module1Module.class, navigationEvent = true) public void startModule1(); @Event(forwardToModules = Module2Module.class, navigationEvent = true) public void startModule2(); @Event(forwardToModules = AdminModule.class, navigationEvent = true) public void startAdmin(); @DisplayChildModuleView({DashboardModule.class, Module1Module.class, Module2Module.class, AdminModule.class}) @Event(handlers = BootstrapPresenter.class) public void changeBody(Widget widget); @NotFoundHistory @Event(handlers = BootstrapPresenter.class) public void show404(); } Additionally I have EntitlementEventFilter declared in BootstrapEventBus that allows only logged user to run AdminModule: public class EntitlementEventFilter implements EventFilter<BootstrapEventBus> { private static final Logger logger = Logger.getLogger(EntitlementEventFilter.class.getName()); @Inject EntitlementsService entitlementsService; @Override public boolean filterEvent(String eventName, Object[] params, BootstrapEventBus eventBus) { boolean notAllowed = "startAdmin".equals(eventName); boolean isLogged = entitlementsService.isLogged(); boolean filtering = !notAllowed || isLogged; logger.log(Level.INFO, "EntitlementEventFilter: event: '"+eventName+"', passFilter: " + filtering + " isEventFromBlackList: " + notAllowed + ", isUserLogged: " + isLogged); return filtering; } } Everything works like a charm when I'm navigating via BootstrapEventBus. When I'm not logged I won't run admin module. The problem I noticed, occurs when I'm trying to enter application via URL: http://localhost:8080/#!admin/start. Here is how initialisation goes. I added BootstrapPlaceService to check how events occurs: 01) EntitlementsService [construct] 02) EntitlementEventFilter: event: 'init', passFilter: true isEventFromBlackList: false, isUserLogged: false 03) BootstrapPresenter.onInit, logged: false 04) BootstrapPlaceService.convertToken: '!admin/start' 05) AdminPresenter.onInit, logged: false 06) EntitlementEventFilter: event: 'changeBody', passFilter: true isEventFromBlackList: false, isUserLogged: false 07) BootstrapPresenter.onChangeBody for view ': admin' 08) BootstrapPlaceService.dispatchEvent: 'admin/start' 09) class pl.pkosmowski.mvp4ghistory.client.adminpanel.AdminHistoryConverter 01) history from token: start logged: false 10) Module2Presenter.onStartAdmin The problem is that EntitlementEventFilter never filters event 'onRunAdmin'. It should happens before AdminModule initialisation so between lines 4 and 5 so it means the feature needs to be added to PlaceService.convertToken method. Please find comment below: protected void convertToken( String token ) { boolean toContinue = false; if ( token != null ) { if ( token.startsWith( CRAWLABLE ) ) { token = token.substring( 1 ); } toContinue = ( token.length() > 0 ); } if ( toContinue ) { String[] result = parseToken( token ); // Here events need to be filtered before forwarding if ( !forwardToChildModuleIfNeeded( result[0], result[1] ) ) { dispatchEvent( result[0], result[1], module ); } } else { module.sendInitEvent(); } }
Original issue reported on code.google.com by kospiotr on 23 Jun 2013 at 1:33
kospiotr
How does mvp4g behave if you use the eventbus directly?
Original comment by frank.hossfeld on 8 Aug 2013 at 11:38
frank.hossfeld
Original issue reported on code.google.com by
kospiotr
on 23 Jun 2013 at 1:33