Search in sources :

Example 1 with JerseyServletModule

use of com.sun.jersey.guice.JerseyServletModule in project platformlayer by platformlayer.

the class KeystoneAdminServer method main.

public static void main(String[] args) throws Exception {
    List<Module> modules = Lists.newArrayList();
    modules.add(new ConfigurationModule());
    modules.add(new CacheModule());
    modules.add(new GuiceAuthenticationConfig());
    modules.add(new KeystoneJdbcModule());
    modules.add(new KeystoneOpsSystemModule());
    modules.add(new CodahaleMetricsModule());
    modules.add(new JerseyServletModule() {

        @Override
        protected void configureServlets() {
            bind(TokensResource.class);
            bind(KeychainResource.class);
            bind(PkiResource.class);
            bind(ServicesResource.class);
            Map<String, String> params = Maps.newHashMap();
            params.put(PackagesResourceConfig.PROPERTY_PACKAGES, "org.openstack.keystone.jaxrs;org.codehaus.jackson.jaxrs");
            serve("/*").with(GuiceContainer.class, params);
        }
    });
    Injector injector = Guice.createInjector(modules);
    KeystoneAdminServer server = injector.getInstance(KeystoneAdminServer.class);
    server.start(WellKnownPorts.PORT_PLATFORMLAYER_AUTH_ADMIN);
}
Also used : KeystoneOpsSystemModule(org.platformlayer.auth.keystone.KeystoneOpsSystemModule) KeystoneJdbcModule(org.platformlayer.auth.KeystoneJdbcModule) CacheModule(org.platformlayer.cache.CacheModule) TokensResource(org.openstack.keystone.resources.admin.TokensResource) CodahaleMetricsModule(org.platformlayer.metrics.client.codahale.CodahaleMetricsModule) ConfigurationModule(org.platformlayer.config.ConfigurationModule) Injector(com.google.inject.Injector) GuiceAuthenticationConfig(org.platformlayer.auth.server.GuiceAuthenticationConfig) JerseyServletModule(com.sun.jersey.guice.JerseyServletModule) GuiceContainer(com.sun.jersey.guice.spi.container.servlet.GuiceContainer) Module(com.google.inject.Module) CodahaleMetricsModule(org.platformlayer.metrics.client.codahale.CodahaleMetricsModule) JerseyServletModule(com.sun.jersey.guice.JerseyServletModule) ConfigurationModule(org.platformlayer.config.ConfigurationModule) CacheModule(org.platformlayer.cache.CacheModule) KeystoneJdbcModule(org.platformlayer.auth.KeystoneJdbcModule) KeystoneOpsSystemModule(org.platformlayer.auth.keystone.KeystoneOpsSystemModule) KeychainResource(org.openstack.keystone.resources.admin.KeychainResource) ServicesResource(org.openstack.keystone.resources.admin.ServicesResource) PkiResource(org.openstack.keystone.resources.admin.PkiResource) Map(java.util.Map)

Example 2 with JerseyServletModule

use of com.sun.jersey.guice.JerseyServletModule in project commons by twitter.

the class HttpStatsFilterIntegrationTest method setUp.

@Before
public void setUp() {
    Stats.flush();
    server = new JettyHttpServerDispatch();
    server.listen(0);
    server.registerFilter(GuiceFilter.class, "/*");
    clock = new FakeClock();
    final Injector injector = Guice.createInjector(new AbstractModule() {

        @Override
        protected void configure() {
            bind(TestServlet.class).in(Singleton.class);
            bind(Clock.class).toInstance(clock);
            bind(HttpStatsFilter.class).in(Singleton.class);
        }
    }, new JerseyServletModule() {

        @Override
        protected void configureServlets() {
            filter("/*").through(HttpStatsFilter.class);
            serve("/*").with(GuiceContainer.class, ImmutableMap.of(PROPERTY_CONTAINER_RESPONSE_FILTERS, HttpStatsFilter.class.getName()));
        }
    });
    server.getRootContext().addEventListener(new GuiceServletContextListener() {

        @Override
        protected Injector getInjector() {
            return injector;
        }
    });
    ClientConfig config = new DefaultClientConfig();
    client = Client.create(config);
}
Also used : JettyHttpServerDispatch(com.twitter.common.net.http.JettyHttpServerDispatch) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) FakeClock(com.twitter.common.util.testing.FakeClock) Injector(com.google.inject.Injector) Singleton(com.google.inject.Singleton) JerseyServletModule(com.sun.jersey.guice.JerseyServletModule) GuiceContainer(com.sun.jersey.guice.spi.container.servlet.GuiceContainer) ClientConfig(com.sun.jersey.api.client.config.ClientConfig) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) GuiceServletContextListener(com.google.inject.servlet.GuiceServletContextListener) AbstractModule(com.google.inject.AbstractModule) Before(org.junit.Before)

Example 3 with JerseyServletModule

use of com.sun.jersey.guice.JerseyServletModule 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

JerseyServletModule (com.sun.jersey.guice.JerseyServletModule)3 AbstractModule (com.google.inject.AbstractModule)2 Injector (com.google.inject.Injector)2 GuiceContainer (com.sun.jersey.guice.spi.container.servlet.GuiceContainer)2 Module (com.google.inject.Module)1 Singleton (com.google.inject.Singleton)1 GuiceServletContextListener (com.google.inject.servlet.GuiceServletContextListener)1 Client (com.sun.jersey.api.client.Client)1 ClientConfig (com.sun.jersey.api.client.config.ClientConfig)1 DefaultClientConfig (com.sun.jersey.api.client.config.DefaultClientConfig)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 JettyHttpServerDispatch (com.twitter.common.net.http.JettyHttpServerDispatch)1 FakeClock (com.twitter.common.util.testing.FakeClock)1 Map (java.util.Map)1 Before (org.junit.Before)1 KeychainResource (org.openstack.keystone.resources.admin.KeychainResource)1 PkiResource (org.openstack.keystone.resources.admin.PkiResource)1