Search in sources :

Example 1 with RealtimeSystemModule

use of com.ning.metrics.meteo.binder.RealtimeSystemModule 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();
        }
    });
}
Also used : RealtimeSystemModule(com.ning.metrics.meteo.binder.RealtimeSystemModule) HashMap(java.util.HashMap) SubscribersCompiler(com.ning.metrics.meteo.subscribers.SubscribersCompiler) Injector(com.google.inject.Injector) JettyServer(com.ning.metrics.meteo.server.JettyServer) DefaultServlet(org.eclipse.jetty.servlet.DefaultServlet) GuiceContainer(com.sun.jersey.guice.spi.container.servlet.GuiceContainer) ServletModule(com.google.inject.servlet.ServletModule)

Aggregations

Injector (com.google.inject.Injector)1 ServletModule (com.google.inject.servlet.ServletModule)1 RealtimeSystemModule (com.ning.metrics.meteo.binder.RealtimeSystemModule)1 JettyServer (com.ning.metrics.meteo.server.JettyServer)1 SubscribersCompiler (com.ning.metrics.meteo.subscribers.SubscribersCompiler)1 GuiceContainer (com.sun.jersey.guice.spi.container.servlet.GuiceContainer)1 HashMap (java.util.HashMap)1 DefaultServlet (org.eclipse.jetty.servlet.DefaultServlet)1