JavaXT
|
|||||||||
FileManager ClassUsed to serve up static files (html, javascript, css, images, etc). Ensures static files are cached properly by browsers by appending version numbers to css and js files. Also updates js and css resources referenced inside html files and application-specific xml files. Redirects requests to the most recent version of each file. Sends 304 responses as required.
ConstructorsPublic MethodsgetFileUpdates( EventMonitor eventMonitor ) returns void Used to monitor the web directory for changes. Calls the eventMonitor whenever a file is created, updated, moved or deleted. Example:
fileManager.getFileUpdates((Directory.Event event) -> { String op; int eventID = event.getEventID(); if (eventID==Directory.Event.CREATE){ op = "create"; } else if (eventID==Directory.Event.DELETE){ op = "delete"; } else{ op = "update"; } java.io.File file = new java.io.File(event.getFile()); console.log(op, file); }); getFile( HttpServletRequest request ) returns java.io.File Returns a file that best matches the given HttpServletRequest. See the other getFile() method for more information. getFile( String path ) returns java.io.File Returns a file that best matches the given path. If the path represents a directory, searches for welcome files in the directory (e.g. "index.html"). Returns null if a file is not found. sendFile( HttpServletRequest request, HttpServletResponse response ) returns void Used to send a file to the client. sendFile( String path, HttpServletRequest request, HttpServletResponse response ) returns void Used to send a file to the client. sendFile( java.io.File file, HttpServletRequest request, HttpServletResponse response ) returns void Used to send a file to the client. sendFile( javaxt.io.File file, HttpServletRequest request, HttpServletResponse response ) returns void Used to send a file to the client. sendResponse( String html, long date, HttpServletRequest request, HttpServletResponse response ) returns void Sends a given string to the client. Transparently handles caching using "ETag" and "Last-Modified" headers.
updateLinks( javaxt.io.File xmlFile, org.w3c.dom.Document xml ) returns long Used to update links to scripts and css files by appending a version number to the urls (?v=12345678). This operation is multi-threaded to improve performance.
updateNodes( NodeList nodes, org.w3c.dom.Document xml ) returns void Adds empty comment blocks to "childless" nodes to prevent self-enclosing tags. updateNode( Node node, org.w3c.dom.Document xml ) returns void Adds an empty comment block to a node to prevent self-enclosing tags. Public Classes |