"ExampleService.thrift.client.read-timeout", "1000ms"
);
// In this case, no child injector is needed because Jsr250 handles post-construct
// exceptions gracefully by running the @PreDestroy for any injected instances
Jsr250Injector injector = Jsr250.createInjector(
Stage.PRODUCTION,
new ConfigurationModule(new ConfigurationFactory(configuration)),
new ThriftCodecModule(),
new ThriftClientModule(),
new Module()
{
@Override
public void configure(Binder binder)
{
binder.bind(String.class)
.annotatedWith(Names.named("stringToProcess"))
.toInstance("jsr250InjectorExample");
thriftClientBinder(binder).bindThriftClient(ExampleService.class);
}
});
ThriftClient<ExampleService> clientFactory =
injector.getInstance(Key.get(new TypeLiteral<ThriftClient<ExampleService>>() {}));
String stringToProcess =
injector.getInstance(Key.get(String.class, Names.named("stringToProcess")));
new ClientExampleHelper(clientFactory, stringToProcess).execute();
injector.destroy();
}