use of org.webpieces.router.api.routes.MethodMeta in project webpieces by deanhiller.
the class AbstractLoader method createServiceFromFiltersImpl.
protected Service<MethodMeta, Action> createServiceFromFiltersImpl(ServiceCreationInfo meta) {
Injector injector = meta.getInjector();
List<RouteFilter<?>> filters = createFilters(injector, meta.getFilterInfos());
Service<MethodMeta, Action> svcWithFilters = loader.loadFilters(meta.getService(), filters);
return svcWithFilters;
}
use of org.webpieces.router.api.routes.MethodMeta in project webpieces by deanhiller.
the class RouteBuilderImpl method buildRouter.
public DScopedRouter buildRouter() {
if (pageNotFoundInfo == null)
throw new IllegalStateException("Client did not call setPageNotFoundRoute for router=" + routerInfo + " and that's required to catch stray not founds");
else if (internalErrorInfo == null)
throw new IllegalStateException("Client did not call setInternalErrorRoute for router=" + routerInfo + " and that's required to catch stray bugs in your application");
List<AbstractRouter> routers = super.buildRoutes(routeFilters);
// static routes get cached in browser typically so add them last so dynamic routes which are not cached are
// pattern matched first and we don't waste loop matching static routes
routers.addAll(staticRouters);
Map<String, EScopedRouter> pathToRouter = buildScopedRouters(routeFilters);
SvcProxyFixedRoutes svcProxy = new SvcProxyFixedRoutes(holder.getSvcProxyLogic().getServiceInvoker(), futureUtil);
FilterCreationMeta notFoundChain = new FilterCreationMeta(resettingLogic.getInjector(), notFoundFilters, svcProxy);
FilterCreationMeta internalErrorChain = new FilterCreationMeta(resettingLogic.getInjector(), internalErrorFilters, svcProxy);
Service<MethodMeta, Action> svc = holder.getFinder().loadFilters(internalErrorChain);
String i18nBundleName = internalErrorInfo.getRouteModuleInfo().getI18nBundleName();
EInternalErrorRouter internalErrorRouter = new EInternalErrorRouter(holder.getRouteInvoker2(), i18nBundleName, internalErrorController, svc);
Service<MethodMeta, Action> notFoundSvc = holder.getFinder().loadFilters(notFoundChain);
String notFoundBundleName = pageNotFoundInfo.getRouteModuleInfo().getI18nBundleName();
ENotFoundRouter notFoundRouter = new ENotFoundRouter(holder.getRouteInvoker2(), notFoundBundleName, notFoundControllerInst, notFoundSvc);
return new DScopedRouter(routerInfo, pathToRouter, routers, notFoundRouter, internalErrorRouter, routerFutures, futureUtil);
}
use of org.webpieces.router.api.routes.MethodMeta in project webpieces by deanhiller.
the class SharedMatchUtil method buildRoutes.
protected List<AbstractRouter> buildRoutes(List<FilterInfo<?>> routeFilters) {
List<AbstractRouter> routers = new ArrayList<>();
for (RouterAndInfo routerAndInfo : newDynamicRoutes) {
AbstractDynamicRouter router = routerAndInfo.getRouter();
MatchInfo matchInfo = router.getMatchInfo();
String path = matchInfo.getFullPath();
Port port = matchInfo.getExposedPorts();
ResolvedMethod methodMeta = routerAndInfo.getMetaAndController().getMethodMeta();
StreamService streamSvc;
if (routerAndInfo.getRouteType() == RouteType.STREAMING) {
streamSvc = new StreamProxy(holder.getFutureUtil(), holder.getServiceInvoker());
} else {
// Wire in request/response filters at this point
List<FilterInfo<?>> filters = findMatchingFilters(methodMeta, path, port, routeFilters);
FilterCreationMeta chainInfo = new FilterCreationMeta(resettingLogic.getInjector(), filters, routerAndInfo.getSvcProxy());
Service<MethodMeta, Action> service = holder.getFinder().loadFilters(chainInfo);
Processor processor;
if (routerAndInfo.getRouteType() == RouteType.CONTENT) {
processor = holder.getResponseProcessorContent();
} else if (routerAndInfo.getRouteType() == RouteType.HTML) {
processor = holder.getResponseProcessorHtml();
} else {
throw new IllegalStateException("RouteType not supported here=" + routerAndInfo.getRouteType());
}
String i18nBundleName = routerAndInfo.getRouteInfo().getRouteModuleInfo().getI18nBundleName();
Endpoint svc = new Endpoint(service);
streamSvc = new RequestResponseStream(svc, i18nBundleName, processor, holder.getBodyParsers(), holder.getServiceInvoker());
}
// Add streaming filters at this point here...
router.setDynamicInfo(streamSvc);
routers.add(router);
}
return routers;
}
use of org.webpieces.router.api.routes.MethodMeta in project webpieces by deanhiller.
the class AbstractRouteInvoker method invokeSvc.
private XFuture<Void> invokeSvc(InvokeInfo invokeInfo, Endpoint dynamicInfo, RouteData data, Processor processor) {
LoadedController loadedController = invokeInfo.getLoadedController();
ProxyStreamHandle handle = invokeInfo.getHandler();
RequestContext requestCtx = invokeInfo.getRequestCtx();
MethodMeta methodMeta = new MethodMeta(loadedController, requestCtx, invokeInfo.getRouteType(), data);
String i18nBundleName = "";
return serviceInvoker.invokeSvc(methodMeta, i18nBundleName, dynamicInfo, processor, handle);
}
use of org.webpieces.router.api.routes.MethodMeta in project webpieces by deanhiller.
the class AbstractRouteInvoker method invokeRealRoute.
protected RouterStreamRef invokeRealRoute(InvokeInfo invokeInfo, StreamService endpoint, RouteData data) {
if (endpoint == null)
throw new IllegalStateException("Bug, service should never be null at this point");
LoadedController loadedController = invokeInfo.getLoadedController();
RequestContext requestCtx = invokeInfo.getRequestCtx();
Messages messages = new Messages(invokeInfo.getI18nBundleName(), "webpieces");
requestCtx.setMessages(messages);
MethodMeta methodMeta = new MethodMeta(loadedController, requestCtx, invokeInfo.getRouteType(), data);
return endpoint.openStream(methodMeta, invokeInfo.getHandler());
}
Aggregations