/** * @param request The request for external context of Lasta Di. (NotNull) * @throws IllegalStateException When the external context or existing request is not found. */ public static void overrideExternalRequest(HttpServletRequest request) { if (request == null) { throw new IllegalArgumentException("The argument 'request' should not be null."); } final ExternalContext context = retrieveExternalContext(); final Object existing = context.getRequest(); if (existing == null) { throw new IllegalStateException("Not found external request in Lasta Di container for your overriding by: " + request); } context.setRequest(request); }
/** * @param request The request for external context of Lasta Di. (NotNull) * @throws IllegalStateException When the external context or existing request is not found. */ public static void overrideExternalRequest(HttpServletRequest request) { if (request == null) { throw new IllegalArgumentException("The argument 'request' should not be null."); } final ExternalContext context = retrieveExternalContext(); final Object existing = context.getRequest(); if (existing == null) { throw new IllegalStateException("Not found external request in Lasta Di container for your overriding by: " + request); } context.setRequest(request); }
protected void viaLastaDiContext(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { final LaContainer container = SingletonLaContainerFactory.getContainer(); final ExternalContext externalContext = container.getExternalContext(); if (externalContext == null) { throw new IllegalStateException("The externalContext should not be null from the container: " + container); } final Object prevoiusRequest = externalContext.getRequest(); final Object previousResponse = externalContext.getResponse(); try { externalContext.setRequest(request); externalContext.setResponse(response); viaHotdeploy(request, response, chain); // #to_action } finally { externalContext.setRequest(prevoiusRequest); externalContext.setResponse(previousResponse); } }
protected void xclearRequestMockContext() { final LaContainer container = SingletonLaContainerFactory.getContainer(); final ExternalContext externalContext = container.getExternalContext(); if (externalContext != null) { // just in case externalContext.setRequest(null); externalContext.setResponse(null); } xreleaseMockRequestInstance(); }
protected void viaLastaDiContext(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { final LaContainer container = SingletonLaContainerFactory.getContainer(); final ExternalContext externalContext = container.getExternalContext(); if (externalContext == null) { throw new IllegalStateException("The externalContext should not be null from the container: " + container); } final Object prevoiusRequest = externalContext.getRequest(); final Object previousResponse = externalContext.getResponse(); try { externalContext.setRequest(request); externalContext.setResponse(response); viaHotdeploy(request, response, chain); // #to_action } finally { externalContext.setRequest(prevoiusRequest); externalContext.setResponse(previousResponse); } }
protected void xregisterRequestMockContext(MockletServletConfig servletConfig) { // like S2ContainerFilter final LaContainer container = SingletonLaContainerFactory.getContainer(); final ExternalContext externalContext = container.getExternalContext(); final MockletHttpServletRequest request = createMockletHttpServletRequest(servletConfig.getServletContext()); final MockletHttpServletResponse response = createMockletHttpServletResponse(request); externalContext.setRequest(request); externalContext.setResponse(response); xkeepMockRequestInstance(request, response); // for web mock handling methods }