Package org.apache.wiki.util

Examples of org.apache.wiki.util.WatchDog$ThreadWrapper


    public void doFilter( ServletRequest  request,
                          ServletResponse response,
                          FilterChain     chain )
        throws ServletException, IOException
    {
        WatchDog w = m_engine.getCurrentWatchDog();
        try
        {
            NDC.push( m_engine.getApplicationName()+":"+((HttpServletRequest)request).getRequestURI() );

            w.enterState("Filtering for URL "+((HttpServletRequest)request).getRequestURI(), 90 );
            HttpServletResponseWrapper responseWrapper;
        
            if( m_useOutputStream )
            {
                log.debug( "Using ByteArrayResponseWrapper" );
                responseWrapper = new ByteArrayResponseWrapper( (HttpServletResponse)response );
            }
            else
            {
                log.debug( "Using MyServletResponseWrapper" );
                responseWrapper = new MyServletResponseWrapper( (HttpServletResponse)response );
               
            }
       
            // fire PAGE_REQUESTED event
            String pagename = DefaultURLConstructor.parsePageFromURL(
                    (HttpServletRequest)request, response.getCharacterEncoding() );
            fireEvent( WikiPageEvent.PAGE_REQUESTED, pagename );

            super.doFilter( request, responseWrapper, chain );

            // The response is now complete. Lets replace the markers now.
       
            // WikiContext is only available after doFilter! (That is after
            //   interpreting the jsp)

            try
            {
                w.enterState( "Delivering response", 30 );
                WikiContext wikiContext = getWikiContext( request );
                String r = filter( wikiContext, responseWrapper );
       
                //String encoding = "UTF-8";
                //if( wikiContext != null ) encoding = wikiContext.getEngine().getContentEncoding();
       
                // Only now write the (real) response to the client.
                // response.setContentLength(r.length());
                // response.setContentType(encoding);
               
                if (m_useOutputStream)
                {
                    OutputStreamWriter out = new OutputStreamWriter(response.getOutputStream(),
                                                                    response.getCharacterEncoding());
                    out.write(r);
                    out.flush();
                    out.close();
                }
                else
                {
                    response.getWriter().write(r);
                }
           
                // Clean up the UI messages and loggers
                if( wikiContext != null )
                {
                    wikiContext.getWikiSession().clearMessages();
                }

                // fire PAGE_DELIVERED event
                fireEvent( WikiPageEvent.PAGE_DELIVERED, pagename );

            }
            finally
            {
                w.exitState();
            }
        }
        finally
        {
            w.exitState();
            NDC.pop();
            NDC.remove();
        }
    }
View Full Code Here


    public void doFilter( ServletRequest  request,
                          ServletResponse response,
                          FilterChain     chain )
        throws ServletException, IOException
    {
        WatchDog w = m_engine.getCurrentWatchDog();
        try
        {
            NDC.push( m_engine.getApplicationName()+":"+((HttpServletRequest)request).getRequestURI() );

            w.enterState("Filtering for URL "+((HttpServletRequest)request).getRequestURI(), 90 );
            HttpServletResponseWrapper responseWrapper;
        
            if( m_useOutputStream )
            {
                log.debug( "Using ByteArrayResponseWrapper" );
                responseWrapper = new ByteArrayResponseWrapper( (HttpServletResponse)response );
            }
            else
            {
                log.debug( "Using MyServletResponseWrapper" );
                responseWrapper = new MyServletResponseWrapper( (HttpServletResponse)response );
               
            }
       
            // fire PAGE_REQUESTED event
            String pagename = DefaultURLConstructor.parsePageFromURL(
                    (HttpServletRequest)request, response.getCharacterEncoding() );
            fireEvent( WikiPageEvent.PAGE_REQUESTED, pagename );

            super.doFilter( request, responseWrapper, chain );

            // The response is now complete. Lets replace the markers now.
       
            // WikiContext is only available after doFilter! (That is after
            //   interpreting the jsp)

            try
            {
                w.enterState( "Delivering response", 30 );
                WikiContext wikiContext = getWikiContext( request );
                String r = filter( wikiContext, responseWrapper );
       
                //String encoding = "UTF-8";
                //if( wikiContext != null ) encoding = wikiContext.getEngine().getContentEncoding();
       
                // Only now write the (real) response to the client.
                // response.setContentLength(r.length());
                // response.setContentType(encoding);
               
                response.getWriter().write(r);
           
                // Clean up the UI messages and loggers
                if( wikiContext != null )
                {
                    wikiContext.getWikiSession().clearMessages();
                }

                // fire PAGE_DELIVERED event
                fireEvent( WikiPageEvent.PAGE_DELIVERED, pagename );

            }
            finally
            {
                w.exitState();
            }
        }
        finally
        {
            w.exitState();
            NDC.pop();
            NDC.remove();
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.wiki.util.WatchDog$ThreadWrapper

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.