use of org.webpieces.router.api.plugins.Plugin in project webpieces by deanhiller.
the class DevServerMeta method getPlugins.
@Override
public List<Plugin> getPlugins() {
List<Plugin> prodPlugins = prodMeta.getPlugins();
List<Plugin> devPlugins = Lists.newArrayList(// so the in-memory H2 DB can be queried to debug issues with your application code
new H2DbPlugin(new H2DbConfig()), new WebpiecesDocumentationPlugin(new DocumentationConfig()));
prodPlugins.addAll(devPlugins);
return prodPlugins;
}
use of org.webpieces.router.api.plugins.Plugin in project webpieces by deanhiller.
the class JsonMeta method getPlugins.
@Override
public List<Plugin> getPlugins() {
JacksonConfig config = new JacksonConfig("/json/.*");
config.setFilterClazz(TestCatchAllFilter.class);
config.setNotFoundFilterClazz(TestNotFoudSubclassFilter.class);
return Lists.<Plugin>newArrayList(new JacksonPlugin(config));
}
use of org.webpieces.router.api.plugins.Plugin 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;
}
use of org.webpieces.router.api.plugins.Plugin in project webpieces by deanhiller.
the class RouteLoader method loadAllRoutes.
// protected abstract void verifyRoutes(Collection<Route> allRoutes);
public void loadAllRoutes(WebAppMeta rm, Injector injector, RoutingHolder routingHolder) {
log.info("adding routes");
reverseRoutes = new ReverseRoutes(config, redirectFormation, objectTranslator, reverseTranslator);
ResettingLogic resettingLogic = new ResettingLogic(reverseRoutes, injector);
Boolean enableSeparateBackend = backPortExists.get();
DomainRouteBuilderImpl routerBuilder = new DomainRouteBuilderImpl(routerFutures, futureUtil, routeBuilderLogic, resettingLogic, enableSeparateBackend);
routingHolder.setReverseRouteLookup(reverseRoutes);
routeBuilderLogic.init(reverseRoutes);
List<Routes> all = new ArrayList<>();
// the core application routes
all.addAll(rm.getRouteModules());
List<Plugin> plugins = rm.getPlugins();
if (plugins != null) {
for (Plugin plugin : plugins) {
all.addAll(plugin.getRouteModules());
}
}
for (Routes module : all) {
CurrentRoutes.set(new RouteModuleInfo(module.getClass()));
module.configure(routerBuilder);
CurrentRoutes.set(null);
}
log.info("added all routes to router. Applying Filters");
reverseRoutes.finalSetup();
BRouter domainRouter = routerBuilder.build();
routingHolder.setDomainRouter(domainRouter);
masterRouter.setDomainRouter(domainRouter);
log.info("all filters applied");
compressionCacheSetup.setupCache(routerBuilder.getStaticRoutes());
}
Aggregations