use of org.webpieces.util.threading.SafeRunnable in project webpieces by deanhiller.
the class RouteLoader method createTHEModule.
// private XFuture<Void> setupSimpleStorage(Injector injector) {
// SimpleStorage storage = injector.getInstance(SimpleStorage.class);
//
// List<XFuture<?>> futures = new ArrayList<>();
// List<NeedsSimpleStorage> needsStorage = config.getNeedsStorage();
// for(NeedsSimpleStorage bean : needsStorage) {
// XFuture<Void> future = bean.init(storage);
// futures.add(future);
// }
//
// return XFuture.allOf(futures.toArray(new XFuture<?>[0]));
// }
public Module createTHEModule(WebAppMeta routerModule, RoutingHolder routingHolder) {
List<Module> guiceModules = routerModule.getGuiceModules();
if (guiceModules == null)
guiceModules = new ArrayList<>();
int corePoolSize = config.getScheduledThreadPoolSize();
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(corePoolSize, new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
// always name the threads & prevent thread death
Thread t = new Thread(new SafeRunnable(r), "webpieces-scheduling");
t.setDaemon(true);
return t;
}
});
guiceModules.add(new WebpiecesToAppBindingModule(routingHolder, beanMeta, platformInjector, objectTranslator, scheduler, metrics));
Module module = Modules.combine(guiceModules);
List<Plugin> plugins = routerModule.getPlugins();
if (plugins != null) {
for (Plugin plugin : plugins) {
List<Module> modules = new ArrayList<>();
modules.addAll(plugin.getGuiceModules());
modules.add(module);
module = Modules.combine(modules);
}
}
if (config.getWebappOverrides() != null)
module = Modules.override(module).with(config.getWebappOverrides());
return module;
}
Aggregations