changeset 295:90bab835fc25

Servlet version 1.5.0b -- the beginning of the next generation :-) - code restructuring to improve scaleability - new Initialiser servlet that must be run first - image transformation work moved to DigilibImageWorker class - Maximum number of concurrent threads limited by Semaphore - old JIMI toolkit implementation removed
author robcast
date Sun, 24 Oct 2004 20:23:50 +0200
parents 5b4fbec16a2c
children 0a212bc468ad
files servlet/src/digilib/io/Directory.java servlet/src/digilib/io/DocuDirectory.java servlet/src/digilib/io/ImageFile.java servlet/src/digilib/io/ImageFileset.java servlet/src/digilib/servlet/DigilibConfiguration.java
diffstat 5 files changed, 45 insertions(+), 77 deletions(-) [+]
line wrap: on
line diff
--- a/servlet/src/digilib/io/Directory.java	Sun Oct 24 20:23:49 2004 +0200
+++ b/servlet/src/digilib/io/Directory.java	Sun Oct 24 20:23:50 2004 +0200
@@ -82,10 +82,10 @@
 	 */
 	public boolean readDir() {
 		if (dir != null) {
-			logger.debug("reading dir: "+dir.getPath());
+			//logger.debug("reading dir: "+dir.getPath());
 			list = dir.list();
 			Arrays.sort(list);
-			logger.debug("  done");
+			//logger.debug("  done");
 		}
 		return (list != null);
 	}
--- a/servlet/src/digilib/io/DocuDirectory.java	Sun Oct 24 20:23:49 2004 +0200
+++ b/servlet/src/digilib/io/DocuDirectory.java	Sun Oct 24 20:23:50 2004 +0200
@@ -175,7 +175,7 @@
 		// first file extension to try for scaled directories
 		String scalext = null;
 		// read all filenames
-		logger.debug("reading directory " + dir.getPath());
+		//logger.debug("reading directory " + dir.getPath());
 		/*
 		 * using ReadableFileFilter is safer (we won't get directories with file
 		 * extensions) but slower.
@@ -186,7 +186,7 @@
 		} else {
 			allFiles = dir.listFiles();
 		}
-		logger.debug("  done");
+		//logger.debug("  done");
 		if (allFiles == null) {
 			// not a directory
 			return false;
@@ -204,9 +204,9 @@
 			File d = new File(baseDirNames[j], dirName);
 			if (d.isDirectory()) {
 				dirs[j] = new Directory(d);
-				logger.debug("  reading scaled directory " + d.getPath());
+				//logger.debug("  reading scaled directory " + d.getPath());
 				dirs[j].readDir();
-				logger.debug("    done");
+				//logger.debug("    done");
 			}
 		}
 
--- a/servlet/src/digilib/io/ImageFile.java	Sun Oct 24 20:23:49 2004 +0200
+++ b/servlet/src/digilib/io/ImageFile.java	Sun Oct 24 20:23:50 2004 +0200
@@ -129,7 +129,7 @@
 	 * 
 	 * @return
 	 */
-	public double getAspect() {
+	public float getAspect() {
 		return (pixelSize != null) ? pixelSize.getAspect() : 0;
 	}
 
--- a/servlet/src/digilib/io/ImageFileset.java	Sun Oct 24 20:23:49 2004 +0200
+++ b/servlet/src/digilib/io/ImageFileset.java	Sun Oct 24 20:23:50 2004 +0200
@@ -45,13 +45,13 @@
 	private ArrayList list = null;
 
 	/** aspect ratio (width/height) */
-	private double aspect = 0;
+	private float aspect = 0;
 
 	/** resolution of the biggest image (DPI) */
-	private double resX = 0;
+	private float resX = 0;
 
 	/** resolution of the biggest image (DPI) */
-	private double resY = 0;
+	private float resY = 0;
 
 	/**
 	 * Creator for empty fileset.
@@ -278,8 +278,8 @@
 				}
 			}
 			if (FileOps.classForFilename(dirFiles[fileIdx]) == FileOps.CLASS_IMAGE) {
-				logger.debug("adding file " + dirFiles[fileIdx]
-						+ " to Fileset " + this.getName());
+				/* logger.debug("adding file " + dirFiles[fileIdx]
+						+ " to Fileset " + this.getName()); */
 				add(new ImageFile(dirFiles[fileIdx], this, dirs[dirIdx]));
 			}
 		}
@@ -319,17 +319,17 @@
 		}
 		metaChecked = true;
 		String s;
-		double dpi = 0;
-		double dpix = 0;
-		double dpiy = 0;
-		double sizex = 0;
-		double sizey = 0;
-		double pixx = 0;
-		double pixy = 0;
+		float dpi = 0;
+		float dpix = 0;
+		float dpiy = 0;
+		float sizex = 0;
+		float sizey = 0;
+		float pixx = 0;
+		float pixy = 0;
 		// DPI is valid for X and Y
 		if (fileMeta.containsKey("original-dpi")) {
 			try {
-				dpi = Double.parseDouble((String) fileMeta.get("original-dpi"));
+				dpi = Float.parseFloat((String) fileMeta.get("original-dpi"));
 			} catch (NumberFormatException e) {
 			}
 			if (dpi != 0) {
@@ -342,9 +342,9 @@
 		if (fileMeta.containsKey("original-dpi-x")
 				&& fileMeta.containsKey("original-dpi-y")) {
 			try {
-				dpix = Double.parseDouble((String) fileMeta
+				dpix = Float.parseFloat((String) fileMeta
 						.get("original-dpi-x"));
-				dpiy = Double.parseDouble((String) fileMeta
+				dpiy = Float.parseFloat((String) fileMeta
 						.get("original-dpi-y"));
 			} catch (NumberFormatException e) {
 			}
@@ -360,19 +360,19 @@
 				&& fileMeta.containsKey("original-pixel-x")
 				&& fileMeta.containsKey("original-pixel-y")) {
 			try {
-				sizex = Double.parseDouble((String) fileMeta
+				sizex = Float.parseFloat((String) fileMeta
 						.get("original-size-x"));
-				sizey = Double.parseDouble((String) fileMeta
+				sizey = Float.parseFloat((String) fileMeta
 						.get("original-size-y"));
-				pixx = Double.parseDouble((String) fileMeta
+				pixx = Float.parseFloat((String) fileMeta
 						.get("original-pixel-x"));
-				pixy = Double.parseDouble((String) fileMeta
+				pixy = Float.parseFloat((String) fileMeta
 						.get("original-pixel-y"));
 			} catch (NumberFormatException e) {
 			}
 			if ((sizex != 0) && (sizey != 0) && (pixx != 0) && (pixy != 0)) {
-				resX = pixx / (sizex * 100 / 2.54);
-				resY = pixy / (sizey * 100 / 2.54);
+				resX = pixx / (sizex * 100 / 2.54f);
+				resY = pixy / (sizey * 100 / 2.54f);
 				return;
 			}
 		}
@@ -381,14 +381,14 @@
 	/**
 	 * @return
 	 */
-	public double getResX() {
+	public float getResX() {
 		return resX;
 	}
 
 	/**
 	 * @return
 	 */
-	public double getResY() {
+	public float getResY() {
 		return resY;
 	}
 
@@ -411,7 +411,7 @@
 	 * 
 	 * @return
 	 */
-	public double getAspect() {
+	public float getAspect() {
 		return aspect;
 	}
 
--- a/servlet/src/digilib/servlet/DigilibConfiguration.java	Sun Oct 24 20:23:49 2004 +0200
+++ b/servlet/src/digilib/servlet/DigilibConfiguration.java	Sun Oct 24 20:23:50 2004 +0200
@@ -30,14 +30,9 @@
 
 import org.apache.log4j.BasicConfigurator;
 import org.apache.log4j.Logger;
-import org.apache.log4j.xml.DOMConfigurator;
 
-import digilib.auth.AuthOps;
-import digilib.auth.XMLAuthOps;
 import digilib.image.DocuImage;
 import digilib.image.DocuImageImpl;
-import digilib.io.AliasingDocuDirCache;
-import digilib.io.DocuDirCache;
 import digilib.io.FileOps;
 import digilib.io.XMLListLoader;
 
@@ -146,6 +141,8 @@
 		newParameter("max-image-size", new Integer(0), null, 'f');
 		// use safe (but slower) directory indexing
 		newParameter("safe-dir-index", Boolean.FALSE, null, 'f');
+		// number of working threads
+		newParameter("worker-threads", new Integer(1), null, 'f');
 
 	}
 
@@ -225,47 +222,6 @@
 			}
 		}
 
-		/*
-		 * further initialization
-		 */
-
-		// set up logger
-		File logConf =
-			ServletOps.getConfigFile((File)getValue("log-config-file"), c);
-		DOMConfigurator.configure(logConf.getAbsolutePath());
-		setValue("log-config-file", logConf);
-		// directory cache
-		String[] bd = (String[]) getValue("basedir-list");
-		int[] fcs =
-			{ FileOps.CLASS_IMAGE, FileOps.CLASS_TEXT, FileOps.CLASS_SVG };
-		DocuDirCache dirCache;
-		if (getAsBoolean("use-mapping")) {
-			// with mapping file
-			File mapConf =
-				ServletOps.getConfigFile((File)getValue("mapping-file"), c);
-			dirCache = new AliasingDocuDirCache(bd, fcs, mapConf, this);
-			setValue("mapping-file", mapConf);
-		} else {
-			// without mapping
-			dirCache = new DocuDirCache(bd, fcs, this);
-		}
-		setValue("servlet.dir.cache", dirCache);
-		// useAuthentication
-		if (getAsBoolean("use-authorization")) {
-			// DB version
-			//authOp = new DBAuthOpsImpl(util);
-			// XML version
-			File authConf =
-				ServletOps.getConfigFile((File)getValue("auth-file"), c);
-			AuthOps authOp = new XMLAuthOps(authConf);
-			setValue("servlet.auth.op", authOp);
-			setValue("auth-file", authConf);
-		}
-		// DocuImage class
-		String s = getAsString("docuimage-class");
-		Class cl = Class.forName(getAsString("docuimage-class"));
-		docuImageClass = Class.forName(getAsString("docuimage-class"));
-		setValue("servlet.docuimage.class", docuImageClass.getName());
 	}
 
 	/**
@@ -287,4 +243,16 @@
 		return di;
 	}
 
+	/**
+	 * @return Returns the docuImageClass.
+	 */
+	public Class getDocuImageClass() {
+		return docuImageClass;
+	}
+	/**
+	 * @param docuImageClass The docuImageClass to set.
+	 */
+	public void setDocuImageClass(Class docuImageClass) {
+		this.docuImageClass = docuImageClass;
+	}
 }