001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.wicket.markup.html; 018 019import org.apache.wicket.markup.head.HeaderItem; 020import org.apache.wicket.markup.head.IHeaderResponse; 021import org.apache.wicket.request.Response; 022 023/** 024 * This is simply a helper implementation of IHeaderResponse that really delegates all of its method 025 * calls to the IHeaderResponse that is passed into the constructor. It is defined as abstract 026 * because it's only meant to be extended and not used a la carte. You can extend it and override 027 * only the methods that you want to change the functionality of. 028 * 029 * @see IHeaderResponseDecorator 030 * @see IHeaderResponse 031 * @author Jeremy Thomerson 032 */ 033public abstract class DecoratingHeaderResponse implements IHeaderResponse 034{ 035 036 private final IHeaderResponse realResponse; 037 038 /** 039 * Create a header response that simply delegates all methods to the one that is passed in here. 040 * 041 * @param real 042 * the actual response that this class delegates to by default 043 */ 044 public DecoratingHeaderResponse(IHeaderResponse real) 045 { 046 realResponse = real; 047 } 048 049 /** 050 * Returns the actual response being decorated for subclasses to be able to pass it off to other 051 * objects if they need to do so. 052 * 053 * @return the actual wrapped IHeaderResponse 054 */ 055 protected final IHeaderResponse getRealResponse() 056 { 057 return realResponse; 058 } 059 060 @Override 061 public void render(HeaderItem item) 062 { 063 realResponse.render(item); 064 } 065 066 @Override 067 public void markRendered(Object object) 068 { 069 realResponse.markRendered(object); 070 } 071 072 @Override 073 public boolean wasRendered(Object object) 074 { 075 return realResponse.wasRendered(object); 076 } 077 078 @Override 079 public Response getResponse() 080 { 081 return realResponse.getResponse(); 082 } 083 084 @Override 085 public void close() 086 { 087 realResponse.close(); 088 } 089 090 @Override 091 public boolean isClosed() 092 { 093 return realResponse.isClosed(); 094 } 095}