gt: 			if (cached != null) {
context: // ========================================================================
  // $Id: ResourceCache.java,v 1.13 2006/04/04 22:28:02 gregwilkins Exp $
  // Copyright 2000-2004 Mort Bay Consulting Pty. Ltd.
  // ------------------------------------------------------------------------
  // 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 org.browsermob.proxy.jetty.http;
  
  import org.apache.commons.logging.Log;
  import org.browsermob.proxy.jetty.log.LogFactory;
  import org.browsermob.proxy.jetty.util.*;
  
  import java.io.IOException;
  import java.io.Serializable;
  import java.util.*;
  
  // TODO: Auto-generated Javadoc
  /* ------------------------------------------------------------ */
  /**
   * The Class ResourceCache.
   * 
   * @version $Id: ResourceCache.java,v 1.13 2006/04/04 22:28:02 gregwilkins Exp $
   * @author Greg Wilkins
   */
  public class ResourceCache implements LifeCycle, Serializable {
  
  	/** The log. */
  	private static Log log = LogFactory.getLog(ResourceCache.class);
  
  	/* ------------------------------------------------------------ */
  	/* ------------------------------------------------------------ */
  	/** The Constant __dftMimeMap. */
  	private final static Map __dftMimeMap = new HashMap();
  
  	/** The Constant __encodings. */
  	private final static Map __encodings = new HashMap();
  	static {
  		ResourceBundle mime = ResourceBundle
  				.getBundle("org/browsermob/proxy/jetty/http/mime");
  		Enumeration i = mime.getKeys();
  		while (i.hasMoreElements()) {
  			String ext = (String) i.nextElement();
  			__dftMimeMap.put(StringUtil.asciiToLowerCase(ext),
  					mime.getString(ext));
  		}
  		ResourceBundle encoding = ResourceBundle
  				.getBundle("org/browsermob/proxy/jetty/http/encoding");
  		i = encoding.getKeys();
  		while (i.hasMoreElements()) {
  			String type = (String) i.nextElement();
  			__encodings.put(type, encoding.getString(type));
  		}
  	}
  
  	/* ------------------------------------------------------------ */
  	/* ------------------------------------------------------------ */
  	// TODO - handle this
  	// These attributes are serialized by WebApplicationContext, which needs
  	// to be updated if you add to these
  
  	/** The _max cached file size. */
  	private int _maxCachedFileSize = 1 * 1024;
  
  	/** The _max cache size. */
  	private int _maxCacheSize = 1 * 1024;
  
  	/* ------------------------------------------------------------ */
  	/** The _resource base. */
  	private Resource _resourceBase;
  
  	/** The _mime map. */
  	private Map _mimeMap;
  
  	/** The _encoding map. */
  	private Map _encodingMap;
  
  	/* ------------------------------------------------------------ */
  	/** The _started. */
  	private transient boolean _started;
  
  	/** The _cache. */
  	protected transient Map _cache;
  
  	/** The _cache size. */
  	protected transient int _cacheSize;
  
  	/** The _most recently used. */
  	protected transient CachedMetaData _mostRecentlyUsed;
  
  	/** The _least recently used. */
  	protected transient CachedMetaData _leastRecentlyUsed;
  
  	/* ------------------------------------------------------------ */
  	/**
  	 * Constructor.
  	 */
  	public ResourceCache() {
  		_cache = new HashMap();
  	}
  
  	/* ------------------------------------------------------------ */
  	/**
  	 * Read object.
  	 * 
  	 * @param in
  	 *            the in
  	 * @throws IOException
  	 *             Signals that an I/O exception has occurred.
  	 * @throws ClassNotFoundException
  	 *             the class not found exception
  	 */
  	private void readObject(java.io.ObjectInputStream in) throws IOException,
  			ClassNotFoundException {
  		in.defaultReadObject();
  		_cache = new HashMap();
  	}
  
  	/* ------------------------------------------------------------ */
  	/**
  	 * Set the Resource Base. The base resource is the Resource to use as a
  	 * relative base for all context resources. The ResourceBase attribute is a
  	 * string version of the baseResource. If a relative file is passed, it is
  	 * converted to a file URL based on the current working directory.
  	 * 
  	 * @return The file or URL to use as the base for all resources within the
  	 *         context.
  	 */
  	public String getResourceBase() {
  		if (_resourceBase == null)
  			return null;
  		return _resourceBase.toString();
  	}
  
  	/* ------------------------------------------------------------ */
  	/**
  	 * Set the Resource Base. The base resource is the Resource to use as a
  	 * relative base for all context resources. The ResourceBase attribute is a
  	 * string version of the baseResource. If a relative file is passed, it is
  	 * converted to a file URL based on the current working directory.
  	 * 
  	 * @param resourceBase
  	 *            A URL prefix or directory name.
  	 */
  	public void setResourceBase(String resourceBase) {
  		try {
  			_resourceBase = Resource.newResource(resourceBase);
  			if (log.isDebugEnabled())
  				log.debug("resourceBase=" + _resourceBase + " for " + this);
  		} catch (IOException e) {
  			log.debug(LogSupport.EXCEPTION, e);
  			throw new IllegalArgumentException(resourceBase + ":"
  					+ e.toString());
  		}
  	}
  
  	/* ------------------------------------------------------------ */
  	/**
  	 * Get the base resource. The base resource is the Resource to use as a
  	 * relative base for all context resources. The ResourceBase attribute is a
  	 * string version of the baseResource.
  	 * 
  	 * @return The resourceBase as a Resource instance
  	 */
  	public Resource getBaseResource() {
  		return _resourceBase;
  	}
  
  	/* ------------------------------------------------------------ */
  	/**
  	 * Set the base resource. The base resource is the Resource to use as a
  	 * relative base for all context resources. The ResourceBase attribute is a
  	 * string version of the baseResource.
  	 * 
  	 * @param base
  	 *            The resourceBase as a Resource instance
  	 */
  	public void setBaseResource(Resource base) {
  		_resourceBase = base;
  	}
  
  	/* ------------------------------------------------------------ */
  	/**
  	 * Gets the max cached file size.
  	 * 
  	 * @return the max cached file size
  	 */
  	public int getMaxCachedFileSize() {
  		return _maxCachedFileSize;
  	}
  
  	/* ------------------------------------------------------------ */
  	/**
  	 * Sets the max cached file size.
  	 * 
  	 * @param maxCachedFileSize
  	 *            the new max cached file size
  	 */
  	public void setMaxCachedFileSize(int maxCachedFileSize) {
  		_maxCachedFileSize = maxCachedFileSize;
  		_cache.clear();
  	}
  
  	/* ------------------------------------------------------------ */
  	/**
  	 * Gets the max cache size.
  	 * 
  	 * @return the max cache size
  	 */
  	public int getMaxCacheSize() {
  		return _maxCacheSize;
  	}
  
  	/* ------------------------------------------------------------ */
  	/**
  	 * Sets the max cache size.
  	 * 
  	 * @param maxCacheSize
  	 *            the new max cache size
  	 */
  	public void setMaxCacheSize(int maxCacheSize) {
  		_maxCacheSize = maxCacheSize;
  		_cache.clear();
  	}
  
  	/* ------------------------------------------------------------ */
  	/**
  	 * Flush cache.
  	 */
  	public void flushCache() {
  		_cache.clear();
  		System.gc();
  	}
  
  	/* ------------------------------------------------------------ */
  	/**
  	 * Get a resource from the context. Cached Resources are returned if the
  	 * resource fits within the LRU cache. Directories may have CachedResources
  	 * returned, but the caller must use the CachedResource.setCachedData method
  	 * to set the formatted directory content.
  	 * 
  	 * @param pathInContext
  	 *            the path in context
  	 * @return Resource
  	 * @throws IOException
  	 *             Signals that an I/O exception has occurred.
  	 */
  	public Resource getResource(String pathInContext) throws IOException {
  		if (log.isTraceEnabled())
  			log.trace("getResource " + pathInContext);
  		if (_resourceBase == null)
  			return null;
  
  		Resource resource = null;
  
  		// Cache operations
  		synchronized (_cache) {
  			// Look for it in the cache
  			CachedResource cached = (CachedResource) _cache.get(pathInContext);
  