01: // PageCompileProp.java
02: // $Id: PageCompileProp.java,v 1.2 2000/08/16 21:37:43 ylafon Exp $
03: // (c) COPYRIGHT MIT and INRIA, 1998.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05:
06: package org.w3c.jigsaw.pagecompile;
07:
08: import java.io.File;
09:
10: import org.w3c.jigsaw.config.PropertySet;
11:
12: import org.w3c.tools.resources.Attribute;
13: import org.w3c.tools.resources.AttributeRegistry;
14: import org.w3c.tools.resources.FileAttribute;
15: import org.w3c.tools.resources.StringAttribute;
16:
17: import org.w3c.jigsaw.http.httpd;
18:
19: /**
20: * @version $Revision: 1.2 $
21: * @author Benoît Mahé (bmahe@w3.org)
22: */
23: public class PageCompileProp extends PropertySet {
24:
25: /**
26: * Our property name.
27: */
28: protected static String PAGE_COMPILE_PROP_NAME = "PageCompileProps";
29:
30: /**
31: * Name of the property indicating the generated class directory.
32: */
33: protected static String PAGE_COMPILED_DIR = "org.w3c.jigsaw.pagecompile.dir";
34:
35: /**
36: * Name of the property indicating the compiler class name
37: */
38: protected static String PAGE_COMPILER_CLASS = "org.w3c.jigsaw.pagecompile.compiler";
39:
40: /**
41: * Attribute index - The index for our generated class directory.
42: */
43: protected static int ATTR_PAGE_COMPILED_DIR = -1;
44:
45: /**
46: * Attribute index - The index for our compiler class name.
47: */
48: protected static int ATTR_PAGE_COMPILER_CLASS = -1;
49:
50: static {
51: Class cls = null;
52: Attribute a = null;
53:
54: try {
55: cls = Class
56: .forName("org.w3c.jigsaw.pagecompile.PageCompileProp");
57: } catch (Exception ex) {
58: ex.printStackTrace();
59: System.exit(1);
60: }
61: // The generated class directory:
62: a = new FileAttribute(PAGE_COMPILED_DIR, null,
63: Attribute.EDITABLE);
64: ATTR_PAGE_COMPILED_DIR = AttributeRegistry.registerAttribute(
65: cls, a);
66: //The compiler class name:
67: a = new StringAttribute(PAGE_COMPILER_CLASS,
68: "org.w3c.jigsaw.pagecompile.JDKCompiler",
69: Attribute.EDITABLE);
70: ATTR_PAGE_COMPILER_CLASS = AttributeRegistry.registerAttribute(
71: cls, a);
72: }
73:
74: protected File getDefaultCompiledPageDirectory() {
75: File root = server.getRootDirectory();
76: File def = new File(root, "compiledPage");
77: if (!def.exists())
78: def.mkdir();
79: return def;
80: }
81:
82: protected File getCompiledPageDirectory() {
83: File dir = (File) getValue(ATTR_PAGE_COMPILED_DIR, null);
84: if (dir == null) {
85: dir = getDefaultCompiledPageDirectory();
86: setValue(ATTR_PAGE_COMPILED_DIR, dir);
87: }
88: return dir;
89: }
90:
91: protected String getCompilerClassName() {
92: return (String) getValue(ATTR_PAGE_COMPILER_CLASS, null);
93: }
94:
95: PageCompileProp(httpd server) {
96: super(PAGE_COMPILE_PROP_NAME, server);
97: }
98: }
|