org.glassfish.hk2.utilities.Binder Java Examples
The following examples show how to use
org.glassfish.hk2.utilities.Binder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JerseyServletProvider.java From vespa with Apache License 2.0 | 5 votes |
private static Binder componentInjectorBinder(RestApiContext restApiContext) { final ComponentGraphProvider componentGraphProvider = new ComponentGraphProvider(restApiContext.getInjectableComponents()); final TypeLiteral<InjectionResolver<Component>> componentAnnotationType = new TypeLiteral<InjectionResolver<Component>>() { }; return new AbstractBinder() { @Override public void configure() { bind(componentGraphProvider).to(componentAnnotationType); } }; }
Example #2
Source File: ListFilteringFactory.java From dropwizard-experiment with MIT License | 5 votes |
public static Binder getBinder() { return new AbstractBinder() { @Override protected void configure() { bindFactory(ListFilteringFactory.class).to(ListFiltering.class); } }; }
Example #3
Source File: OAuth2AuthorizationRequestFactory.java From dropwizard-experiment with MIT License | 5 votes |
public static Binder getBinder() { return new AbstractBinder() { @Override protected void configure() { bindFactory(OAuth2AuthorizationRequestFactory.class).to(OAuth2AuthorizationRequest.class); } }; }
Example #4
Source File: HmacAuthFeature.java From jersey-hmac-auth with Apache License 2.0 | 4 votes |
protected Binder getBinder() { return binder; }
Example #5
Source File: PizzaApplication.java From jersey-hmac-auth with Apache License 2.0 | 4 votes |
protected Binder getPizzaApplicationBinder() { return pizzaApplicationBinder; }
Example #6
Source File: RaftApplication.java From barge with Apache License 2.0 | 4 votes |
public ResourceConfig makeResourceConfig() { ClusterConfig clusterConfig = HttpClusterConfig.from(new HttpReplica(uris[serverIndex]), remotes()); if (!logDir.exists() && !logDir.mkdirs()) logger.warn("failed to create directories for storing logs, bad things will happen"); StateMachine stateMachine = new StateMachine() { int i = 0; @Override public Object applyOperation(@Nonnull ByteBuffer entry) { return i++; } }; final JaxRsRaftModule raftModule = new JaxRsRaftModule(clusterConfig, logDir, stateMachine, 1500, transitionListeners, protocolListeners); injector = Optional.of(Guice.createInjector(raftModule)); ResourceConfig resourceConfig = new ResourceConfig(); Binder binder = new AbstractBinder() { @Override protected void configure() { bindFactory(new Factory<Raft>() { @Override public Raft provide() { return injector.get().getInstance(Raft.class); } @Override public void dispose(Raft raft) { } }).to(Raft.class); bindFactory(new Factory<ClusterConfig>() { @Override public ClusterConfig provide() { return injector.get().getInstance(ClusterConfig.class); } @Override public void dispose(ClusterConfig instance) { } }).to(ClusterConfig.class); } }; resourceConfig.register(BargeResource.class); resourceConfig.register(Jackson.customJacksonProvider()); resourceConfig.register(binder); return resourceConfig; }
Example #7
Source File: Openscoring.java From openscoring with GNU Affero General Public License v3.0 | 4 votes |
public Openscoring(){ Config config = ConfigFactory.load(); setConfig(config); Binder configBinder = new AbstractBinder(){ @Override public void configure(){ bind(config).to(Config.class).named("openscoring"); } }; register(configBinder); ModelRegistry modelRegistry = createModelRegistry(config); setModelRegistry(modelRegistry); Binder modelRegistryBinder = new AbstractBinder(){ @Override public void configure(){ bind(modelRegistry).to(ModelRegistry.class).named("openscoring"); } }; register(modelRegistryBinder); LoadingModelEvaluatorBuilder loadingModelEvaluatorBuilder = createLoadingModelEvaluatorBuilder(config); setLoadingModelEvaluatorBuilder(loadingModelEvaluatorBuilder); Binder loadingModelEvaluatorBuilderBinder = new AbstractBinder(){ @Override public void configure(){ bind(loadingModelEvaluatorBuilder).to(LoadingModelEvaluatorBuilder.class); } }; register(loadingModelEvaluatorBuilderBinder); Config applicationConfig = config.getConfig("application"); register(ModelResource.class); // Convert path variables to ModelRef objects register(loadClass(ModelRefConverterProvider.class, applicationConfig)); // PMML support register(loadClass(ModelProvider.class, applicationConfig)); // JSON support register(JacksonJsonProvider.class); register(ObjectMapperProvider.class); // CSV support register(loadClass(TableProvider.class, applicationConfig)); // Convert exceptions to JSON objects register(WebApplicationExceptionMapper.class); // Permit the HTTP POST method to be changed to HTTP PUT or DELETE methods register(HttpMethodOverrideFilter.class); // File upload support register(MultiPartFeature.class); // Security support register(RolesAllowedDynamicFeature.class); // GZip and Deflate encoding support register(EncodingFilter.class); register(GZipEncoder.class); register(DeflateEncoder.class); // Application identification register(ApplicationHeaderFilter.class); List<String> componentClassNames = applicationConfig.getStringList("componentClasses"); for(String componentClassName : componentClassNames){ Class<?> clazz = loadClass(Object.class, componentClassName); register(clazz); } }