01: /*
02: * @(#)PnutsServletContext.java 1.2 04/12/06
03: *
04: * Copyright (c) 1997-2003 Sun Microsystems, Inc. All Rights Reserved.
05: *
06: * See the file "LICENSE.txt" for information on usage and redistribution
07: * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
08: */
09: package pnuts.servlet;
10:
11: import java.io.IOException;
12: import java.net.URL;
13: import java.util.Iterator;
14: import java.util.Set;
15: import pnuts.lang.Pnuts;
16: import pnuts.lang.Context;
17: import pnuts.lang.Package;
18:
19: class PnutsServletContext {
20: Context context;
21: Package basePackage;
22: Pnuts script;
23: long time;
24: Set/*<URL>*/scriptURLs;
25:
26: PnutsServletContext(Context context, Package basePackage) {
27: this .context = context;
28: this .basePackage = basePackage;
29: }
30:
31: public boolean needToUpdate() {
32: if (script == null) {
33: return true;
34: }
35: if (scriptURLs != null && time != 0L) {
36: try {
37: for (Iterator it = scriptURLs.iterator(); it.hasNext();) {
38: URL url = (URL) it.next();
39: long modified = url.openConnection()
40: .getLastModified();
41: if (modified > time) {
42: return true;
43: }
44: }
45: } catch (IOException e) {
46: // ignore
47: }
48: }
49: return false;
50: }
51: }
|