diff options
author | Thomas <> | 2022-01-09 15:01:28 +0100 |
---|---|---|
committer | Thomas <> | 2022-01-09 15:01:28 +0100 |
commit | e3639ef805f1e525415c43cbda80ed71cc43a70c (patch) | |
tree | 2b215fd820f510d71652c0ac4a7c3015bd579ce7 /eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/gui/interceptor/AsynchSpringMvcGuiBuilderIntercepter.java | |
parent | 6fcfe3946fb8c252f9b7a4961720dd851f720f9a (diff) | |
download | EAAF-Components-e3639ef805f1e525415c43cbda80ed71cc43a70c.tar.gz EAAF-Components-e3639ef805f1e525415c43cbda80ed71cc43a70c.tar.bz2 EAAF-Components-e3639ef805f1e525415c43cbda80ed71cc43a70c.zip |
feature(core): add synch. and asynch. GUI builder implementation that use Spring MVC architecture
Diffstat (limited to 'eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/gui/interceptor/AsynchSpringMvcGuiBuilderIntercepter.java')
-rw-r--r-- | eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/gui/interceptor/AsynchSpringMvcGuiBuilderIntercepter.java | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/gui/interceptor/AsynchSpringMvcGuiBuilderIntercepter.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/gui/interceptor/AsynchSpringMvcGuiBuilderIntercepter.java new file mode 100644 index 00000000..708e3b84 --- /dev/null +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/gui/interceptor/AsynchSpringMvcGuiBuilderIntercepter.java @@ -0,0 +1,63 @@ +package at.gv.egiz.eaaf.core.impl.gui.interceptor; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.LocaleResolver; +import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.servlet.ViewResolver; + +import at.gv.egiz.eaaf.core.exceptions.GuiBuildException; +import at.gv.egiz.eaaf.core.impl.gui.utils.MvcGuiRenderUtils; +import lombok.extern.slf4j.Slf4j; + +/** + * Intercepter to render GUI in response processing. + * + * @author tlenz + * + */ +@Slf4j +public class AsynchSpringMvcGuiBuilderIntercepter implements HandlerInterceptor { + + private @Autowired(required = false) ViewResolver[] viewResolvers; + private @Autowired(required = false) LocaleResolver localeResolver; + + /* + * (non-Javadoc) + * + * @see + * org.springframework.web.servlet.HandlerInterceptor#postHandle(javax.servlet. + * http. HttpServletRequest, javax.servlet.http.HttpServletResponse, + * java.lang.Object, org.springframework.web.servlet.ModelAndView) + */ + @Override + public void postHandle(final HttpServletRequest httpReq, final HttpServletResponse httpResp, + final Object handler, final ModelAndView modelAndView) throws Exception { + + final ModelAndView model = MvcGuiRenderUtils.getMvcForAsynchRendering(httpReq); + if (model != null) { + log.debug("Find GUI model: {} Starting model rendering ... ", model.getViewName()); + renderGui(model, httpReq, httpResp); + + } else { + log.trace("No GUI model skipping asynch model rendering"); + + } + + } + + private void renderGui(final ModelAndView mav, + final HttpServletRequest httpReq, final HttpServletResponse httpResp) throws GuiBuildException { + try { + MvcGuiRenderUtils.render(mav, httpReq, httpResp, viewResolvers, localeResolver); + + } catch (final Exception e) { + log.info("Can NOT generate GUI for illustration", e); + throw new GuiBuildException(e.getMessage(), e); + + } + } +} |