--- /dev/null
+// PageCompileProp.java\r
+// $Id: PageCompileProp.java,v 1.2 2010/06/15 17:53:14 smhuang Exp $\r
+// (c) COPYRIGHT MIT and INRIA, 1998.\r
+// Please first read the full copyright statement in file COPYRIGHT.html\r
+\r
+package org.w3c.jigsaw.pagecompile;\r
+\r
+import java.io.File;\r
+\r
+import org.w3c.jigsaw.config.PropertySet;\r
+\r
+import org.w3c.tools.resources.Attribute;\r
+import org.w3c.tools.resources.AttributeRegistry;\r
+import org.w3c.tools.resources.FileAttribute;\r
+import org.w3c.tools.resources.StringAttribute;\r
+\r
+import org.w3c.jigsaw.http.httpd;\r
+\r
+/**\r
+ * @version $Revision: 1.2 $\r
+ * @author Benoît Mahé (bmahe@w3.org)\r
+ */\r
+public class PageCompileProp extends PropertySet {\r
+\r
+ /**\r
+ * Our property name.\r
+ */\r
+ protected static String PAGE_COMPILE_PROP_NAME = "PageCompileProps";\r
+\r
+ /**\r
+ * Name of the property indicating the generated class directory.\r
+ */\r
+ protected static String PAGE_COMPILED_DIR =\r
+ "org.w3c.jigsaw.pagecompile.dir";\r
+\r
+ /**\r
+ * Name of the property indicating the compiler class name\r
+ */\r
+ protected static String PAGE_COMPILER_CLASS =\r
+ "org.w3c.jigsaw.pagecompile.compiler";\r
+\r
+ /**\r
+ * Attribute index - The index for our generated class directory.\r
+ */\r
+ protected static int ATTR_PAGE_COMPILED_DIR = -1 ;\r
+\r
+ /**\r
+ * Attribute index - The index for our compiler class name.\r
+ */\r
+ protected static int ATTR_PAGE_COMPILER_CLASS = -1;\r
+\r
+ static {\r
+ Class cls = null;\r
+ Attribute a = null;\r
+\r
+ try {\r
+ cls = Class.forName("org.w3c.jigsaw.pagecompile.PageCompileProp");\r
+ //Added by Jeff Huang\r
+ //TODO: FIXIT\r
+ } catch (Exception ex) {\r
+ ex.printStackTrace();\r
+ System.exit(1);\r
+ }\r
+ // The generated class directory:\r
+ a = new FileAttribute(PAGE_COMPILED_DIR,\r
+ null,\r
+ Attribute.EDITABLE);\r
+ ATTR_PAGE_COMPILED_DIR = AttributeRegistry.registerAttribute(cls, a);\r
+ //The compiler class name:\r
+ a = new StringAttribute(PAGE_COMPILER_CLASS,\r
+ "org.w3c.jigsaw.pagecompile.JDKCompiler",\r
+ Attribute.EDITABLE);\r
+ ATTR_PAGE_COMPILER_CLASS = AttributeRegistry.registerAttribute(cls, a);\r
+ }\r
+\r
+ protected File getDefaultCompiledPageDirectory() {\r
+ File root = server.getRootDirectory();\r
+ File def = new File(root, "compiledPage");\r
+ if (! def.exists())\r
+ def.mkdir();\r
+ return def;\r
+ }\r
+\r
+ protected File getCompiledPageDirectory() {\r
+ File dir = (File)getValue(ATTR_PAGE_COMPILED_DIR, null);\r
+ if (dir == null) {\r
+ dir = getDefaultCompiledPageDirectory();\r
+ setValue(ATTR_PAGE_COMPILED_DIR, dir);\r
+ }\r
+ return dir;\r
+ }\r
+\r
+ protected String getCompilerClassName() {\r
+ return (String)getValue(ATTR_PAGE_COMPILER_CLASS, null);\r
+ }\r
+\r
+ PageCompileProp(httpd server) {\r
+ super(PAGE_COMPILE_PROP_NAME, server);\r
+ }\r
+}\r