/** * When instantiating the module this way be sure to read {@link DefaultPlaceManager} and manually bind the required * constants. Consider using {@link DefaultModule.Builder} if you need to use a different implementation than the * default one for a binding. * <p/> * <b>Important!</b> If you use this class, don't forget to bind {@link DefaultPlace}, {@link ErrorPlace} and {@link * UnauthorizedPlace} to name tokens associated to a presenter.<br/> */ public DefaultModule() { this(new Builder()); }
public class ClientModule extends AbstractPresenterModule { @Override protected void configure() { install(new DefaultModule(MyPlaceManager.class)); }
@Override protected void configure() { install(new CommonGinModule()); bind(RootPresenter.class).asEagerSingleton(); bind(EventBus.class).to(builder.getEventBusClass()).in(Singleton.class); bind(TokenFormatter.class).to(builder.getTokenFormatterClass()).in(Singleton.class); bind(PlaceManager.class).to(builder.getPlaceManagerClass()).in(Singleton.class); maybeBindConstant(DefaultPlace.class, builder.getDefaultPlace()); maybeBindConstant(ErrorPlace.class, builder.getErrorPlace()); maybeBindConstant(UnauthorizedPlace.class, builder.getUnauthorizedPlace()); }
@Override protected void configure() { // dummy, redefine in your application install(new DefaultModule.Builder().placeManager(OwnPlaceManagerImpl.class) .defaultPlace(NameTokens.LOGIN).errorPlace(NameTokens.LOGIN) .unauthorizedPlace(NameTokens.LOGIN).build()); this.bindPresenter(NavigationPresenter.class, NavigationPresenter.MyView.class, TreeNavigationView.class, NavigationPresenter.MyProxy.class); this.bind(User.class).to(MinimumUser.class).in(Singleton.class); this.bind(Session.class).to(DummySession.class).in(Singleton.class); this.bind(NavigationStructure.class).to(DummyNavigationStructure.class).in(Singleton.class); } }
/** * Convenience method for binding a non-singleton {@link PresenterWidget} with * its {@link View}. * * @param <P> The {@link PresenterWidget} class type. * @param <V> The {@link View} interface type. * @param presenterImpl The {@link PresenterWidget} implementation (NOT a * singleton). * @param view The {@link View} interface. * @param viewImpl The {@link View} implementation (NOT a singleton). */ protected <P extends PresenterWidget<?>, V extends View> void bindPresenterWidget( Class<P> presenterImpl, Class<V> view, Class<? extends V> viewImpl) { bind(presenterImpl); bind(view).to(viewImpl); }
private void maybeBindConstant(Class<? extends Annotation> annotationClass, String nameToken) { if (nameToken != null && !nameToken.isEmpty()) { bindConstant().annotatedWith(annotationClass).to(nameToken); } } }
public class ClientModule extends AbstractPresenterModule { @Override protected void configure() { bind(RestyGwtConfig.class).asEagerSingleton(); install(new DefaultModule.Builder().defaultPlace(Routing.PAGE.url).errorPlace(Routing.PAGE.url).unauthorizedPlace(Routing.LOGIN.url).tokenFormatter(RouteTokenFormatter.class).build()); install(new AppModule()); bind(CurrentUser.class).in(Singleton.class); bind(IsAdminGatekeeper.class).in(Singleton.class); bind(UserLoginGatekeeper.class).in(Singleton.class); } }
protected void configure() { // Singletons install(new DefaultModule(ClientPlaceManager.class)); ...
/** * Convenience method for binding a singleton presenter with its view and its * proxy, when using custom-made proxy classes. * * @param <P> The {@link Presenter} class type. * @param <V> The {@link View} interface type. * @param <Proxy_> The {@link Proxy} type. * @param presenterImpl The {@link Presenter} implementation (a singleton). * @param view The {@link View} interface. * @param viewImpl The {@link View} implementation (a singleton). * @param proxy The {@link Proxy} interface. * @param proxyImpl The {@link Proxy} implementation (a singleton). */ protected <P extends Presenter<?, ?>, V extends View, Proxy_ extends Proxy<P>> void bindPresenterCustomProxy( Class<P> presenterImpl, Class<V> view, Class<? extends V> viewImpl, Class<Proxy_> proxy, Class<? extends Proxy_> proxyImpl) { bind(presenterImpl).in(Singleton.class); bind(viewImpl).in(Singleton.class); bind(proxyImpl).asEagerSingleton(); bind(view).to(viewImpl); bind(proxy).to(proxyImpl); }
public DefaultModule build() { return new DefaultModule(this); }
/** * Convenience method for binding a non-singleton {@link PresenterWidget} with * its {@link View}. * * @param <P> The {@link PresenterWidget} interface type. * @param <V> The {@link View} interface type. * @param presenter The {@link PresenterWidget} interface. * @param presenterImpl The {@link PresenterWidget} implementation (NOT a * singleton). * @param view The {@link View} interface. * @param viewImpl The {@link View} implementation (NOT a singleton). */ protected <P extends PresenterWidget<?>, V extends View> void bindPresenterWidget( Class<P> presenter, Class<? extends P> presenterImpl, Class<V> view, Class<? extends V> viewImpl) { bind(presenter).to(presenterImpl); bind(view).to(viewImpl); }
/** * Bind a view interface to its implementation in a non-singleton manner. * <p/> * <b>Important!</b> This is only be meant to be used for presenter associated * with non-singleton views, for example when the same view class is reused * with many presenters. As such, you will use this method with * {@link #bindPresenter(Class, Class)}, * {@link #bindPresenter(Class, Class, Class)}, * {@link #bindPresenterCustomProxy(Class, Class, Class)}, or * {@link #bindPresenterCustomProxy(Class, Class, Class, Class)}, If the view * class is use only by one presenter, you should consider using * {@link #bindPresenter(Class, Class, Class, Class, Class)} instead. * * @param <V> The {@link View} interface type. * @param view The {@link View} interface. * @param viewImpl The {@link View} implementation (not a singleton). */ protected <V extends View> void bindSharedView(Class<V> view, Class<? extends V> viewImpl) { bind(view).to(viewImpl); }
/** * Convenience method for binding a singleton presenter with its view and its * proxy, when using automatically generated proxy classes. * * @param <P> The {@link Presenter} class type. * @param <V> The {@link View} interface type. * @param <Proxy_> The {@link Proxy} type. * @param presenterImpl The {@link Presenter} implementation (a singleton). * @param view The {@link View} interface. * @param viewImpl The {@link View} implementation (a singleton). * @param proxy The {@link Proxy} interface, which will lead to an * automatically generated proxy classes. */ protected <P extends Presenter<?, ?>, V extends View, Proxy_ extends Proxy<P>> void bindPresenter( Class<P> presenterImpl, Class<V> view, Class<? extends V> viewImpl, Class<Proxy_> proxy) { bind(presenterImpl).in(Singleton.class); bind(viewImpl).in(Singleton.class); bind(proxy).asEagerSingleton(); bind(view).to(viewImpl); }
/** * Convenience method for binding a singleton presenter with its proxy, when * using automatically generated proxy classes and non-singleton views. * <p/> * <b>Important!</b> This is only be meant to be used by presenters associated * with non-singleton views, for example when the same view class is reused * with many presenters. As such, you will need to also use the * {@link #bindSharedView} method. If the view class is use only by one * presenter, you should consider using * {@link #bindPresenter(Class, Class, Class, Class)} instead. * * @param <P> The {@link Presenter} class type. * @param <Proxy_> The {@link Proxy} type. * @param presenterImpl The {@link Presenter} implementation (a singleton). * @param proxy The {@link Proxy} interface, which will lead to an * automatically generated proxy classes. */ protected <P extends Presenter<?, ?>, Proxy_ extends Proxy<P>> void bindPresenter( Class<P> presenterImpl, Class<Proxy_> proxy) { bind(presenterImpl).in(Singleton.class); bind(proxy).asEagerSingleton(); }
/** * Convenience method for binding a singleton presenter with its proxy, when * using automatically generated proxy classes and non-singleton views. * <p/> * <b>Important!</b> This is only be meant to be used by presenters associated * with non-singleton views, for example when the same view class is reused * with many presenters. As such, you will need to also use the * {@link #bindSharedView} method. If the view class is use only by one * presenter, you should consider using * {@link #bindPresenter(Class, Class, Class, Class, Class)} instead. * * @param <P> The {@link Presenter} interface type. * @param <Proxy_> The {@link Proxy} type. * @param presenterImpl The {@link Presenter} interface. * @param proxy The {@link Proxy} interface, which will lead to an * automatically generated proxy classes. */ protected <P extends Presenter<?, ?>, Proxy_ extends Proxy<P>> void bindPresenter( Class<P> presenter, Class<? extends P> presenterImpl, Class<Proxy_> proxy) { bind(presenterImpl).in(Singleton.class); bind(proxy).asEagerSingleton(); bind(presenter).to(presenterImpl); }
/** * Convenience method for binding a singleton presenter with its view and its * proxy, when using automatically generated proxy classes. * * @param <P> The {@link Presenter} interface type. * @param <V> The {@link View} interface type. * @param <Proxy_> The {@link Proxy} type. * @param presenter The {@link Presenter} interface. * @param presenterImpl The {@link Presenter} implementation (a singleton). * @param view The {@link View} interface. * @param viewImpl The {@link View} implementation (a singleton). * @param proxy The {@link Proxy} interface, which will lead to an * automatically generated proxy classes. */ protected <P extends Presenter<?, ?>, V extends View, Proxy_ extends Proxy<P>> void bindPresenter( Class<P> presenter, Class<? extends P> presenterImpl, Class<V> view, Class<? extends V> viewImpl, Class<Proxy_> proxy) { bind(presenterImpl).in(Singleton.class); bind(viewImpl).in(Singleton.class); bind(proxy).asEagerSingleton(); bind(presenter).to(presenterImpl); bind(view).to(viewImpl); }
/** * Convenience method for binding a singleton presenter with its proxy, when * using custom-made proxy classes and non-singleton views. * <p/> * <b>Important!</b> This is only be meant to be used by presenters associated * with non-singleton views, for example when the same view class is reused * with many presenters. As such, you will need to also use the * {@link #bindSharedView} method. If the view class is used only by one * presenter, you should consider using * {@link #bindPresenterCustomProxy(Class, Class, Class, Class, Class)} * instead. * * @param <P> The {@link Presenter} class type. * @param <Proxy_> The {@link Proxy} type. * @param presenterImpl The {@link Presenter} implementation (a singleton). * @param proxy The {@link Proxy} interface. * @param proxyImpl The {@link Proxy} implementation (a singleton). */ protected <P extends Presenter<?, ?>, Proxy_ extends Proxy<P>> void bindPresenterCustomProxy( Class<P> presenterImpl, Class<Proxy_> proxy, Class<? extends Proxy_> proxyImpl) { bind(presenterImpl).in(Singleton.class); bind(proxyImpl).asEagerSingleton(); bind(proxy).to(proxyImpl); }
/** * Convenience method for binding a singleton presenter with its view and its * proxy, when using custom-made proxy classes. * * @param <P> The {@link Presenter} interface type. * @param <V> The {@link View} interface type. * @param <Proxy_> The {@link Proxy} type. * @param presenter The {@link Presenter} interface. * @param presenterImpl The {@link Presenter} implementation (a singleton). * @param view The {@link View} interface. * @param viewImpl The {@link View} implementation (a singleton). * @param proxy The {@link Proxy} interface. * @param proxyImpl The {@link Proxy} implementation (a singleton). */ protected <P extends Presenter<?, ?>, V extends View, Proxy_ extends Proxy<P>> void bindPresenterCustomProxy( Class<P> presenter, Class<? extends P> presenterImpl, Class<V> view, Class<? extends V> viewImpl, Class<Proxy_> proxy, Class<? extends Proxy_> proxyImpl) { bind(presenterImpl).in(Singleton.class); bind(viewImpl).in(Singleton.class); bind(proxyImpl).asEagerSingleton(); bind(presenter).to(presenterImpl); bind(view).to(viewImpl); bind(proxy).to(proxyImpl); }
/** * Convenience method for binding a singleton presenter with its proxy, when * using custom-made proxy classes and non-singleton views. * <p/> * <b>Important!</b> This is only be meant to be used by presenters associated * with non-singleton views, for example when the same view class is reused * with many presenters. As such, you will need to also use the * {@link #bindSharedView} method. If the view class is use only by one * presenter, you should consider using * {@link #bindPresenterCustomProxy(Class, Class, Class, Class, Class, Class)} * instead. * * @param <P> The {@link Presenter} interface type. * @param <Proxy_> The {@link Proxy} type. * @param presenter The {@link Presenter} interface. * @param presenterImpl The {@link Presenter} implementation (a singleton). * @param proxy The {@link Proxy} interface. * @param proxyImpl The {@link Proxy} implementation (a singleton). */ protected <P extends Presenter<?, ?>, Proxy_ extends Proxy<P>> void bindPresenterCustomProxy( Class<P> presenter, Class<? extends P> presenterImpl, Class<Proxy_> proxy, Class<? extends Proxy_> proxyImpl) { bind(presenterImpl).in(Singleton.class); bind(proxyImpl).asEagerSingleton(); bind(presenter).to(presenterImpl); bind(proxy).to(proxyImpl); }
/** * Convenience method for binding a non-singleton {@link PresenterWidget} that * is created via a factory to its {@link View}, which is also created via a * factory. * * @param <P> The type of the {@link PresenterWidget} factory. * @param <V> The type of the {@link View} factory. * @param presenterFactory The interface to the {@link PresenterWidget} * factory. * @param presenterFactoryImpl The implementation of the * {@link PresenterWidget} factory. * @param viewFactory The interface to the {@link View} factory. * @param viewFactoryImpl The implementation of the {@link View} factory. */ protected <P, V> void bindPresenterWidgetFactory(Class<P> presenterFactory, Class<? extends P> presenterFactoryImpl, Class<V> viewFactory, Class<? extends V> viewFactoryImpl) { bind(presenterFactory).to(presenterFactoryImpl).in(Singleton.class); bind(viewFactory).to(viewFactoryImpl).in(Singleton.class); }