Examples of IRequestCycle


Examples of org.apache.tapestry.IRequestCycle

    }

    public void testGetAbsoluteURLWithOverrides() throws Exception
    {
        WebRequest request = newRequest();
        IRequestCycle rc = newCycle();

        EngineServiceLink l = new EngineServiceLink(rc, "/ctx/app", ENCODING, _urlCodec, request,
                buildParameters("myservice", null), false);

        replayControls();
View Full Code Here

Examples of org.apache.tapestry.IRequestCycle

    }

    public void testGetURLNotAbsolute()
    {
        WebRequest request = newRequest();
        IRequestCycle rc = newCycle();

        trainGetScheme(request, "http");
        trainGetServerName(request, "myserver.net");
        trainGetServerPort(request, 80);
View Full Code Here

Examples of org.apache.tapestry.IRequestCycle

    }

    public void testGetURLAbsolute()
    {
        WebRequest request = newRequest();
        IRequestCycle rc = newCycle();

        trainGetScheme(request, "http");

        replayControls();
View Full Code Here

Examples of org.apache.tapestry.IRequestCycle

        return resolver;
    }

    public void testIsRenderRequest() throws Exception
    {
        IRequestCycle cycle = newCycle();
        PortletRequestGlobals globals = newRequestGlobals(true);
        PortletRenderer renderer = newPortletRenderer();
        PortletPageResolver resolver = newResolver(cycle, "ZePage");

        renderer.renderPage(cycle, "ZePage");
View Full Code Here

Examples of org.apache.tapestry.IRequestCycle

        verifyControls();
    }

    public void testIsActionRequest() throws Exception
    {
        IRequestCycle cycle = newCycle();
        PortletRequestGlobals globals = newRequestGlobals(false);
        ResponseRenderer renderer = newResponseRenderer();
        PortletPageResolver resolver = newResolver(cycle, "ZePage");

        cycle.activate("ZePage");
        renderer.renderResponse(cycle);

        replayControls();

        PortletHomeService phs = new PortletHomeService();
View Full Code Here

Examples of org.apache.tapestry.IRequestCycle

    }

    public void testNormal() throws Exception
    {
        MockControl cyclec = newControl(IRequestCycle.class);
        IRequestCycle cycle = (IRequestCycle) cyclec.getMock();

        MockControl requestc = newControl(PortletRequest.class);
        PortletRequest request = (PortletRequest) requestc.getMock();

        PortletRenderer renderer = (PortletRenderer) newMock(PortletRenderer.class);
View Full Code Here

Examples of org.apache.tapestry.IRequestCycle

    }

    public void testPortletModeChanged() throws Exception
    {
        MockControl cyclec = newControl(IRequestCycle.class);
        IRequestCycle cycle = (IRequestCycle) cyclec.getMock();

        MockControl requestc = newControl(PortletRequest.class);
        PortletRequest request = (PortletRequest) requestc.getMock();

        PortletRenderer renderer = (PortletRenderer) newMock(PortletRenderer.class);
View Full Code Here

Examples of org.apache.tapestry.IRequestCycle

    }

    public void testWindowStateChanged() throws Exception
    {
        MockControl cyclec = newControl(IRequestCycle.class);
        IRequestCycle cycle = (IRequestCycle) cyclec.getMock();

        MockControl requestc = newControl(PortletRequest.class);
        PortletRequest request = (PortletRequest) requestc.getMock();

        PortletRenderer renderer = (PortletRenderer) newMock(PortletRenderer.class);
View Full Code Here

Examples of org.apache.tapestry.IRequestCycle

     **/

    public boolean service(RequestContext context) throws ServletException, IOException
    {
        ApplicationServlet servlet = context.getServlet();
        IRequestCycle cycle = null;
        ResponseOutputStream output = null;
        IMonitor monitor = null;

        if (LOG.isDebugEnabled())
            LOG.debug("Begin service " + context.getRequestURI());

        if (_specification == null)
            _specification = servlet.getApplicationSpecification();

        // The servlet invokes setLocale() before invoking service().  We want
        // to ignore that setLocale() ... that is, not force a cookie to be
        // written.

        _localeChanged = false;

        if (_resolver == null)
            _resolver = servlet.getResourceResolver();

        try
        {
            setupForRequest(context);

            monitor = getMonitor(context);

            output = new ResponseOutputStream(context.getResponse());
        }
        catch (Exception ex)
        {
            reportException(Tapestry.getMessage("AbstractEngine.unable-to-begin-request"), ex);

            throw new ServletException(ex.getMessage(), ex);
        }

        IEngineService service = null;

        try
        {
            try
            {
                String serviceName;

                try
                {
                    serviceName = extractServiceName(context);

                    if (Tapestry.isBlank(serviceName))
                        serviceName = Tapestry.HOME_SERVICE;

                    // Must have a service to create the request cycle.
                    // Must have a request cycle to report an exception.

                    service = getService(serviceName);
                }
                catch (Exception ex)
                {
                    service = getService(Tapestry.HOME_SERVICE);
                    cycle = createRequestCycle(context, service, monitor);

                    throw ex;
                }

                cycle = createRequestCycle(context, service, monitor);

                monitor.serviceBegin(serviceName, context.getRequestURI());

                // Invoke the service, which returns true if it may have changed
                // the state of the engine (most do return true).

                service.service(this, cycle, output);

                // Return true only if the engine is actually dirty.  This cuts down
                // on the number of times the engine is stored into the
                // session unceccesarily.

                return _dirty;
            }
            catch (PageRedirectException ex)
            {
                handlePageRedirectException(ex, cycle, output);
            }
            catch (RedirectException ex)
            {
                handleRedirectException(cycle, ex);
            }
            catch (StaleLinkException ex)
            {
                handleStaleLinkException(ex, cycle, output);
            }
            catch (StaleSessionException ex)
            {
                handleStaleSessionException(ex, cycle, output);
            }
        }
        catch (Exception ex)
        {
            monitor.serviceException(ex);

            // Discard any output (if possible).  If output has already been sent to
            // the client, then things get dicey.  Note that this block
            // gets activated if the StaleLink or StaleSession pages throws
            // any kind of exception.

            // Attempt to switch to the exception page.  However, this may itself fail
            // for a number of reasons, in which case a ServletException is thrown.

            output.reset();

            if (LOG.isDebugEnabled())
                LOG.debug("Uncaught exception", ex);

            activateExceptionPage(cycle, output, ex);
        }
        finally
        {
            if (service != null)
                monitor.serviceEnd(service.getName());

            try
            {
                cycle.cleanup();

                // Closing the buffered output closes the underlying stream as well.

                if (output != null)
                    output.forceFlush();
View Full Code Here

Examples of org.apache.tapestry.IRequestCycle

     * Delegate method for the servlet. Services the request.
     */

    public void service(WebRequest request, WebResponse response) throws IOException
    {
        IRequestCycle cycle = null;
        IEngineService service = null;

        if (_infrastructure == null)
            _infrastructure = (Infrastructure) request.getAttribute(Constants.INFRASTRUCTURE_KEY);

        // Create the request cycle; if this fails, there's not much that can be done ... everything
        // else in Tapestry relies on the RequestCycle.

        try
        {
            cycle = _infrastructure.getRequestCycleFactory().newRequestCycle(this);
        }
        catch (RuntimeException ex)
        {
            throw ex;
        }
        catch (Exception ex)
        {
            throw new IOException(ex.getMessage());
        }

        try
        {
            try
            {
                service = cycle.getService();
                // Let the service handle the rest of the request.
               
                service.service(cycle);
               
                return;
            }
            catch (PageRedirectException ex)
            {
                handlePageRedirectException(cycle, ex);
            }
            catch (RedirectException ex)
            {
                handleRedirectException(cycle, ex);
            }
            catch (StaleLinkException ex)
            {
                handleStaleLinkException(cycle, ex);
            }
            catch (StaleSessionException ex)
            {
                handleStaleSessionException(cycle, ex);
            }
        }
        catch (Exception ex)
        {
            // Attempt to switch to the exception page. However, this may itself
            // fail for a number of reasons, in which case an ApplicationRuntimeException is
            // thrown.

            if (LOG.isDebugEnabled())
                LOG.debug("Uncaught exception", ex);

            activateExceptionPage(cycle, ex);
        }
        finally
        {
            try
            {
                cycle.cleanup();
                _infrastructure.getApplicationStateManager().flush();
            }
            catch (Exception ex)
            {
                reportException(EngineMessages.exceptionDuringCleanup(ex), ex);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.