Changeset 67
- Timestamp:
- 05/05/05 23:47:33 (4 years ago)
- Files:
-
- trunk/dsp/ConfigParser.d (added)
- trunk/dsp/DSPGrammar.d (modified) (3 diffs)
- trunk/dsp/DSPProcessor.d (modified) (3 diffs)
- trunk/dsp/RequestConfig.d (modified) (2 diffs)
- trunk/dsp/ServletCompiler.d (modified) (5 diffs)
- trunk/dsp/ServletGenerator.d (modified) (2 diffs)
- trunk/dsp/servlet/DSPServlet.d (modified) (3 diffs)
- trunk/dsp/servlet/DSPServletProvider.d (modified) (3 diffs)
- trunk/dsp/servlet/ServletRegistry.bak (modified) (previous)
- trunk/dspconf/config.xml (modified) (1 diff)
- trunk/dspconf/dsp01.dsp (modified) (2 diffs)
- trunk/dspconf/dsp02.dsp (modified) (1 diff)
- trunk/dspconf/dsp03.dsp (added)
- trunk/dspcore.d (deleted)
- trunk/dspruntime.bat (modified) (1 diff)
- trunk/server.xml (added)
- trunk/servertest.d (modified) (1 diff)
- trunk/xml/dom/std/CAttr.d (modified) (1 diff)
- trunk/xml/dom/std/CCharacterData.d (modified) (2 diffs)
- trunk/xml/dom/std/CDocument.d (modified) (7 diffs)
- trunk/xml/dom/std/CNamedNodeMap.d (modified) (2 diffs)
- trunk/xml/dom/std/CNode.d (modified) (3 diffs)
- trunk/xml/dom/std/CNodeList.d (modified) (6 diffs)
- trunk/xml/dom/std/CText.d (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/dsp/DSPGrammar.d
r64 r67 34 34 public static char[] escapeStr = "#"; 35 35 public static char[] escapeEscapeStr = "##"; 36 public static char[] fileExtension = "dsp"; 36 37 public static char[] rawPreamble = "dsp"; 37 38 public static char[] preamble = "dsp:"; … … 40 41 public static char[] newline = "\n"; 41 42 42 public static char[] standardInclude = "import dsp.servlet. ServletRegistry,dsp.servlet.IDSPResponse,dsp.servlet.IDSPRequest,std.string,mango.io.model.IWriter";43 public static char[] standardInclude = "import dsp.servlet.IDSPResponse,dsp.servlet.IDSPRequest,std.string,mango.io.model.IWriter"; 43 44 public static char[] servletPrefix = "__servlet_"; 44 45 public static char[] servletDecl = "(IDSPRequest request, IDSPResponse response)"; … … 91 92 `alias void function` ~ servletDecl ~ ` ServletHandle; 92 93 93 static this(){ 94 dsp.servlet.ServletRegistry.registerServletHandle(&` ~ servletFunctionName(name) ~ `,` ~ "`default`" ~ `); 94 extern(C) export void service(IDSPRequest request,IDSPResponse response){ 95 try{ 96 ` ~ servletFunctionName(name) ~`(request,response); 97 } 98 catch(Exception e){ 99 response.setException(e.toString()); 100 } 101 catch(Object o){ 102 response.setException("general servlet exception: " ~ o.toString()); 103 } 95 104 }` ~ newline 105 ; 106 } 107 108 public static char[] dependenciesSection(char[] dependenciesList,char[] modulePath){ 109 return 110 "static char[][] __dependencies = [`" ~ modulePath ~ "`," ~ dependenciesList ~ "];" ~ newline ~ 111 "extern(C) export char[][] dependencies(){ return __dependencies; }" ~ newline 96 112 ; 97 113 } trunk/dsp/DSPProcessor.d
r49 r67 33 33 34 34 35 private import xml.IXMLConsumer ;35 private import xml.IXMLConsumerAdapter; 36 36 private import xml.XMLAttributes; 37 37 … … 39 39 private import std.string; 40 40 41 class DSPProcessor : IXMLConsumer {41 class DSPProcessor : IXMLConsumerAdapter{ 42 42 ServletGenerator generator; 43 43 TagLibrary tags; … … 48 48 } 49 49 50 public char[] getServletSource(char[] modulePath ){51 return generator.getServletSource(modulePath );50 public char[] getServletSource(char[] modulePath,char[] fileExtension){ 51 return generator.getServletSource(modulePath,fileExtension); 52 52 } 53 53 54 54 void xmlProlog(XMLAttributes attribs){ 55 writefln("parsed prolog");56 55 } 57 56 trunk/dsp/RequestConfig.d
r53 r67 38 38 char[] cacheDirectory; 39 39 char[] runtimeDirectory; 40 char[] options; 40 41 41 42 public char[] toString(){ … … 52 53 "cacheDirectory: " ~ cacheDirectory ~ "\n" 53 54 "runtimeDirectory: " ~ runtimeDirectory ~ "\n" 55 "options: " ~ options ~ "\n" 54 56 ; 55 57 } trunk/dsp/ServletCompiler.d
r53 r67 61 61 62 62 parser.parse(processor, provider, stream); 63 std.file.write(cfg.dSourceFilename,cast(char[])processor.getServletSource(cfg.requestModule ));63 std.file.write(cfg.dSourceFilename,cast(char[])processor.getServletSource(cfg.requestModule,cfg.ext)); 64 64 } 65 65 … … 67 67 char[] commandline = 68 68 "dmd " ~ cfg.dSourceFilename ~ 69 " " ~ cfg.options ~ 69 70 " -op" ~ 70 71 " -od" ~ cfg.tempDirectory ~ … … 73 74 " " ~ cfg.runtimeDirectory ~ "DllStub.obj" ~ 74 75 " " ~ cfg.runtimeDirectory ~ "IDSPRequest.obj" ~ 75 " " ~ cfg.runtimeDirectory ~ "IDSPResponse.obj" ~ 76 " " ~ cfg.runtimeDirectory ~ "ServletRegistry.obj" ~ 76 " " ~ cfg.runtimeDirectory ~ "IDSPResponse.obj" ~ 77 77 " " ~ cfg.runtimeDirectory ~ "servlet.def" ~ 78 78 " -version=dsp" ~ … … 85 85 " -op" ~ 86 86 " -od" ~ cfg.tempDirectory ~ 87 " dspruntime.lib" ~87 " mango.lib" ~ 88 88 " servlet.def" ~ 89 89 " -version=dsp" ~ … … 91 91 ; 92 92 */ 93 writefln("command: %s",commandline);93 debug writefln("command: %s",commandline); 94 94 95 95 if(std.process.system(commandline) != 0){ trunk/dsp/ServletGenerator.d
r49 r67 35 35 char[] servletBody; 36 36 char[] servletName; 37 char[] servletDependencies; 37 38 38 39 int contentMode; … … 147 148 } 148 149 149 public char[] getServletSource(char[] modulePath){ 150 public void addDependency(char[] dependency){ 151 servletDependencies ~= "`/" ~ dependency ~ "`,"; 152 } 153 154 public char[] getServletSource(char[] modulePath,char[] fileExtension){ 150 155 return 151 156 DSPGrammar.servletHeader(servletName,modulePath) ~ 157 DSPGrammar.dependenciesSection(servletDependencies,"/" ~ modulePath ~ "." ~ fileExtension) ~ 152 158 DSPGrammar.servletFunction(servletName,servletCPIn,servletBody,servletCPOut) 153 159 ; trunk/dsp/servlet/DSPServlet.d
r65 r67 38 38 private import dsp.RequestConfig; 39 39 40 private import mango.cache.Payload; 41 private import mango.cache.QueuedCache; 42 40 43 private import mango.servlet.Servlet; 44 private import mango.servlet.ServletContext; 45 46 private import mango.http.utils.Dictionary; 47 41 48 private import mango.io.FilePath; 49 private import mango.io.FileProxy; 42 50 private import mango.io.Uri; 43 51 private import mango.log.Logger; 44 52 53 private import mango.format.Int; 54 45 55 private import std.string; 46 56 47 57 extern(C) alias void function(IDSPRequest request,IDSPResponse response) ServiceHandle; 58 extern(C) alias char[][] function() DependencyHandle; 59 60 //TODO: use SystemFinalizer to catch libraries that are still loaded at shutdown 61 62 class DSPLibrary : Payload{ 63 protected long timeModified; 64 protected Library lib; 65 public ServiceHandle service; 66 protected DependencyHandle dependencies; 67 68 protected void unload(){ 69 debug printf("unloading library\n"); 70 lib.unload(); 71 lib = null; 72 service = null; 73 dependencies = null; 74 timeModified = 0; 75 } 76 77 public this(char[] path){ 78 lib = new Library(path); 79 if(lib && lib.isLoaded){ 80 service = cast(ServiceHandle)lib.getSymbol("service"); 81 82 if(!service){ 83 unload(); 84 throw new DSPException("servlet library does not have a valid service handle"); 85 } 86 87 dependencies = cast(DependencyHandle)lib.getSymbol("dependencies"); 88 89 if(!dependencies){ 90 unload(); 91 throw new DSPException("servlet library does not have a valid dependencies handle"); 92 } 93 } 94 else{ 95 if(lib){ 96 unload(); 97 } 98 throw new DSPException("could not load library"); 99 } 100 101 timeModified = (new FileProxy(path)).getModifiedTime(); 102 } 103 104 bit isOutOfDate(char[] basePath,FilePath path){ 105 if(!lib || !lib.isLoaded) return true; 106 107 // verify the date/time of the dependencies 108 foreach(char[] dep; dependencies()){ 109 debug printf("[%.*s%.*s]\n",basePath,dep); 110 if((new FileProxy(basePath ~ dep)).getModifiedTime() > timeModified){ 111 debug printf("%.*s%.*s : servlet is out of date.\n",basePath,dep); 112 unload(); // force unload 113 return true; 114 } 115 } 116 117 debug printf("%.*s%.*s : servlet is up to date.\n",basePath,path.toString()); 118 119 return false; 120 } 121 122 void destroy (){ 123 printf("library: %.*s destroyed\n",lib.getPath); 124 unload(); 125 } 126 127 public char[] toString(){ 128 if(lib){ 129 if(lib.isLoaded){ 130 return "loaded: " ~ lib.getPath; 131 } 132 else{ 133 return "unloaded: " ~ lib.getPath; 134 } 135 } 136 return "[empty library]"; 137 } 138 } 48 139 49 140 /* 50 < p>141 <desc> 51 142 DSPServlet: dll-per-file implementation 52 </ p><p>143 </desc><desc> 53 144 The size of the dlls is directly related to the size of the libraries contributed to its 54 145 compilation. Presently, the libs are floating arount 100kb in size each, due to the inclusion 55 146 of phobos and mango. Possibly loading those libs as dlls could reduce the size, as would recompiling 56 147 them for a release or reduced-capability set. 57 </ p><p>148 </desc><desc> 58 149 dll-per-file is not just for a development time practice, as it is very tunable. The QueuedCache 59 150 can be used to good effect to expire infrequently used libs that needn't be loaded all the time. 60 </ p>151 </desc> 61 152 */ 62 153 63 154 class DSPServlet : Servlet{ 64 Library[char[]] libs;65 66 155 private static Logger logger; 156 protected QueuedCache cache; 67 157 68 158 static this (){ 69 159 logger = Logger.getLogger ("dsp.servlets"); 70 160 } 71 72 public this(){ 73 } 74 75 public ~this(){ 76 foreach(Library lib; libs){ 77 if(lib.isLoaded) lib.unload(); 78 } 79 } 80 81 Library getLibrary(DSPServletContext context,FilePath path){ 82 //TODO: make concurrent 83 84 Library lib = libs[path.toString()]; 85 86 //TODO: add check for file existence 87 //TODO: add check for library date and its validity vs the source file 88 if(!lib){ 89 RequestConfig cfg; 90 91 // configuration 92 93 cfg.pwd = context.getBasePath() ~ "\\"; 94 cfg.pwd = cfg.pwd.replace("/","\\"); 95 cfg.ext = path.getExtension(); 96 97 //HACK: filepath leaves prefixed '/' character on 98 cfg.name = path.getName()[1..$]; 99 100 cfg.modulePath = path.getPath(); 101 cfg.requestModule = cfg.modulePath ~ cfg.name; 102 cfg.dspSourceFilename = cfg.pwd ~ cfg.name ~ "." ~ cfg.ext; 103 104 cfg.tempDirectory = cfg.pwd ~ context.getConfiguration.get("temp-directory"); 105 cfg.cacheDirectory = cfg.pwd ~ context.getConfiguration.get("cache-directory"); 106 107 cfg.dSourceFilename = cfg.tempDirectory ~ cfg.name ~ ".d"; 108 cfg.destServletFilename = cfg.cacheDirectory ~ cfg.name ~ ".dll"; 109 110 cfg.runtimeDirectory = context.getConfiguration.get("runtime-directory"); 111 112 // debug 113 printf("%.*s\n",cfg.toString()); 114 115 // build the servlet library 116 ServletCompiler compiler = new ServletCompiler(); 117 compiler.CompileServlet(cfg); 118 119 // keep the library for later 120 lib = new Library(cfg.destServletFilename); 121 libs[path.toString()] = lib; 122 } 161 162 163 /* 164 <desc> 165 Attempt to recover the servlet from the library cache 166 </desc> 167 */ 168 DSPLibrary recoverLibrary(DSPServletContext context,FilePath path){ 169 char[] libraryPath = context.getBasePath ~ "/" ~ context.getConfiguration.get("cache-directory"); 170 libraryPath ~= path.getName[1..$] ~ ".dll"; 171 172 debug printf("attempting to recover: %.*s\n",libraryPath); 173 174 //TODO: check for file existence here or not? 175 try{ 176 return new DSPLibrary(libraryPath); 177 } 178 179 // catch-all here as the library may not be in a usable condition 180 //TODO: eliminate the library from the cache if it exists? 181 catch(Exception e){ 182 return null; 183 } 184 } 185 186 187 /* 188 <desc> 189 Attempt to build the library from scratch. 190 </desc> 191 */ 192 DSPLibrary buildLibrary(DSPServletContext context,FilePath path){ 193 DSPLibrary lib; 194 RequestConfig cfg; 195 Dictionary contextConfig = context.getConfiguration(); 196 197 // configuration 198 cfg.pwd = context.getBasePath() ~ "\\"; 199 cfg.pwd = cfg.pwd.replace("/","\\"); 200 cfg.ext = path.getExtension(); 201 202 //HACK: filepath leaves prefixed '/' character on 203 cfg.name = path.getName()[1..$]; 204 205 cfg.modulePath = path.getPath(); 206 cfg.requestModule = cfg.modulePath ~ cfg.name; 207 cfg.dspSourceFilename = cfg.pwd ~ cfg.name ~ "." ~ cfg.ext; 208 209 cfg.tempDirectory = cfg.pwd ~ contextConfig.get("temp-directory"); 210 cfg.cacheDirectory = cfg.pwd ~ contextConfig.get("cache-directory"); 211 212 cfg.dSourceFilename = cfg.tempDirectory ~ cfg.name ~ ".d"; 213 cfg.destServletFilename = cfg.cacheDirectory ~ cfg.name ~ ".dll"; 214 215 cfg.runtimeDirectory = contextConfig.get("runtime-directory"); 216 217 cfg.options = contextConfig.get("build-options"); 218 219 // debug 220 debug printf("%.*s\n",cfg.toString()); 221 222 // build the servlet library 223 ServletCompiler compiler = new ServletCompiler(); 224 compiler.CompileServlet(cfg); 225 226 // load the library 227 lib = new DSPLibrary(cfg.destServletFilename); 228 123 229 return lib; 124 230 } … … 135 241 assert(dspResponse); 136 242 assert(context); 243 244 dspResponse.setContentType("text/html"); 137 245 138 246 // bind to the needed dll on the fly 139 247 140 Library lib = getLibrary(context,path); 248 DSPLibrary lib = cast(DSPLibrary)cache.get(request.getPathInfo); 249 141 250 if(lib){ 142 ServiceHandle handle = cast(ServiceHandle)lib.getSymbol("service"); 143 144 // run the service handle 145 if(handle){ 146 handle(dspRequest,dspResponse); 251 printf("cache lib: %.*s = %.*s\n",request.getPathInfo,lib.toString()); 252 } 253 else{ 254 printf("cache lib: %.*s = [not present]\n",request.getPathInfo); 255 } 256 257 // attempt to recover the lib from the file cache 258 if(!lib){ 259 cache.extract(request.getPathInfo); // kill the cache entry 260 lib = recoverLibrary(context,path); 261 if(lib){ 262 cache.put(request.getPathInfo,lib); 147 263 } 148 else{ 149 throw new DSPException("servlet library does not have a valid service handle"); 150 } 151 152 dspResponse.getWriter.put("<h2>This is a test for DSP servlets</h2>"); 153 154 if(dspResponse.isExceptionSet){ 155 throw new DSPException("servlet: " ~ dspResponse.getException()); 156 } 157 } 158 else{ 159 throw new DSPException("could not load library"); 160 } 264 } 265 266 // rebuild the library if recovery fails or is out of date 267 if(!lib || lib.isOutOfDate(context.getBasePath,path)){ 268 lib = buildLibrary(context,path); 269 cache.put(request.getPathInfo,lib); 270 } 271 272 // run the servlet 273 lib.service(dspRequest,dspResponse); 274 275 //TODO: debug information 161 276 } 162 277 else{ … … 167 282 } 168 283 } 284 285 debug private import mango.http.utils.Dictionary; 169 286 170 287 void init (ServletConfig config) 171 288 { 172 //TODO: is this needed? 289 //grab the cache size and concurrency from the config (somehow) 290 ServletContext context = config.getServletContext(); 291 292 debug{ 293 foreach(DElement elem; context.getConfiguration()){ 294 printf("(servlet) config test: %.*s = %.*s\n",elem.name,elem.value); 295 } 296 } 297 298 uint threads = 0; 299 char[] serverThreads = context.getConfiguration.get("server-threads"); 300 if(serverThreads) threads = Int.parse(serverThreads); 301 if(threads == 0) threads = 16; 302 303 uint size = 0; 304 char[] dspCacheSize = context.getConfiguration.get("cache-size"); 305 if(dspCacheSize) size = Int.parse(dspCacheSize); 306 if(size == 0) size = 20; 307 308 debug printf("(cache config) size: %d threads: %d\n",size,threads); 309 310 cache = new QueuedCache(size,threads); 173 311 } 174 312 } 175 176 /+177 /*178 <p>179 all-in-one implementation180 </p><p>181 The tradeoff for one dll per application is a smaller total runtime footprint at the cost of182 more ram up-front and the inability to cache or unload pieces of the application. There may183 be situations where this mode is preferred, as it side-steps the limitations imposed by184 wielding so many libs at once.185 </p><p>186 Developers may find that all-in-one works best for deployment only, and that it may be too187 slow to recompile changes within even modestly sized applications.188 </p>189 190 TODO: needs compiler/generator support to work191 TODO: may best rely on 'build' to get the job done192 */193 class DSPAllInOneServlet : Servlet{194 Library lib;195 ServletHandle handle;196 197 private static Logger logger;198 199 static this (){200 logger = Logger.getLogger ("dsp.servlets");201 }202 203 public this(){204 }205 206 public ~this(){207 if(lib && lib.isLoaded) lib.unload();208 }209 210 Library getLibrary(DSPServletContext context,FilePath path){211 //TODO: make concurrent212 //TODO: add check for file existence213 //TODO: add check for library date and its validity vs the source file214 if(!lib){215 RequestConfig cfg;216 217 // configuration218 219 cfg.pwd = context.getBasePath() ~ "\\";220 cfg.pwd = cfg.pwd.replace("/","\\");221 cfg.ext = path.getExtension();222 223 //HACK: filepath leaves prefixed '/' character on224 cfg.name = path.getName()[1..$];225 226 cfg.modulePath = path.getPath();227 cfg.requestModule = cfg.modulePath ~ cfg.name;228 cfg.dspSourceFilename = cfg.pwd ~ cfg.name ~ "." ~ cfg.ext;229 230 cfg.tempDirectory = cfg.pwd ~ context.getConfiguration.get("temp-directory");231 cfg.cacheDirectory = cfg.pwd ~ context.getConfiguration.get("cache-directory");232 233 cfg.dSourceFilename = cfg.tempDirectory ~ cfg.name ~ ".d";234 cfg.destServletFilename = cfg.cacheDirectory ~ cfg.name ~ ".dll";235 236 cfg.runtimeDirectory = context.getConfiguration.get("runtime-directory");237 238 // debug239 printf("%.*s\n",cfg.toString());240 241 // build the servlet library242 ServletCompiler compiler = new ServletCompiler();243 compiler.CompileServlet(cfg);244 245 // keep the library for later246 lib = new Library(cfg.destServletFilename);247 libs[path.toString()] = lib;248 }249 return lib;250 }251 252 void service (IServletRequest request, IServletResponse response){253 FilePath path = new FilePath(request.getPathInfo);254 255 if(path.getExtension == "dsp"){256 IDSPRequest dspRequest = cast(IDSPRequest)request;257 IDSPResponse dspResponse = cast(IDSPResponse)response;258 DSPServletContext context = cast(DSPServletContext)request.getContext();259 260 assert(dspRequest);261 assert(dspResponse);262 assert(context);263 264 // bind to the needed dll on the fly265 266 Library lib = getLibrary(context,path);267 if(lib){268 ServiceHandle handle = cast(ServiceHandle)lib.getSymbol("service");269 270 // run the service handle271 if(handle){272 handle(dspRequest,dspResponse);273 }274 else{275 throw new DSPException("servlet library does not have a valid service handle");276 }277 278 dspResponse.getWriter.put("<h2>This is a test for DSP servlets</h2>");279 280 if(dspResponse.isExceptionSet){281 throw new DSPException("servlet: " ~ dspResponse.getException());282 }283 }284 else{285 throw new DSPException("could not load library");286 }287 }288 else{289 //TODO: use configuration and handling rules290 //TODO: provide a directory listing if the file doesn't exist291 logger.info ("request for file: " ~ request.getUri.getPath ~ " (" ~ request.getPathInfo ~ ")");292 response.copyFile (request.getContext, request.getPathInfo);293 }294 }295 296 void init (ServletConfig config)297 {298 //TODO: is this needed?299 }300 }301 +/trunk/dsp/servlet/DSPServletProvider.d
r57 r67 26 26 module dsp.servlet.DSPServletProvider; 27 27 28 private import xml.ConduitStream; 29 30 private import dsp.ConfigParser; 31 28 32 private import dsp.servlet.DSPServlet; 33 private import dsp.servlet.DSPServletContext; 29 34 private import dsp.servlet.DSPRequest; 30 35 private import dsp.servlet.DSPResponse; 31 36 32 37 private import mango.servlet.ServletProvider; 38 private import mango.servlet.ServletContext; 33 39 34 40 private import mango.http.server.HttpRequest; … … 37 43 private import mango.http.server.model.IProviderBridge; 38 44 45 private import mango.http.utils.Dictionary; 46 47 private import mango.io.FileConduit; 48 39 49 class DSPServletProvider : ServletProvider{ 50 protected MutableDictionary configuration; 51 52 public this (char[] configPath,uint urls = 2048){ 53 super(urls); 54 55 FileConduit fc = new FileConduit(configPath); 56 57 // load configuration 58 if(fc){ 59 ConduitStream cs = new ConduitStream(fc.getPath.getName,fc); 60 ConfigParser configParser = new ConfigParser(); 61 configuration = configParser.parse(cs); 62 } 63 } 64 65 public Dictionary getConfiguration(){ 66 return configuration; 67 } 40 68 41 69 override HttpRequest createRequest(IProviderBridge bridge){ 42 printf("create request\n");70 debug printf("DSPServletProvider: create request\n"); 43 71 return new DSPRequest(bridge); 44 72 } 45 73 46 override HttpResponse createResponse(IProviderBridge bridge) 47 { 48 printf("create response\n"); 74 override HttpResponse createResponse(IProviderBridge bridge){ 75 debug printf("DSPServletProvider: create response\n"); 49 76 return new DSPResponse(bridge); 50 77 } … … 53 80 { 54 81 return "DSPServlet"; 55 } 82 } 83 56 84 } trunk/dspconf/config.xml
r64 r67 1 1 <?xml version="1.0"?> 2 2 <config> 3 <temp-directory value="_temp\"/>4 3 <cache-directory value="_cache\"/> 4 <cache-size value="2"/> 5 5 <runtime-directory value="c:\dev\dsp\trunk\runtime/"/> 6 < dmdopts></dmdopts>6 <build-options value=""/> 7 7 </config> trunk/dspconf/dsp01.dsp
r55 r67 2 2 <?dsp:in assert(response); ?> 3 3 <?dsp:out assert(response); ?> 4 <?dsp:xml version="1.0" ?>5 4 <?dsp 6 5 char[] expr(){ … … 20 19 else response.getWriter.put("hello world"); 21 20 </dsp:code> 21 <p> 22 Changed Again IIIIIIII 23 </p> 22 24 </body> 23 25 </html> trunk/dspconf/dsp02.dsp
r64 r67 1 1 <?xml version="1.0" ?> 2 2 <?dsp 3 3 response.getWriter.put("This is Servlet #2"); 4 4 ?> 5 5 <html/> trunk/dspruntime.bat
r51 r67 1 dmd -c dsp\servlet\ServletRegistry.d -odruntime2 1 dmd -c dsp\servlet\IDSPRequest.d -odruntime 3 2 dmd -c dsp\servlet\IDSPResponse.d -odruntime trunk/servertest.d
r64 r67 95 95 96 96 // construct a servlet-provider 97 DSPServletProvider sp = new DSPServletProvider( );97 DSPServletProvider sp = new DSPServletProvider("server.xml"); 98 98 99 99 // create a context for admin servlets trunk/xml/dom/std/CAttr.d
r66 r67 24 24 protected DOMTypeInfo _DOMTypeInfo; 25 25 26 public this(in DOMString name){ 26 public this(CDocument document,DOMString name,DOMString value){ 27 super(document); 27 28 _name = name; 29 _value = value; 28 30 } 29 31 30 public this( in DOMString namespaceURI, in DOMString qualifiedName){32 public this(CDocument document,in DOMString namespaceURI, in DOMString qualifiedName,DOMString value){ 31 33 _name = qualifiedName; 32 34 super.setQName(namespaceURI,qualifiedName); 35 _value = value; 33 36 } 37 38 public void ownerElement(Element value){ _ownerElement = value; } 34 39 35 40 trunk/xml/dom/std/CCharacterData.d
r66 r67 13 13 abstract class CCharacterData : CNode, CharacterData{ 14 14 protected DOMString _data; 15 16 protected this(CDocument document,DOMString data){ 17 super(document); 18 _data = data; 19 } 15 20 16 21 /+ CharacterData Overloads +/ … … 19 24 void data(DOMString value){ _data = value; } 20 25 21 uint length(){ return _data.length; }26 uint length(){ return _data.length; } 22 27 23 DOMString substringData(in uint offset,in uint count); 24 void appendData(in DOMString arg); 25 void insertData(in uint offset, in DOMString arg); 26 void deleteData(in uint offset, in uint count); 27 void replaceData(in uint offset,in uint count,in DOMString arg); 28 DOMString substringData(in uint offset,in uint count){ 29 if(offset+count >= _data.length){ 30 throw new DOMException(INDEX_SIZE_ERR); 31 } 32 return _data[offset..offset+count]; 33 } 28 34 29 }; 35 void appendData(in DOMString arg){ 36 _data ~= arg; 37 } 38 39 void insertData(in uint offset, in DOMString arg){ 40 _data = _data[0..offset] ~ arg ~ _data[offset.._data.length]; 41 } 42 43 void deleteData(in uint offset, in uint count){ 44 if(offset+count >= _data.length){ 45 throw new DOMException(INDEX_SIZE_ERR); 46 } 47 _data = _data[0..offset] ~ _data[offset+count.._data.length]; 48 } 49 50 void replaceData(in uint offset,in uint count,in DOMString arg){ 51 if(offset+count >= _data.length){ 52 throw new DOMException(INDEX_SIZE_ERR); 53 } 54 _data = _data[0..offset] ~ arg ~ _data[offset+count.._data.length]; 55 } 56 } trunk/xml/dom/std/CDocument.d
r66 r67 72 72 73 73 DocumentFragment createDocumentFragment(){ 74 return new CDocumentFragment( );74 return new CDocumentFragment(this); 75 75 } 76 76 77 77 Text createTextNode(in DOMString data){ 78 return new CText( );78 return new CText(this,data); 79 79 } 80 80 81 81 Comment createComment(in DOMString data){ 82 return new CComment( data);82 return new CComment(this,data); 83 83 } 84 84 85 85 CDATASection createCDATASection(in DOMString data){ 86 return new CCDATASection( data);86 return new CCDATASection(this,data); 87 87 } 88 88 … … 91 91 //according to the XML version in use specified in the Document.xmlVersion attribute. 92 92 93 return new CProcessingInstruction(t arget,data):93 return new CProcessingInstruction(this,target,data): 94 94 } 95 95 … … 97 97 //TODO: NVALID_CHARACTER_ERR: Raised if the specified name is not an XML name 98 98 //according to the XML version in use specified in the 99 return new CAttr( name);99 return new CAttr(this,name); 100 100 } 101 101 … … 105 105 //according to the XML version in use specified in the 106 106 107 CEntityReference value = new CEntityReference( name);107 CEntityReference value = new CEntityReference(this,name); 108 108 //TODO: find corresponding Entity and copy child list to 'value'. 109 109 return value; … … 111 111 112 112 NodeList getElementsByTagName(in DOMString tagname){ 113 CNodeList list = new CNodeList(); 114 115 //TODO: add matching tags in document order ("*" means all) 113 if(tagname == "*") return super._children.dup(); 114 115 NodeList list = new CNodeList(); 116 117 foreach(Node node; super._children){ 118 if(node.name == name) list.append(node); 119 } 120 116 121 return list; 117 122 } … … 127 132 // http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-DocCrElNS 128 133 129 return new CElement( namespaceURI,qualifiedName);134 return new CElement(this,namespaceURI,qualifiedName); 130 135 } 131 136 … … 134 139 // http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-DocCrElNS 135 140 136 return new CAttr( namespaceURI,qualifiedName);141 return new CAttr(this,namespaceURI,qualifiedName); 137 142 } 138 143 trunk/xml/dom/std/CNamedNodeMap.d
r66 r67 15 15 Node[DOMString] map; 16 16 17 /+ NamedNodeMap Overrides +/ 17 18 public Node getNamedItem(in DOMString name){ 18 19 return map[name]; … … 58 59 }; 59 60 60 //TODO: implement a read-only map 61 62 63 class CReadOnlyNamedNodeMap : CNamedNodeMap{ 64 Node[DOMString] map; 65 66 public Node setNamedI
