/** * @see org.lastaflute.di.core.ComponentDef#getComponent() */ public Object getComponent() { return getContainer().getRoot().getExternalContext().getResponse(); } }
/** * @return The optional response of servlet. (NotNull, EmptyAllowed: when out of scope for external context) */ public static OptionalThing<HttpServletResponse> getOptionalResponse() { final HttpServletResponse response; if (ContainerUtil.hasExternalContext()) { final ExternalContext externalContext = ContainerUtil.retrieveExternalContext(); // not null response = (HttpServletResponse) externalContext.getResponse(); // null allowed, request not found } else { response = null; // external context not found } return toRequestOptional(response); }
/** * @see org.lastaflute.di.core.ComponentDef#getComponent() */ public Object getComponent() { return getContainer().getRoot().getExternalContext().getResponse(); } }
/** * @return The optional response of servlet. (NotNull, EmptyAllowed: when out of scope for external context) */ public static OptionalThing<HttpServletResponse> getOptionalResponse() { final HttpServletResponse response; if (ContainerUtil.hasExternalContext()) { final ExternalContext externalContext = ContainerUtil.retrieveExternalContext(); // not null response = (HttpServletResponse) externalContext.getResponse(); // null allowed, request not found } else { response = null; // external context not found } return toRequestOptional(response); }
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 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); } }