Package org.jboss.seam.servlet.http

Examples of org.jboss.seam.servlet.http.HttpServletRequestContext


        fireEvent(new InternalServletResponseEvent(response), InitializedLiteral.INSTANCE);
        Path path = null;
        if (request instanceof HttpServletRequest) {
            path = new PathLiteral(HttpServletRequest.class.cast(request).getServletPath());
            fireEvent(response, InitializedLiteral.INSTANCE, path);
            fireEvent(new HttpServletRequestContext(request, response), InitializedLiteral.INSTANCE, path);
        } else {
            fireEvent(response, InitializedLiteral.INSTANCE);
            fireEvent(new ServletRequestContext(request, response), InitializedLiteral.INSTANCE);
        }

        try {
            if (!response.isCommitted()) {
                chain.doFilter(request, response);
            }
        } finally {
            if (request instanceof HttpServletRequest) {
                fireEvent(response, DestroyedLiteral.INSTANCE, path);
                fireEvent(new HttpServletRequestContext(request, response), DestroyedLiteral.INSTANCE, path);
            } else {
                fireEvent(response, DestroyedLiteral.INSTANCE);
                fireEvent(new ServletRequestContext(request, response), DestroyedLiteral.INSTANCE);
            }
            fireEvent(new InternalServletResponseEvent(response), DestroyedLiteral.INSTANCE);
View Full Code Here


    protected void requestInitialized(@Observes @Initialized final InternalServletRequestEvent e) {
        ServletRequest req = e.getServletRequest();
        log.servletRequestInitialized(req);
        if (req instanceof HttpServletRequest) {
            requestCtx.set(new HttpServletRequestContext(req));
        } else {
            requestCtx.set(new ServletRequestContext(req));
        }
    }
View Full Code Here

    protected void responseInitialized(@Observes @Initialized final InternalServletResponseEvent e) {
        ServletResponse res = e.getServletResponse();
        log.servletResponseInitialized(res);
        if (res instanceof HttpServletResponse) {
            requestCtx.set(new HttpServletRequestContext(requestCtx.get().getRequest(), res));
        } else {
            requestCtx.set(new ServletRequestContext(requestCtx.get().getRequest(), res));
        }
    }
View Full Code Here

    }

    protected void responseDestroyed(@Observes @Destroyed final InternalServletResponseEvent e) {
        log.servletResponseDestroyed(e.getServletResponse());
        if (requestCtx.get() instanceof HttpServletRequestContext) {
            requestCtx.set(new HttpServletRequestContext(requestCtx.get().getRequest()));
        } else {
            requestCtx.set(new ServletRequestContext(requestCtx.get().getRequest()));
        }
    }
View Full Code Here

    @AroundInvoke
    public Object processException(InvocationContext ctx) throws Exception {
        Method m = ctx.getMethod();
        // FIXME would be helpful if Catch provided a utility to get the CaughtException
        if (ctx.getParameters().length > 0 && ctx.getParameters()[0] instanceof CaughtException) {
            HttpServletRequestContext requestCtx = requestCtxResolver.get();
            // we can't respond w/ this exception handler if response is committed
            // TODO should see if exception is marked handled already
            if (requestCtx.getResponse().isCommitted()) {
                return Void.TYPE;
            }
            CaughtException<?> c = (CaughtException<?>) ctx.getParameters()[0];
            if (m.isAnnotationPresent(SendHttpError.class)) {
                SendHttpError r = m.getAnnotation(SendHttpError.class);
                String message = r.message().trim();
                if (r.message().length() == 0 && r.useExceptionMessageAsDefault()) {
                    message = c.getException().getMessage();
                }

                if (message != null && message.length() > 0) {
                    requestCtx.getResponse().sendError(r.status(), message);
                } else {
                    requestCtx.getResponse().sendError(r.status());
                }
            } else if (m.isAnnotationPresent(SendErrorPage.class)) {
                SendErrorPage r = m.getAnnotation(SendErrorPage.class);
                if (r.redirect()) {
                    requestCtx.getResponse().sendRedirect(requestCtx.getResponse().encodeRedirectURL(r.value()));
                } else {
                    requestCtx.getRequest().getRequestDispatcher(r.value())
                            .forward(requestCtx.getRequest(), requestCtx.getResponse());
                }
            } else {
                // perhaps log a warning?
            }
        }
View Full Code Here

TOP

Related Classes of org.jboss.seam.servlet.http.HttpServletRequestContext

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.