com.laxser.blitz.web.portal.impl.PortalResponse.java Source code

Java tutorial

Introduction

Here is the source code for com.laxser.blitz.web.portal.impl.PortalResponse.java

Source

/*
 * Copyright 2007-2009 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.laxser.blitz.web.portal.impl;

import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.laxser.blitz.web.portal.Portal;

/**
 * 
 *@author laxser  Date 2012-3-23 ?4:57:14
@contact [duqifan@gmail.com]
@PortalResponse.java
     
 */
class PortalResponse extends HttpServletResponseWrapper {

    private static final Log logger = LogFactory.getLog(PortalResponse.class);

    private Portal portal;

    public PortalResponse(Portal portal, HttpServletResponse response) {
        super(response);
        this.portal = portal;
    }

    public Portal getPortal() {
        return portal;
    }

    @Override
    public void setResponse(ServletResponse response) {
        if (logger.isDebugEnabled()) {
            logger.debug(String.format("set response: %s", response));
        }
        super.setResponse(response);
    }

    // header????
    @Override
    public void setHeader(String name, String value) {
        synchronized (portal) {
            super.setHeader(name, value);
        }
    }

    @Override
    public void addHeader(String name, String value) {
        synchronized (portal) {
            super.addHeader(name, value);
        }
    }

}