org.archive.crawler.settings
Class SettingsCache

java.lang.Object
  extended by org.archive.crawler.settings.SettingsCache

public class SettingsCache
extends java.lang.Object

This class keeps a map of host names to settings objects. It is implemented with soft references which implies that the elements can be garbage collected when there's no strong references to the elements. Even if there's no strong references left elements will not be garbage collected unless the memory is needed.

Author:
John Erik Halse

Constructor Summary
SettingsCache(CrawlerSettings globalSettings)
          Creates a new instance of the settings cache
 
Method Summary
 void clear()
          Clear all cached settings.
 void deleteSettingsObject(CrawlerSettings settings)
          Delete a settings object from the cache.
 CrawlerSettings getGlobalSettings()
           
 CrawlerSettings getSettings(java.lang.String host, java.lang.String refinement)
          Get the effective settings for a host.
 CrawlerSettings getSettingsObject(java.lang.String scope, java.lang.String refinement)
          Get a settings object.
 void putSettings(java.lang.String host, CrawlerSettings settings)
          Add a settings object to the cache.
 void refreshHostToSettings()
          Make sure that no host strings points to wrong settings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SettingsCache

public SettingsCache(CrawlerSettings globalSettings)
Creates a new instance of the settings cache

Method Detail

getSettings

public CrawlerSettings getSettings(java.lang.String host,
                                   java.lang.String refinement)
Get the effective settings for a host.

Parameters:
host - the host to get settings for.
Returns:
the settings or null if not in cache.

getSettingsObject

public CrawlerSettings getSettingsObject(java.lang.String scope,
                                         java.lang.String refinement)
Get a settings object.

Parameters:
scope - the scope of the settings object to get.
Returns:
the settings object or null if not in cache.

putSettings

public void putSettings(java.lang.String host,
                        CrawlerSettings settings)
Add a settings object to the cache.

Parameters:
host - the host for which the settings object is valid.
settings - the settings object.

deleteSettingsObject

public void deleteSettingsObject(CrawlerSettings settings)
Delete a settings object from the cache.

Parameters:
settings - the settings object to remove.

refreshHostToSettings

public void refreshHostToSettings()
Make sure that no host strings points to wrong settings. This method clears most of the host to settings mappings. Because of the performance penalty this should only used when really needed.


clear

public void clear()
Clear all cached settings.


getGlobalSettings

public CrawlerSettings getGlobalSettings()


Copyright © 2003-2011 Internet Archive. All Rights Reserved.