Package com.astamuse.asta4d.web

Examples of com.astamuse.asta4d.web.WebApplicationContext


        Map<String, Object> flashScopeData = rd.getFlashScopeData();
        if (url == null) {
            addFlashScopeData(flashScopeData);
        } else {
            Map<String, Object> dataMap = new HashMap<String, Object>();
            WebApplicationContext context = Context.getCurrentThreadContext();
            List<Map<String, Object>> dataList = context.getData(FlashScopeDataListKey);
            if (dataList != null) {
                for (Map<String, Object> map : dataList) {
                    dataMap.putAll(map);
                }
            }
            if (flashScopeData != null) {
                dataMap.putAll(flashScopeData);
            }
            if (url.startsWith("/")) {
                url = context.getRequest().getContextPath() + url;
            }
            url = RedirectUtil.setFlashScopeData(url, dataMap);
            response.sendRedirect(url);
        }
    }
View Full Code Here


        if (logger.isDebugEnabled()) {
            logger.debug("apply rule at :" + result.getRule());
        }

        WebApplicationContext context = (WebApplicationContext) Context.getCurrentThreadContext();
        writePathVarToContext(context, result.getPathVarMap());

        UrlMappingRule rule = result.getRule();
        context.setData(KEY_CURRENT_RULE, rule);
        writePathVarToContext(context, rule.getExtraVarMap());
        retrieveFlashScopeData(request);

        List<ContentProvider<?>> requestResult = handleRequest(rule);
        ContentWriter cw;
View Full Code Here

     * @return ContentProvider
     * @throws Exception
     */
    private List<ContentProvider<?>> handleRequest(UrlMappingRule currentRule) throws Exception {
        // TODO should we handle the exceptions?
        WebApplicationContext context = (WebApplicationContext) Context.getCurrentThreadContext();
        RequestHandlerInvokerFactory factory = ((WebApplicationConfiguration) context.getConfiguration()).getRequestHandlerInvokerFactory();
        RequestHandlerInvoker invoker = factory.getInvoker();

        Object requestHandlerResult;
        try {
            requestHandlerResult = invoker.invoke(currentRule);
        } catch (InvocationTargetException ex) {
            logger.error(currentRule.toString(), ex);
            requestHandlerResult = ex.getTargetException();
        } catch (Exception ex) {
            logger.error(currentRule.toString(), ex);
            requestHandlerResult = ex;
        }

        context.setData(KEY_REQUEST_HANDLER_RESULT, requestHandlerResult);

        List<ContentProvider<?>> cpList = new ArrayList<>();

        if (requestHandlerResult instanceof List) {
            List<?> resultList = (List<?>) requestHandlerResult;
View Full Code Here

    public static void addFlashScopeData(Map<String, Object> flashScopeData) {
        if (flashScopeData == null || flashScopeData.isEmpty()) {
            return;
        }
        WebApplicationContext context = Context.getCurrentThreadContext();
        List<Map<String, Object>> dataList = context.getData(FlashScopeDataListKey);
        if (dataList == null) {
            dataList = new LinkedList<>();
            context.setData(FlashScopeDataListKey, dataList);
        }
        dataList.add(flashScopeData);
    }
View Full Code Here

        WebApplicationConfiguration.setConfiguration(asta4dConf);
    }

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        WebApplicationContext asta4dContext = WebApplicationContext.getCurrentThreadContext();
        if (asta4dContext == null) {
            asta4dContext = new WebApplicationContext();
            Context.setCurrentThreadContext(asta4dContext);
        }
        asta4dContext.init();
        asta4dContext.setRequest(request);
        asta4dContext.setResponse(response);
        asta4dContext.setServletContext(servletContext);
        return true;
    }
View Full Code Here

TOP

Related Classes of com.astamuse.asta4d.web.WebApplicationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.