01: /*
02: * init.java
03: *
04: * Copyright (c) 1997-2006 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 pnuts.lang.Pnuts;
12: import pnuts.lang.Runtime;
13: import pnuts.lang.Package;
14: import pnuts.lang.Context;
15: import pnuts.ext.ModuleBase;
16:
17: /**
18: * Initialization of the pnuts.servlet module
19: */
20: public class init extends ModuleBase {
21:
22: static String[] files = { "pnuts/servlet/escape",
23: "pnuts/servlet/session", "pnuts/servlet/setup" };
24:
25: static String[][] functions = { { "unescape" }, { "session", },
26: { "setupPages", "setupActions" }, };
27:
28: static String[] javaFunctions = { "getFile", "getCookie",
29: "addCookie", "getInitParameter", "makeQueryString",
30: "parseQueryString", "readMultipartRequest",
31: "readGetParameters", "readPostParameters",
32: "readParameters", "getParameter", "decodeURL", "encodeURL",
33: "getURL", "getSession", "getSessionMap", "sendRedirect",
34: "getRequest", "getResponse", "requestScope", "requestPath",
35: "forward", "debug", "readDynamicPage",
36: "convertDynamicPage", "escape", "sendPostRequest" };
37:
38: protected String getPrefix() {
39: return "org";
40: }
41:
42: public Object execute(Context context) {
43: try {
44: context.usePackage("pnuts.tools");
45: try {
46: Class.forName("java.lang.CharSequence");
47: context.usePackage("pnuts.nio");
48: } catch (ClassNotFoundException e) {
49: }
50: // context.clearPackages();
51: for (int i = 0; i < files.length; i++) {
52: autoload(functions[i], files[i], context);
53: }
54: for (int i = 0; i < javaFunctions.length; i++) {
55: autoloadFunction(javaFunctions[i], context);
56: }
57:
58: } catch (Exception e) {
59: e.printStackTrace();
60: }
61: return null;
62: }
63: }
|