use of com.google.inject.servlet.ServletModule in project meteo by pierre.
the class RealtimeSystem method main.
public static void main(final String[] args) throws Exception {
final Injector injector = Guice.createInjector(new RealtimeSystemModule(), new ServletModule() {
@Override
protected void configureServlets() {
// Static files
bind(DefaultServlet.class).asEagerSingleton();
serve("/media/*").with(DefaultServlet.class);
serve("*").with(GuiceContainer.class, new HashMap<String, String>() {
{
put(PackagesResourceConfig.PROPERTY_PACKAGES, "com.ning.metrics.meteo.server.resources");
}
});
}
});
final SubscribersCompiler subscribersCompiler = injector.getInstance(SubscribersCompiler.class);
subscribersCompiler.startAll();
final JettyServer jetty = injector.getInstance(JettyServer.class);
jetty.start(injector);
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
subscribersCompiler.stopAll();
jetty.stop();
}
});
}
use of com.google.inject.servlet.ServletModule in project API by ca-cwds.
the class JerseyGuiceRule method before.
@Override
protected void before() throws Throwable {
Injector baseInjector = Guice.createInjector(Stage.PRODUCTION, new ServletModule());
JerseyGuiceUtils.install(new ServiceLocatorGenerator() {
@Override
public ServiceLocator create(String name, ServiceLocator parent) {
if (!name.startsWith("__HK2_Generated_")) {
return null;
}
return baseInjector.createChildInjector(new JerseyGuiceModule(name)).getInstance(ServiceLocator.class);
}
});
}
Aggregations