Package com.mycila.inject.jsr250

Examples of com.mycila.inject.jsr250.Jsr250Injector


                "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();
    }
View Full Code Here

TOP

Related Classes of com.mycila.inject.jsr250.Jsr250Injector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.