The com.mediamania.hotcache package
This package contains the classes that can be used to support a hot cache, as presented in Chapter 14.
com.mediamania.hotcache.AbstractCache
1 package com.mediamania.hotcache; 2 3 import java.util.Map; 4 import java.util.HashMap; 5 6 import com.mediamania.prototype.PrototypeQueries; 7 import com.mediamania.MediaManiaApp; 8 import com.mediamania.prototype.Movie; 9 10 public abstract class AbstractCache extends MediaManiaApp 11 implements com.mediamania.hotcache.CacheAccess { 12 13 protected Map cache = new HashMap( ); 14 15 /** Creates a new instance of AbstractCache. The AbstractCache is the 16 * base class for MasterCache and SlaveCache. 17 */ 18 protected AbstractCache( ) { 19 } 20 21 /** Get the Movie by title. If the movie is not in the cache, put it in. 22 * @param title the title of the movie 23 * @return the movie instance 24 */ 25 public Movie getMovieByTitle(String title) { 26 Movie movie = (Movie) cache.get(title); 27 if (movie == null) { 28 movie = PrototypeQueries.getMovie (pm, title); 29 if (movie != null) { 30 cache.put (title, movie); 31 } 32 } 33 return movie; 34 } 35 }
com.mediamania.hotcache.AbstractDriver
1 package com.mediamania.hotcache; 2 3 import java.io.InputStream; 4 import java.io.InputStreamReader; 5 import java.io.IOException; 6 import java.io.Reader; 7 import java.io.BufferedReader; 8 9 import java.util.StringTokenizer; 10 11 import java.net.URL; 12 import java.net.MalformedURLException; 13 14 import com.mediamania.Utilities; ...
Get Java Data Objects now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.