comparison common/src/main/java/digilib/servlet/DigilibConfiguration.java @ 903:7779b37d1d05

refactored into maven modules per servlet type. can build servlet-api 2.3 and 3.0 via profile now!
author robcast
date Tue, 26 Apr 2011 20:24:31 +0200
parents
children 28d007673346
comparison
equal deleted inserted replaced
902:89ba3ffcf552 903:7779b37d1d05
1 /*
2 * DigilibConfiguration -- Holding all parameters for digilib servlet.
3 *
4 * Digital Image Library servlet components
5 *
6 * Copyright (C) 2001, 2002 Robert Casties (robcast@mail.berlios.de)
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 * Please read license.txt for the full details. A copy of the GPL may be found
14 * at http://www.gnu.org/copyleft/lgpl.html
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
18 * Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21
22 package digilib.servlet;
23
24 import java.io.IOException;
25
26 import org.apache.log4j.BasicConfigurator;
27 import org.apache.log4j.Logger;
28
29 import digilib.image.DocuImage;
30 import digilib.image.DocuImageImpl;
31 import digilib.io.ImageInput;
32 import digilib.util.ParameterMap;
33
34 /**
35 * Class to hold the digilib servlet configuration parameters. The parameters
36 * can be read from the digilib-config file and be passed to other servlets or
37 * beans. <br>errorImgFileName: image file to send in case of error. <br>
38 * denyImgFileName: image file to send if access is denied. <br>baseDirs:
39 * array of base directories in order of preference (prescaled versions first).
40 * <br>useAuth: use authentication information. <br>authConfPath:
41 * authentication configuration file. <br>... <br>
42 *
43 * @author casties
44 *
45 */
46 public abstract class DigilibConfiguration extends ParameterMap {
47
48 /** DocuImage class instance */
49 protected static Class<DocuImageImpl> docuImageClass = null;
50
51 /** Log4J logger */
52 protected Logger logger = Logger.getLogger("digilib.config");
53
54 /**
55 * Default constructor defines all parameters and their default values.
56 *
57 */
58 public DigilibConfiguration() {
59 super(20);
60 // we start with a default logger config
61 BasicConfigurator.configure();
62 initParams();
63 }
64
65 /**
66 *
67 */
68 protected void initParams() {
69 /*
70 * Definition of parameters and default values. System parameters that
71 * are not read from config file have a type 's'.
72 */
73 }
74
75 /**
76 * Creates a new DocuImage instance.
77 *
78 * The type of DocuImage is specified by docuimage-class.
79 *
80 * @return DocuImage
81 */
82 public static DocuImage getDocuImageInstance() {
83 DocuImageImpl di = null;
84 try {
85 di = docuImageClass.newInstance();
86 } catch (Exception e) {
87 }
88 return di;
89 }
90
91 /**
92 * Check image size and type and store in ImageFile imgf
93 *
94 * @param imgf
95 * @return
96 * @throws IOException
97 */
98 public static ImageInput identifyDocuImage(ImageInput imgf) throws IOException {
99 // use fresh DocuImage instance
100 DocuImage di = getDocuImageInstance();
101 return di.identify(imgf);
102 }
103
104 /**
105 * @return Returns the docuImageClass.
106 */
107 public static Class<DocuImageImpl> getDocuImageClass() {
108 return docuImageClass;
109 }
110
111 /**
112 * @param docuImageClass The docuImageClass to set.
113 */
114 public static void setDocuImageClass(Class<DocuImageImpl> dic) {
115 docuImageClass = dic;
116 }
117 }