Search in sources :

Example 1 with Closure

use of com.twitter.common.base.Closure in project commons by twitter.

the class Main method getModules.

@Override
public Iterable<? extends Module> getModules() {
    return Arrays.asList(new HttpModule(), new LogModule(), new StatsModule(), new AbstractModule() {

        @Override
        protected void configure() {
            bind(new TypeLiteral<Closure<String>>() {
            }).toInstance(new Closure<String>() {

                private final Client http = Client.create();

                @Override
                public void execute(String path) {
                    http.asyncResource("http://" + PING_TARGET.get() + path).get(String.class);
                }
            });
            install(new JerseyServletModule() {

                @Override
                protected void configureServlets() {
                    filter("/ping*").through(GuiceContainer.class, ImmutableMap.<String, String>of());
                    Registration.registerEndpoint(binder(), "/ping");
                    bind(PingHandler.class);
                }
            });
        }
    });
}
Also used : Closure(com.twitter.common.base.Closure) LogModule(com.twitter.common.application.modules.LogModule) HttpModule(com.twitter.common.application.modules.HttpModule) JerseyServletModule(com.sun.jersey.guice.JerseyServletModule) StatsModule(com.twitter.common.application.modules.StatsModule) Client(com.sun.jersey.api.client.Client) AbstractModule(com.google.inject.AbstractModule)

Aggregations

AbstractModule (com.google.inject.AbstractModule)1 Client (com.sun.jersey.api.client.Client)1 JerseyServletModule (com.sun.jersey.guice.JerseyServletModule)1 HttpModule (com.twitter.common.application.modules.HttpModule)1 LogModule (com.twitter.common.application.modules.LogModule)1 StatsModule (com.twitter.common.application.modules.StatsModule)1 Closure (com.twitter.common.base.Closure)1