From: <bra...@us...> - 2007-07-25 00:27:48
|
Revision: 1866 http://archive-access.svn.sourceforge.net/archive-access/?rev=1866&view=rev Author: bradtofel Date: 2007-07-24 17:27:51 -0700 (Tue, 24 Jul 2007) Log Message: ----------- REFACTOR: removed all references to PropertyConfigurable interface Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/liveweb/LiveWebCache.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/liveweb/LiveWebLocalResourceIndex.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/liveweb/URLCacher.java Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/liveweb/LiveWebCache.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/liveweb/LiveWebCache.java 2007-07-25 00:26:37 UTC (rev 1865) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/liveweb/LiveWebCache.java 2007-07-25 00:27:51 UTC (rev 1866) @@ -28,13 +28,11 @@ import java.net.URL; import java.text.ParseException; import java.util.Date; -import java.util.Properties; import java.util.logging.Logger; import org.apache.commons.httpclient.URIException; import org.archive.io.arc.ARCLocation; import org.archive.io.arc.ARCRecord; -import org.archive.wayback.PropertyConfigurable; import org.archive.wayback.WaybackConstants; import org.archive.wayback.core.CaptureSearchResults; import org.archive.wayback.core.Resource; @@ -42,7 +40,6 @@ import org.archive.wayback.core.SearchResults; import org.archive.wayback.core.Timestamp; import org.archive.wayback.core.WaybackRequest; -import org.archive.wayback.exception.ConfigurationException; import org.archive.wayback.exception.LiveDocumentNotAvailableException; import org.archive.wayback.exception.ResourceNotInArchiveException; import org.archive.wayback.exception.WaybackException; @@ -55,7 +52,7 @@ * @author brad * @version $Date$, $Revision$ */ -public class LiveWebCache implements PropertyConfigurable { +public class LiveWebCache { private static final Logger LOGGER = Logger.getLogger( LiveWebCache.class.getName()); @@ -65,18 +62,6 @@ private LiveWebLocalResourceIndex index = null; static UrlCanonicalizer canonicalizer = new UrlCanonicalizer(); - /* (non-Javadoc) - * @see org.archive.wayback.PropertyConfigurable#init(java.util.Properties) - */ - public void init(Properties p) throws ConfigurationException { - index = new LiveWebLocalResourceIndex(); - index.init(p); - cacher = new URLCacher(); - cacher.init(p); - arcCacheDir = new ARCCacheDirectory(); - arcCacheDir.init(p); - } - /** * closes all resources (currently unused...) */ @@ -291,4 +276,60 @@ } return resource; } + + /** + * @return the maxFailedCacheMS + */ + public long getMaxFailedCacheMS() { + return maxFailedCacheMS; + } + + /** + * @param maxFailedCacheMS the maxFailedCacheMS to set + */ + public void setMaxFailedCacheMS(long maxFailedCacheMS) { + this.maxFailedCacheMS = maxFailedCacheMS; + } + + /** + * @return the arcCacheDir + */ + public ARCCacheDirectory getArcCacheDir() { + return arcCacheDir; + } + + /** + * @param arcCacheDir the arcCacheDir to set + */ + public void setArcCacheDir(ARCCacheDirectory arcCacheDir) { + this.arcCacheDir = arcCacheDir; + } + + /** + * @return the cacher + */ + public URLCacher getCacher() { + return cacher; + } + + /** + * @param cacher the cacher to set + */ + public void setCacher(URLCacher cacher) { + this.cacher = cacher; + } + + /** + * @return the index + */ + public LiveWebLocalResourceIndex getIndex() { + return index; + } + + /** + * @param index the index to set + */ + public void setIndex(LiveWebLocalResourceIndex index) { + this.index = index; + } } Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/liveweb/LiveWebLocalResourceIndex.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/liveweb/LiveWebLocalResourceIndex.java 2007-07-25 00:26:37 UTC (rev 1865) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/liveweb/LiveWebLocalResourceIndex.java 2007-07-25 00:27:51 UTC (rev 1866) @@ -25,12 +25,9 @@ package org.archive.wayback.liveweb; import java.util.ArrayList; -import java.util.Properties; import org.archive.wayback.core.SearchResult; -import org.archive.wayback.exception.ConfigurationException; import org.archive.wayback.resourceindex.LocalResourceIndex; -import org.archive.wayback.resourceindex.SearchResultSourceFactory; import org.archive.wayback.resourceindex.bdb.BDBIndex; import org.archive.wayback.resourceindex.indexer.SearchResultToBDBRecordAdapter; import org.archive.wayback.util.AdaptedIterator; @@ -43,45 +40,12 @@ * @version $Date$, $Revision$ */ public class LiveWebLocalResourceIndex extends LocalResourceIndex { - private final static String LW_DB_DIR = "liveweb.dbdir"; - private final static String LW_DB_NAME = "liveweb.dbname"; - - private String getProp(Properties p, String key) - throws ConfigurationException { - - if(p.containsKey(key)) { - String v = p.getProperty(key); - if(v == null || v.length() < 1) { - throw new ConfigurationException("Empty configuration " + key); - } - return v; - } else { - throw new ConfigurationException("Missing configuration " + key); - } - - } - public void init(Properties p) throws ConfigurationException { - // use alternate Properties, to differentiate config from normal - // ResourceIndex - Properties newP = new Properties(); - - newP.setProperty(SearchResultSourceFactory.SOURCE_CLASS, - SearchResultSourceFactory.SOURCE_CLASS_BDB); - - newP.setProperty(SearchResultSourceFactory.INDEX_PATH, - getProp(p,LW_DB_DIR)); - - newP.setProperty(SearchResultSourceFactory.DB_NAME, - getProp(p,LW_DB_NAME)); - - super.init(newP); - } - /** * Add a single SearchResult to the index. * @param result */ + @SuppressWarnings("unchecked") public void addSearchResult(SearchResult result) { ArrayList<SearchResult> l = new ArrayList<SearchResult>(); l.add(result); Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/liveweb/URLCacher.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/liveweb/URLCacher.java 2007-07-25 00:26:37 UTC (rev 1865) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/liveweb/URLCacher.java 2007-07-25 00:27:51 UTC (rev 1866) @@ -52,9 +52,6 @@ import org.archive.io.arc.ARCLocation; import org.archive.io.arc.ARCWriter; import org.archive.net.LaxURI; -import org.archive.wayback.PropertyConfigurable; -import org.archive.wayback.core.PropertyConfiguration; -import org.archive.wayback.exception.ConfigurationException; import org.archive.wayback.exception.LiveDocumentNotAvailableException; /** @@ -67,13 +64,14 @@ * @author brad * @version $Date$, $Revision$ */ -public class URLCacher implements PropertyConfigurable { +public class URLCacher { private static final Logger LOGGER = Logger.getLogger( URLCacher.class.getName()); private static final String CACHE_PATH = "liveweb.tmp.dir"; protected File tmpDir = null; + @SuppressWarnings("unchecked") private final ThreadLocal tl = new ThreadLocal() { protected synchronized Object initialValue() { HttpClient http = new HttpClient(); @@ -88,16 +86,6 @@ return (HttpClient) tl.get(); } - /* (non-Javadoc) - * @see org.archive.wayback.PropertyConfigurable#init(java.util.Properties) - */ - public void init(Properties p) throws ConfigurationException { - PropertyConfiguration pc = new PropertyConfiguration(p); - tmpDir = pc.getDir(CACHE_PATH,true); - LOGGER.info("URLCacher storing temp files in " + - tmpDir.getAbsolutePath()); - } - private File getTmpFile() { String tmpName; File tmpFile; @@ -241,13 +229,13 @@ URLCacher uc = new URLCacher(); ARCCacheDirectory cache = new ARCCacheDirectory(); - try { - cache.init(p); - uc.init(p); - } catch (ConfigurationException e) { - e.printStackTrace(); - System.exit(1); - } +// try { +//// cache.init(p); +//// uc.init(p); +// } catch (ConfigurationException e) { +// e.printStackTrace(); +// System.exit(1); +// } for(int k = 1; k < args.length; k++) { try { url = new URL(args[k]); @@ -433,4 +421,21 @@ } } + /** + * @return the tmpDir + */ + public String getTmpDir() { + if(tmpDir == null) { + return null; + } + return tmpDir.getAbsolutePath(); + } + + /** + * @param tmpDir the tmpDir to set + */ + public void setTmpDir(String tmpDir) { + this.tmpDir = new File(tmpDir); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |