use of org.webpieces.router.impl.loader.LoadedController 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.impl.loader.LoadedController 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());
}
use of org.webpieces.router.impl.loader.LoadedController in project webpieces by deanhiller.
the class ScopedRouteBuilderImpl method addRoute.
@Override
public void addRoute(Port port, HttpMethod method, String path, String controllerMethod, RouteId routeId, boolean checkToken) {
if (!controllerMethod.contains("."))
throw new IllegalArgumentException("controllerMethod='" + controllerMethod + " does not contain a '.' which is required separating class name and method");
UrlPath p = new UrlPath(routerInfo, path);
boolean isPostOnly = method == HttpMethod.POST;
RouteModuleInfo moduleInfo = CurrentRoutes.get();
RouteInfo routeInfo = new RouteInfo(moduleInfo, controllerMethod);
// MUST DO loadControllerIntoMetat HERE so stack trace has customer's line in it so he knows EXACTLY what
// he did wrong when reading the exception!!
MethodMetaAndController metaAndController = holder.getFinder().loadHtmlController(resettingLogic.getInjector(), routeInfo, isPostOnly);
MatchInfo matchInfo = createMatchInfo(p, port, method, holder.getUrlEncoding());
LoadedController loadedController = metaAndController.getLoadedController();
FHtmlRouter router = new FHtmlRouter(holder.getRouteInvoker2(), loadedController, moduleInfo.getI18nBundleName(), matchInfo, checkToken);
SvcProxyForHtml svc = new SvcProxyForHtml(holder.getSvcProxyLogic(), futureUtil);
RouterAndInfo routerAndInfo = new RouterAndInfo(router, routeInfo, metaAndController, svc);
newDynamicRoutes.add(routerAndInfo);
resettingLogic.getReverseRoutes().addRoute(routeId, router);
log.info("scope:'" + routerInfo + "' added route=" + matchInfo + " method=" + routeInfo.getControllerMethodString());
}
use of org.webpieces.router.impl.loader.LoadedController in project webpieces by deanhiller.
the class ScopedRouteBuilderImpl method addContentRoute.
@Override
public void addContentRoute(Port port, HttpMethod method, String path, String controllerMethod, RouteId routeId) {
UrlPath p = new UrlPath(routerInfo, path);
RouteModuleInfo moduleInfo = CurrentRoutes.get();
RouteInfo routeInfo = new RouteInfo(moduleInfo, controllerMethod);
// MUST DO loadControllerIntoMeta HERE so stack trace has customer's line in it so he knows EXACTLY what
// he did wrong when reading the exception!!
BinderAndLoader container = holder.getFinder().loadContentController(resettingLogic.getInjector(), routeInfo);
MatchInfo matchInfo = createMatchInfo(p, port, method, holder.getUrlEncoding());
LoadedController loadedController = container.getMetaAndController().getLoadedController();
FContentRouter router = new FContentRouter(holder.getRouteInvoker2(), loadedController, moduleInfo, matchInfo, container.getBinder());
SvcProxyForContent svc = new SvcProxyForContent(holder.getSvcProxyLogic(), futureUtil);
RouterAndInfo routerAndInfo = new RouterAndInfo(router, routeInfo, container.getMetaAndController(), svc);
newDynamicRoutes.add(routerAndInfo);
if (// if there is a routeId, then add the reverse mapping
routeId != null)
resettingLogic.getReverseRoutes().addRoute(routeId, router);
log.info("scope:'" + routerInfo + "' added content route=" + matchInfo + " method=" + routeInfo.getControllerMethodString());
}
use of org.webpieces.router.impl.loader.LoadedController in project webpieces by deanhiller.
the class DevRouteInvoker method invokeDevelopmentErrorPage.
private XFuture<Void> invokeDevelopmentErrorPage(InvokeInfo invokeInfo, RouteInfoForInternalError data) {
RequestContext requestCtx = invokeInfo.getRequestCtx();
ProxyStreamHandle handler = invokeInfo.getHandler();
RouterRequest req = requestCtx.getRequest();
Throwable exception = data.getException();
Injector webAppInjector = webInjector.getCurrentInjector();
RouteInfo routeInfo = new RouteInfo(new RouteModuleInfo("", null), "/org/webpieces/devrouter/impl/DevelopmentController.internalError");
SvcProxyFixedRoutes svcProxy = new SvcProxyFixedRoutes(serviceInvoker, futureUtil);
LoadedController newLoadedController = controllerFinder.loadGenericController(webAppInjector, routeInfo).getLoadedController();
Endpoint newInfo = new Endpoint(svcProxy);
RouterRequest newRequest = new RouterRequest();
newRequest.putMultipart("url", req.relativePath);
newRequest.isHttps = req.isHttps;
newRequest.isBackendRequest = req.isBackendRequest;
newRequest.originalRequest = req.originalRequest;
newRequest.requestState.put(DevelopmentController.ORIGINAL_REQUEST, req);
newRequest.requestState.put(DevelopmentController.EXCEPTION, exception);
newRequest.requestState.put(DevRouteInvoker.ERROR_KEY, req.requestState.get(DevRouteInvoker.ERROR_KEY));
ApplicationContext ctx = webInjector.getAppContext();
RequestContext overridenCtx = new RequestContext(requestCtx.getValidation(), (FlashSub) requestCtx.getFlash(), requestCtx.getSession(), newRequest, ctx);
InvokeInfo newInvokeInfo = new InvokeInfo(overridenCtx, handler, RouteType.INTERNAL_SERVER_ERROR, newLoadedController, null);
RequestContext oldContext = Current.getContext();
Current.setContext(overridenCtx);
try {
return super.invokeErrorController(newInvokeInfo, newInfo, data);
} finally {
Current.setContext(oldContext);
}
}
Aggregations