2
package org.crosswire.servlet;
4
import javax.servlet.http.*;
7
* Some generic functions to help Servlet writing.
9
* <table border='1' cellPadding='3' cellSpacing='0' width="100%">
10
* <tr><td bgColor='white'class='TableRowColor'><font size='-7'>
11
* Distribution Licence:<br />
12
* Project B is free software; you can redistribute it
13
* and/or modify it under the terms of the GNU General Public License,
14
* version 2 as published by the Free Software Foundation.<br />
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
* General Public License for more details.<br />
19
* The License is available on the internet
20
* <a href='http://www.gnu.org/copyleft/gpl.html'>here</a>, by writing to
21
* <i>Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22
* MA 02111-1307, USA</i>, Or locally at the Licence link below.<br />
23
* The copyright to this program is held by it's authors.
24
* </font></td></tr></table>
25
* @see <a href='http://www.eireneh.com/servlets/Web'>Project B Home</a>
26
* @see <{docs.Licence}>
29
public class ServletUtil
32
* You can create an instance of this class to do reference counting
39
* Called at the start of any service call. The average service method
40
* (or a <code>doGet()</code> or <code>doPost()</code>) method should
41
* do something like this:<pre>
42
* public void service()
44
* sutil.startService();
50
* If there is any lengthy processing to be done in this method then
51
* something like this is a good idea:<pre>
52
* while (inProgress() && sutil.isAlive())
58
* In the destroy method you should do stuff like this:<pre>
59
* public void destroy()
66
* catch (InterruptedException ex)
73
public void startService()
79
* Called at the end of any service call
81
public void endService()
92
* Check to see if destroy has been called. Service methods should
93
* call this before any lengthy operations, and back down if there
96
public boolean isAlive()
102
* This method first sets a flag to inform any service methods that
103
* ask, that we are dying, and then waits for them all to finish
106
public void die() throws InterruptedException
119
/** The number of instances noted */
120
private int counter = 0;
122
/** The number of instances noted */
123
private boolean dying = false;