Search in sources :

Example 1 with Plugin

use of org.webpieces.router.api.routing.Plugin in project webpieces by deanhiller.

the class RouteLoader method createInjector.

public Injector createInjector(WebAppMeta routerModule) {
    List<Module> guiceModules = routerModule.getGuiceModules();
    if (guiceModules == null)
        guiceModules = new ArrayList<>();
    guiceModules.add(new EmptyPluginModule());
    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());
    Injector injector = Guice.createInjector(module);
    return injector;
}
Also used : Injector(com.google.inject.Injector) ArrayList(java.util.ArrayList) Module(com.google.inject.Module) Plugin(org.webpieces.router.api.routing.Plugin)

Example 2 with Plugin

use of org.webpieces.router.api.routing.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) {
    log.info("adding routes");
    ReverseRoutes reverseRoutes = new ReverseRoutes(config);
    //routerBuilder = new RouterBuilder("", new AllRoutingInfo(), reverseRoutes, controllerFinder, config.getUrlEncoding());
    LogicHolder holder = new LogicHolder(reverseRoutes, controllerFinder, injector, config);
    routerBuilder = new R1RouterBuilder(new RouterInfo(null, ""), new L1AllRouting(), holder, false);
    invoker.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) {
        AbstractRouteBuilder.currentPackage.set(new RouteModuleInfo(module));
        module.configure(routerBuilder);
        AbstractRouteBuilder.currentPackage.set(null);
    }
    log.info("added all routes to router.  Applying Filters");
    reverseRoutes.finalSetup();
    routerBuilder.applyFilters(rm);
    Collection<RouteMeta> metas = reverseRoutes.getAllRouteMetas();
    for (RouteMeta m : metas) {
        controllerFinder.loadFiltersIntoMeta(m, m.getFilters(), true);
    }
    routerBuilder.loadNotFoundAndErrorFilters();
    log.info("all filters applied");
    compressionCacheSetup.setupCache(routerBuilder.getStaticRoutes());
}
Also used : RouterInfo(org.webpieces.router.impl.model.RouterInfo) ArrayList(java.util.ArrayList) Routes(org.webpieces.router.api.routing.Routes) R1RouterBuilder(org.webpieces.router.impl.model.R1RouterBuilder) L1AllRouting(org.webpieces.router.impl.model.L1AllRouting) RouteModuleInfo(org.webpieces.router.impl.model.RouteModuleInfo) LogicHolder(org.webpieces.router.impl.model.LogicHolder) Plugin(org.webpieces.router.api.routing.Plugin)

Example 3 with Plugin

use of org.webpieces.router.api.routing.Plugin in project webpieces by deanhiller.

the class DeveloperMeta method getPlugins.

@Override
public List<Plugin> getPlugins() {
    List<Plugin> prodPlugins = prodMeta.getPlugins();
    List<Plugin> devPlugins = Lists.newArrayList(//This is only for the development server to expose a GUI to use http://localhost:9000/@db
    new H2DbPlugin());
    prodPlugins.addAll(devPlugins);
    return prodPlugins;
}
Also used : Plugin(org.webpieces.router.api.routing.Plugin) H2DbPlugin(org.webpieces.plugins.hsqldb.H2DbPlugin) H2DbPlugin(org.webpieces.plugins.hsqldb.H2DbPlugin)

Aggregations

Plugin (org.webpieces.router.api.routing.Plugin)3 ArrayList (java.util.ArrayList)2 Injector (com.google.inject.Injector)1 Module (com.google.inject.Module)1 H2DbPlugin (org.webpieces.plugins.hsqldb.H2DbPlugin)1 Routes (org.webpieces.router.api.routing.Routes)1 L1AllRouting (org.webpieces.router.impl.model.L1AllRouting)1 LogicHolder (org.webpieces.router.impl.model.LogicHolder)1 R1RouterBuilder (org.webpieces.router.impl.model.R1RouterBuilder)1 RouteModuleInfo (org.webpieces.router.impl.model.RouteModuleInfo)1 RouterInfo (org.webpieces.router.impl.model.RouterInfo)1