Search in sources :

Example 1 with RouteModuleInfo

use of org.webpieces.router.impl.model.RouteModuleInfo in project webpieces by deanhiller.

the class DevRoutingService method fetchNotFoundRoute.

public NotFoundInfo fetchNotFoundRoute(NotFoundException e, RouterRequest req) {
    //Production app's notFound route TBD and used in iframe later
    RouteMeta origMeta = routeLoader.fetchNotFoundRoute(req.domain);
    if (req.queryParams.containsKey("webpiecesShowPage")) {
        //This is actually a callback from the below code's iframe!!!
        if (origMeta.getControllerInstance() == null) {
            finder.loadControllerIntoMetaObject(origMeta, false);
            finder.loadFiltersIntoMeta(origMeta, origMeta.getFilters(), false);
        }
        Service<MethodMeta, Action> svc = origMeta.getService222();
        return new NotFoundInfo(origMeta, svc, req);
    }
    log.error("(Development only log message) Route not found!!! Either you(developer) typed the wrong url OR you have a bad route.  Either way,\n" + " something needs a'fixin.  req=" + req, e);
    RouteImpl r = new RouteImpl("/org/webpieces/devrouter/impl/NotFoundController.notFound", RouteType.NOT_FOUND);
    RouteModuleInfo info = new RouteModuleInfo("", null);
    RouteMeta meta = new RouteMeta(r, origMeta.getInjector(), info, config.getUrlEncoding());
    if (meta.getControllerInstance() == null) {
        finder.loadControllerIntoMetaObject(meta, false);
        meta.setService(serviceCreator.create());
    }
    String reason = "Your route was not found in routes table";
    if (e != null)
        reason = e.getMessage();
    RouterRequest newRequest = new RouterRequest();
    newRequest.putMultipart("webpiecesError", "Exception message=" + reason);
    newRequest.putMultipart("url", req.relativePath);
    return new NotFoundInfo(meta, meta.getService222(), newRequest);
}
Also used : MethodMeta(org.webpieces.router.api.dto.MethodMeta) NotFoundInfo(org.webpieces.router.impl.NotFoundInfo) Action(org.webpieces.router.api.actions.Action) RouteImpl(org.webpieces.router.impl.RouteImpl) RouteMeta(org.webpieces.router.impl.RouteMeta) RouteModuleInfo(org.webpieces.router.impl.model.RouteModuleInfo) RouterRequest(org.webpieces.ctx.api.RouterRequest)

Example 2 with RouteModuleInfo

use of org.webpieces.router.impl.model.RouteModuleInfo 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 RouteModuleInfo

use of org.webpieces.router.impl.model.RouteModuleInfo in project webpieces by deanhiller.

the class ScopedDomainRoutes method configure.

@Override
protected void configure() {
    this.router = router.getDomainScopedRouter(domain);
    for (Routes module : modules) {
        AbstractRouteBuilder.currentPackage.set(new RouteModuleInfo(module));
        module.configure(router);
        AbstractRouteBuilder.currentPackage.set(null);
    }
}
Also used : RouteModuleInfo(org.webpieces.router.impl.model.RouteModuleInfo)

Aggregations

RouteModuleInfo (org.webpieces.router.impl.model.RouteModuleInfo)3 ArrayList (java.util.ArrayList)1 RouterRequest (org.webpieces.ctx.api.RouterRequest)1 Action (org.webpieces.router.api.actions.Action)1 MethodMeta (org.webpieces.router.api.dto.MethodMeta)1 Plugin (org.webpieces.router.api.routing.Plugin)1 Routes (org.webpieces.router.api.routing.Routes)1 NotFoundInfo (org.webpieces.router.impl.NotFoundInfo)1 RouteImpl (org.webpieces.router.impl.RouteImpl)1 RouteMeta (org.webpieces.router.impl.RouteMeta)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 RouterInfo (org.webpieces.router.impl.model.RouterInfo)1