public <T> GinConstantBindingBuilder bindConstant() { return binder.bindConstant().annotatedWith(Internal.class); }
private void maybeBindConstant(Class<? extends Annotation> annotationClass, String nameToken) { if (nameToken != null && !nameToken.isEmpty()) { bindConstant().annotatedWith(annotationClass).to(nameToken); } } }
@Override protected void configure() { install(new RestDispatchAsyncModule.Builder().xsrfTokenHeaderName(ResourcePaths.XSRF_HEADER) .build()); bindConstant().annotatedWith(SecurityCookie.class).to(ResourcePaths.XSRF_COOKIE); }
@Override protected void configure() { install(new RestDispatchAsyncModule.Builder().xsrfTokenHeaderName(ResourcePaths.XSRF_HEADER) .build()); bindConstant().annotatedWith(SecurityCookie.class).to(ResourcePaths.XSRF_COOKIE); }
@Override protected void configureDispatch() { // Common install(new CommonGinModule()); install(new SerializationModule()); install(builder.getCoreModule()); bind(RestFilterRegistry.class).to(builder.getFilterRegistry()).in(Singleton.class); // Constants / Configurations // It's not possible to bind non-native type constants, so we must encode them at compile-time and decode them // at runtime (ie: Global Parameters) String globalHeaderParams = bindingsSerializer.serialize(builder.getGlobalHeaderParams()); String globalQueryParams = bindingsSerializer.serialize(builder.getGlobalQueryParams()); bindConstant().annotatedWith(XsrfHeaderName.class).to(builder.getXsrfTokenHeaderName()); bindConstant().annotatedWith(RequestTimeout.class).to(builder.getRequestTimeoutMs()); bindConstant().annotatedWith(DefaultDateFormat.class).to(builder.getDefaultDateFormat()); bindConstant().annotatedWith(GlobalHeaderParams.class).to(globalHeaderParams); bindConstant().annotatedWith(GlobalQueryParams.class).to(globalQueryParams); }
@Override protected void configure() { bind(ProcessesOutputRestorer.class).asEagerSingleton(); bind(MachineFailNotifier.class).asEagerSingleton(); bind(MachineChooserView.class).to(MachineChooserViewImpl.class); bind(ModuleHolder.class).in(Singleton.class); bindConstant() .annotatedWith(Names.named("machine.extension.api_port")) .to(Constants.WS_AGENT_PORT); } }
@Override protected void configure() { install(new DefaultModule.Builder() .placeManager(DefaultPlaceManager.class) .tokenFormatter(RouteTokenFormatter.class) .build()); bind(CurrentUser.class).asEagerSingleton(); bindConstant().annotatedWith(DefaultPlace.class).to(NameTokens.getHome()); bindConstant().annotatedWith(ErrorPlace.class).to(NameTokens.getHome()); bindConstant().annotatedWith(UnauthorizedPlace.class).to(NameTokens.getLogin()); install(new ServiceModule()); install(new LoginModule()); install(new ApplicationModule()); } }
@Override protected void configure() { install(new DefaultModule.Builder() .tokenFormatter(RouteTokenFormatter.class) .defaultPlace(NameTokens.HOME) .errorPlace(NameTokens.HOME) .unauthorizedPlace(NameTokens.HOME) .build()); install(new RestDispatchAsyncModule()); install(new ApplicationModule()); bind(ResourceLoader.class).asEagerSingleton(); bindConstant().annotatedWith(RestApplicationPath.class).to("/api"); bind(MyGatekeeper.class).in(Singleton.class); } }