FileDocCategorySizeDatePackage
CoyoteResponseFacade.javaAPI DocGlassfish v2 API13982Fri May 04 22:32:44 BST 2007org.apache.coyote.tomcat5

CoyoteResponseFacade

public class CoyoteResponseFacade extends org.apache.catalina.connector.ResponseFacade implements HttpServletResponse
Facade class that wraps a Coyote response object. All methods are delegated to the wrapped response.
author
Remy Maucherat
author
Jean-Francois Arcand
version
$Revision: 1.9 $ $Date: 2007/05/05 05:32:43 $

Fields Summary
protected static final org.apache.catalina.util.StringManager
sm
The string manager for this package.
protected CoyoteResponse
response
The wrapped response.
Constructors Summary
public CoyoteResponseFacade(CoyoteResponse response)
Construct a wrapper for the specified response.

param
response The response to be wrapped


        super(response);
        this.response = response;

    
Methods Summary
public voidaddCookie(javax.servlet.http.Cookie cookie)


        if (isCommitted())
            return;

        response.addCookie(cookie);

    
public voidaddDateHeader(java.lang.String name, long date)


        if (isCommitted())
            return;

        response.addDateHeader(name, date);

    
public voidaddHeader(java.lang.String name, java.lang.String value)


        if (isCommitted())
            return;

        response.addHeader(name, value);

    
public voidaddIntHeader(java.lang.String name, int value)


        if (isCommitted())
            return;

        response.addIntHeader(name, value);

    
public voidclear()
Clear facade.

        response = null;
    
protected java.lang.Objectclone()
Prevent cloning the facade.



    // --------------------------------------------------------- Public Methods

    
            
      
          
        throw new CloneNotSupportedException();
    
public booleancontainsHeader(java.lang.String name)


        if (response == null) {
            throw new IllegalStateException(
                            sm.getString("responseFacade.nullResponse"));
        }

        return response.containsHeader(name);
    
public java.lang.StringencodeRedirectURL(java.lang.String url)


        if (response == null) {
            throw new IllegalStateException(
                            sm.getString("responseFacade.nullResponse"));
        }

        return response.encodeRedirectURL(url);
    
public java.lang.StringencodeRedirectUrl(java.lang.String url)


        if (response == null) {
            throw new IllegalStateException(
                            sm.getString("responseFacade.nullResponse"));
        }

        return response.encodeRedirectURL(url);
    
public java.lang.StringencodeURL(java.lang.String url)


        if (response == null) {
            throw new IllegalStateException(
                            sm.getString("responseFacade.nullResponse"));
        }

        return response.encodeURL(url);
    
public java.lang.StringencodeUrl(java.lang.String url)


        if (response == null) {
            throw new IllegalStateException(
                            sm.getString("responseFacade.nullResponse"));
        }

        return response.encodeURL(url);
    
public voidfinish()


        if (response == null) {
            throw new IllegalStateException(
                            sm.getString("responseFacade.nullResponse"));
        }

        response.setSuspended(true);

    
public voidflushBuffer()


        if (isFinished())
            //            throw new IllegalStateException
            //                (/*sm.getString("responseFacade.finished")*/);
            return;
        
        if (SecurityUtil.isPackageProtectionEnabled()){
            try{
                AccessController.doPrivileged(new PrivilegedExceptionAction(){

                    public Object run() throws IOException{
                        response.setAppCommitted(true);

                        response.flushBuffer();
                        return null;
                    }
                });
            } catch(PrivilegedActionException e){
                Exception ex = e.getException();
                if (ex instanceof IOException){
                    throw (IOException)ex;
                }
            }
        } else {
            response.setAppCommitted(true);

            response.flushBuffer();            
        }

    
public intgetBufferSize()


        if (response == null) {
            throw new IllegalStateException(
                            sm.getString("responseFacade.nullResponse"));
        }

        return response.getBufferSize();
    
public java.lang.StringgetCharacterEncoding()


        if (response == null) {
            throw new IllegalStateException(
                            sm.getString("responseFacade.nullResponse"));
        }

        return response.getCharacterEncoding();
    
public intgetContentCount()

        return response.getContentCount();
    
public java.util.LocalegetLocale()


        if (response == null) {
            throw new IllegalStateException(
                            sm.getString("responseFacade.nullResponse"));
        }

        return response.getLocale();
    
public java.lang.StringgetMessage()

        return response.getMessage();
    
public javax.servlet.ServletOutputStreamgetOutputStream()


        //        if (isFinished())
        //            throw new IllegalStateException
        //                (/*sm.getString("responseFacade.finished")*/);

        ServletOutputStream sos = response.getOutputStream();
        if (isFinished())
            response.setSuspended(true);
        return (sos);

    
public intgetStatus()

        return response.getStatus();
    
public CoyoteResponsegetUnwrappedCoyoteResponse()
Return the original CoyoteRequest object.


        // tomcat does not have any Permission types so instead of
        // creating a TomcatPermission for this, use SecurityPermission.
        if (Globals.IS_SECURITY_ENABLED) {
            Permission perm =
                new SecurityPermission("getUnwrappedCoyoteResponse");
            AccessController.checkPermission(perm);
        }

        return response;
    
public java.io.PrintWritergetWriter()


        //        if (isFinished())
        //            throw new IllegalStateException
        //                (/*sm.getString("responseFacade.finished")*/);

        PrintWriter writer = response.getWriter();
        if (isFinished())
            response.setSuspended(true);
        return (writer);

    
public booleanisCommitted()


        if (response == null) {
            throw new IllegalStateException(
                            sm.getString("responseFacade.nullResponse"));
        }

        return (response.isAppCommitted());
    
public booleanisError()

        return response.isError();
    
public booleanisFinished()


        if (response == null) {
            throw new IllegalStateException(
                            sm.getString("responseFacade.nullResponse"));
        }

        return response.isSuspended();

    
public voidreset()


        if (isCommitted())
            throw new IllegalStateException
                (/*sm.getString("responseBase.reset.ise")*/);

        response.reset();

    
public voidresetBuffer()


        if (isCommitted())
            throw new IllegalStateException
                (/*sm.getString("responseBase.reset.ise")*/);

        response.resetBuffer();

    
public voidsendError(int sc, java.lang.String msg)


        if (isCommitted())
            throw new IllegalStateException
                (/*sm.getString("responseBase.reset.ise")*/);

        response.setAppCommitted(true);

        response.sendError(sc, msg);

    
public voidsendError(int sc)


        if (isCommitted())
            throw new IllegalStateException
                (/*sm.getString("responseBase.reset.ise")*/);

        response.setAppCommitted(true);

        response.sendError(sc);

    
public voidsendRedirect(java.lang.String location)


        if (isCommitted())
            throw new IllegalStateException
                (/*sm.getString("responseBase.reset.ise")*/);

        response.setAppCommitted(true);

        response.sendRedirect(location);

    
public voidsetAppCommitted(boolean appCommitted)

        response.setAppCommitted(appCommitted);
    
public voidsetBufferSize(int size)


        if (isCommitted())
            throw new IllegalStateException
                (/*sm.getString("responseBase.reset.ise")*/);

        response.setBufferSize(size);

    
public voidsetContentLength(int len)


        if (isCommitted())
            return;

        response.setContentLength(len);

    
public voidsetContentType(java.lang.String type)


        if (isCommitted())
            return;
        
        if (SecurityUtil.isPackageProtectionEnabled()){
            AccessController.doPrivileged(new SetContentTypePrivilegedAction(type));
        } else {
            response.setContentType(type);            
        }
    
public voidsetDateHeader(java.lang.String name, long date)


        if (isCommitted())
            return;

        response.setDateHeader(name, date);

    
public voidsetHeader(java.lang.String name, java.lang.String value)


        if (isCommitted())
            return;

        response.setHeader(name, value);

    
public voidsetIntHeader(java.lang.String name, int value)


        if (isCommitted())
            return;

        response.setIntHeader(name, value);

    
public voidsetLocale(java.util.Locale loc)


        if (isCommitted())
            return;

        response.setLocale(loc);
    
public voidsetStatus(int sc)


        if (isCommitted())
            return;

        response.setStatus(sc);

    
public voidsetStatus(int sc, java.lang.String sm)


        if (isCommitted())
            return;

        response.setStatus(sc, sm);

    
public voidsetSuspended(boolean suspended)

        response.setSuspended(suspended);