Search in sources :

Example 1 with UserPingTask

use of net.socialgamer.cah.task.UserPingTask in project PretendYoureXyzzy by ajanata.

the class StartupUtils method contextInitialized.

@Override
public void contextInitialized(final ServletContextEvent contextEvent) {
    final ServletContext context = contextEvent.getServletContext();
    reconfigureLogging(context);
    final Injector injector = getInjector(context);
    final ScheduledThreadPoolExecutor timer = injector.getInstance(ScheduledThreadPoolExecutor.class);
    final UserPingTask ping = injector.getInstance(UserPingTask.class);
    timer.scheduleAtFixedRate(ping, PING_START_DELAY, PING_CHECK_DELAY, TimeUnit.MILLISECONDS);
    final BroadcastGameListUpdateTask broadcastUpdate = injector.getInstance(BroadcastGameListUpdateTask.class);
    timer.scheduleAtFixedRate(broadcastUpdate, BROADCAST_UPDATE_START_DELAY, BROADCAST_UPDATE_DELAY, TimeUnit.MILLISECONDS);
    context.setAttribute(INJECTOR, injector);
    context.setAttribute(DATE_NAME, injector.getInstance(Key.get(Date.class, ServerStarted.class)));
    // this is called in the process of setting up the injector right now... ideally we wouldn't
    // need to do that there and can just do it here again.
    // reloadProperties(context);
    CardcastService.hackSslVerifier();
    // log that the server (re-)started to metrics logging (to flush all old games and users)
    injector.getInstance(Metrics.class).serverStart(injector.getInstance(Key.get(String.class, UniqueId.class)));
}
Also used : Metrics(net.socialgamer.cah.metrics.Metrics) BroadcastGameListUpdateTask(net.socialgamer.cah.task.BroadcastGameListUpdateTask) Injector(com.google.inject.Injector) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) ServletContext(javax.servlet.ServletContext) UserPingTask(net.socialgamer.cah.task.UserPingTask)

Aggregations

Injector (com.google.inject.Injector)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 ServletContext (javax.servlet.ServletContext)1 Metrics (net.socialgamer.cah.metrics.Metrics)1 BroadcastGameListUpdateTask (net.socialgamer.cah.task.BroadcastGameListUpdateTask)1 UserPingTask (net.socialgamer.cah.task.UserPingTask)1