annotate servlet/src/digilib/servlet/Initialiser.java @ 564:4c51d71aef13 digilibPDF

more reshuffling of classes
author robcast
date Fri, 17 Dec 2010 22:03:14 +0100
parents 686086d6e6d6
children 587c90bc5976
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
297
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
1 /* Initialiser.java -- initalisation servlet for setup tasks
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
2 *
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
3 * Digital Image Library servlet components
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
4 *
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
5 * Copyright (C) 2004 Robert Casties (robcast@mail.berlios.de)
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
6 *
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify it
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
8 * under the terms of the GNU General Public License as published by the Free
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
9 * Software Foundation; either version 2 of the License, or (at your option)
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
10 * any later version.
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
11 *
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
12 * Please read license.txt for the full details. A copy of the GPL may be found
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
13 * at http://www.gnu.org/copyleft/lgpl.html
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
14 *
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License along with
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
16 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
17 * Place, Suite 330, Boston, MA 02111-1307 USA
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
18 *
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
19 * Created on 18.10.2004
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
20 */
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
21 package digilib.servlet;
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
22
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
23 import java.io.File;
546
e7c29b587829 more work on util.concurrent compliant structure
casties
parents: 544
diff changeset
24 import java.io.OutputStream;
544
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
25 import java.util.List;
297
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
26
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
27 import javax.servlet.ServletConfig;
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
28 import javax.servlet.ServletContext;
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
29 import javax.servlet.ServletException;
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
30 import javax.servlet.http.HttpServlet;
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
31
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
32 import org.apache.log4j.Logger;
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
33 import org.apache.log4j.xml.DOMConfigurator;
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
34
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
35 import digilib.auth.AuthOps;
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
36 import digilib.auth.XMLAuthOps;
531
9cedd170b581 * PDF generation works now even with subdirectories
robcast
parents:
diff changeset
37 import digilib.image.DocuImage;
297
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
38 import digilib.io.AliasingDocuDirCache;
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
39 import digilib.io.DocuDirCache;
563
686086d6e6d6 more refactoring and rearranging
robcast
parents: 559
diff changeset
40 import digilib.io.FileOps.FileClass;
557
0885f5ca5b24 more refactoring and rearranging
robcast
parents: 548
diff changeset
41 import digilib.util.DigilibJobCenter;
297
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
42
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
43 /**
544
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
44 * Singleton initalisation servlet for setup tasks and resources.
297
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
45 *
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
46 * @author casties
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
47 *
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
48 */
548
bc9196347188 more refactoring and cleanup
robcast
parents: 546
diff changeset
49 @SuppressWarnings("serial")
297
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
50 public class Initialiser extends HttpServlet {
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
51
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
52 /** servlet version */
563
686086d6e6d6 more refactoring and rearranging
robcast
parents: 559
diff changeset
53 public static final String version = "0.2";
297
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
54
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
55 /** gengeral logger for this class */
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
56 private static Logger logger = Logger.getLogger("digilib.init");
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
57
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
58 /** DocuDirCache instance */
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
59 DocuDirCache dirCache;
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
60
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
61 /** DigilibConfiguration instance */
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
62 DigilibConfiguration dlConfig;
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
63
546
e7c29b587829 more work on util.concurrent compliant structure
casties
parents: 544
diff changeset
64 /** Executor for digilib image jobs */
548
bc9196347188 more refactoring and cleanup
robcast
parents: 546
diff changeset
65 DigilibJobCenter<DocuImage> imageEx;
544
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
66
546
e7c29b587829 more work on util.concurrent compliant structure
casties
parents: 544
diff changeset
67 /** Executor for PDF jobs */
548
bc9196347188 more refactoring and cleanup
robcast
parents: 546
diff changeset
68 DigilibJobCenter<OutputStream> pdfEx;
546
e7c29b587829 more work on util.concurrent compliant structure
casties
parents: 544
diff changeset
69
e7c29b587829 more work on util.concurrent compliant structure
casties
parents: 544
diff changeset
70 /** Executor for PDF image jobs */
548
bc9196347188 more refactoring and cleanup
robcast
parents: 546
diff changeset
71 DigilibJobCenter<DocuImage> pdfImageEx;
546
e7c29b587829 more work on util.concurrent compliant structure
casties
parents: 544
diff changeset
72
297
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
73 /**
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
74 * Initialisation on first run.
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
75 *
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
76 * @see javax.servlet.Servlet#init(javax.servlet.ServletConfig)
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
77 */
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
78 public void init(ServletConfig config) throws ServletException {
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
79 super.init(config);
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
80
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
81 System.out
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
82 .println("***** Digital Image Library Initialisation Servlet (version "
563
686086d6e6d6 more refactoring and rearranging
robcast
parents: 559
diff changeset
83 + version + ") *****");
297
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
84
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
85 // get our ServletContext
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
86 ServletContext context = config.getServletContext();
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
87 // see if there is a Configuration instance
544
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
88 dlConfig = (DigilibConfiguration) context.getAttribute("digilib.servlet.configuration");
297
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
89 if (dlConfig == null) {
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
90 // create new Configuration
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
91 try {
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
92 dlConfig = new DigilibConfiguration(config);
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
93
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
94 /*
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
95 * further initialization
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
96 */
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
97
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
98 // set up the logger
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
99 File logConf = ServletOps.getConfigFile((File) dlConfig
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
100 .getValue("log-config-file"), config);
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
101 DOMConfigurator.configure(logConf.getAbsolutePath());
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
102 dlConfig.setValue("log-config-file", logConf);
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
103 // say hello in the log file
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
104 logger
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
105 .info("***** Digital Image Library Initialisation Servlet (version "
563
686086d6e6d6 more refactoring and rearranging
robcast
parents: 559
diff changeset
106 + version + ") *****");
297
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
107 // directory cache
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
108 String[] bd = (String[]) dlConfig.getValue("basedir-list");
563
686086d6e6d6 more refactoring and rearranging
robcast
parents: 559
diff changeset
109 FileClass[] fcs = { FileClass.IMAGE, FileClass.TEXT };
297
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
110 if (dlConfig.getAsBoolean("use-mapping")) {
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
111 // with mapping file
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
112 File mapConf = ServletOps.getConfigFile((File) dlConfig
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
113 .getValue("mapping-file"), config);
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
114 dirCache = new AliasingDocuDirCache(bd, fcs, mapConf,
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
115 dlConfig);
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
116 dlConfig.setValue("mapping-file", mapConf);
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
117 } else {
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
118 // without mapping
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
119 dirCache = new DocuDirCache(bd, fcs, dlConfig);
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
120 }
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
121 dlConfig.setValue("servlet.dir.cache", dirCache);
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
122 // useAuthentication
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
123 if (dlConfig.getAsBoolean("use-authorization")) {
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
124 // DB version
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
125 //authOp = new DBAuthOpsImpl(util);
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
126 // XML version
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
127 File authConf = ServletOps.getConfigFile((File) dlConfig
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
128 .getValue("auth-file"), config);
544
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
129 AuthOps authOp = new XMLAuthOps(authConf);
297
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
130 dlConfig.setValue("servlet.auth.op", authOp);
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
131 dlConfig.setValue("auth-file", authConf);
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
132 }
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
133 // DocuImage class
564
4c51d71aef13 more reshuffling of classes
robcast
parents: 563
diff changeset
134 DocuImage di = DigilibConfiguration.getDocuImageInstance();
531
9cedd170b581 * PDF generation works now even with subdirectories
robcast
parents:
diff changeset
135 dlConfig.setValue("servlet.docuimage.class", di.getClass().getName());
546
e7c29b587829 more work on util.concurrent compliant structure
casties
parents: 544
diff changeset
136 // digilib worker threads
297
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
137 int nt = dlConfig.getAsInt("worker-threads");
544
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
138 int mt = dlConfig.getAsInt("max-waiting-threads");
563
686086d6e6d6 more refactoring and rearranging
robcast
parents: 559
diff changeset
139 imageEx = new DigilibJobCenter<DocuImage>(nt, mt, true, "servlet.worker.imageexecutor");
543
919e008ab1fb more steps towards more standard java.util.concurrent design
robcast
parents: 542
diff changeset
140 dlConfig.setValue("servlet.worker.imageexecutor", imageEx);
546
e7c29b587829 more work on util.concurrent compliant structure
casties
parents: 544
diff changeset
141 // PDF worker threads
e7c29b587829 more work on util.concurrent compliant structure
casties
parents: 544
diff changeset
142 int pnt = dlConfig.getAsInt("pdf-worker-threads");
e7c29b587829 more work on util.concurrent compliant structure
casties
parents: 544
diff changeset
143 int pmt = dlConfig.getAsInt("pdf-max-waiting-threads");
563
686086d6e6d6 more refactoring and rearranging
robcast
parents: 559
diff changeset
144 pdfEx = new DigilibJobCenter<OutputStream>(pnt, pmt, true, "servlet.worker.pdfexecutor");
546
e7c29b587829 more work on util.concurrent compliant structure
casties
parents: 544
diff changeset
145 dlConfig.setValue("servlet.worker.pdfexecutor", pdfEx);
548
bc9196347188 more refactoring and cleanup
robcast
parents: 546
diff changeset
146 // PDF image worker threads
546
e7c29b587829 more work on util.concurrent compliant structure
casties
parents: 544
diff changeset
147 int pint = dlConfig.getAsInt("pdf-image-worker-threads");
e7c29b587829 more work on util.concurrent compliant structure
casties
parents: 544
diff changeset
148 int pimt = dlConfig.getAsInt("pdf-image-max-waiting-threads");
563
686086d6e6d6 more refactoring and rearranging
robcast
parents: 559
diff changeset
149 pdfImageEx = new DigilibJobCenter<DocuImage>(pint, pimt, true, "servlet.worker.pdfimageexecutor");
546
e7c29b587829 more work on util.concurrent compliant structure
casties
parents: 544
diff changeset
150 dlConfig.setValue("servlet.worker.pdfimageexecutor", pdfImageEx);
297
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
151 // set as the servlets main config
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
152 context.setAttribute("digilib.servlet.configuration", dlConfig);
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
153
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
154 } catch (Exception e) {
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
155 throw new ServletException(e);
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
156 }
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
157 } else {
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
158 // say hello in the log file
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
159 logger
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
160 .info("***** Digital Image Library Initialisation Servlet (version "
563
686086d6e6d6 more refactoring and rearranging
robcast
parents: 559
diff changeset
161 + version + ") *****");
544
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
162 logger.warn("Already initialised!");
297
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
163 }
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
164 }
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
165
544
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
166 /** clean up local resources
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
167 * @see javax.servlet.GenericServlet#destroy()
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
168 */
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
169 @Override
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
170 public void destroy() {
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
171 if (dirCache != null) {
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
172 // shut down dirCache?
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
173 dirCache = null;
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
174 }
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
175 if (imageEx != null) {
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
176 // shut down image thread pool
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
177 List<Runnable> rj = imageEx.shutdownNow();
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
178 int nrj = rj.size();
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
179 if (nrj > 0) {
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
180 logger.error("Still running threads when shutting down image job queue: "+nrj);
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
181 }
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
182 }
559
ad1d473a01f5 clean up thread pools
robcast
parents: 557
diff changeset
183 if (pdfEx != null) {
ad1d473a01f5 clean up thread pools
robcast
parents: 557
diff changeset
184 // shut down pdf thread pool
ad1d473a01f5 clean up thread pools
robcast
parents: 557
diff changeset
185 List<Runnable> rj = pdfEx.shutdownNow();
ad1d473a01f5 clean up thread pools
robcast
parents: 557
diff changeset
186 int nrj = rj.size();
ad1d473a01f5 clean up thread pools
robcast
parents: 557
diff changeset
187 if (nrj > 0) {
ad1d473a01f5 clean up thread pools
robcast
parents: 557
diff changeset
188 logger.error("Still running threads when shutting down PDF job queue: "+nrj);
ad1d473a01f5 clean up thread pools
robcast
parents: 557
diff changeset
189 }
ad1d473a01f5 clean up thread pools
robcast
parents: 557
diff changeset
190 }
ad1d473a01f5 clean up thread pools
robcast
parents: 557
diff changeset
191 if (pdfImageEx != null) {
ad1d473a01f5 clean up thread pools
robcast
parents: 557
diff changeset
192 // shut down pdf image thread pool
ad1d473a01f5 clean up thread pools
robcast
parents: 557
diff changeset
193 List<Runnable> rj = pdfImageEx.shutdownNow();
ad1d473a01f5 clean up thread pools
robcast
parents: 557
diff changeset
194 int nrj = rj.size();
ad1d473a01f5 clean up thread pools
robcast
parents: 557
diff changeset
195 if (nrj > 0) {
ad1d473a01f5 clean up thread pools
robcast
parents: 557
diff changeset
196 logger.error("Still running threads when shutting down PDF-image job queue: "+nrj);
ad1d473a01f5 clean up thread pools
robcast
parents: 557
diff changeset
197 }
ad1d473a01f5 clean up thread pools
robcast
parents: 557
diff changeset
198 }
544
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
199 super.destroy();
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
200 }
5ff500d6812a more steps towards more standard java.util.concurrent design
robcast
parents: 543
diff changeset
201
297
b74c914b48a9 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
diff changeset
202 }