Existing methods should be overridden by using fns passed to a proxy or they super.method () ?
In the following code, RequestHandler.get () is applied with the proxy get [] .
see: http://github.com/paulosuzart/JTornado (ns org.ctornadoweb) (import '(org.jtornodgeeb web $ request handler)) (import' (org.jtornadoweb HttpServer Web Get $ [Handler (Proxy [Web $ Request Handler] [] ([] (.write "hi CLJ")) (Post [] (Post "Post"))) (.listen (HttpServer) (.add (web. App.) "/" (Class myHandler) false false false) 8089)) Compiled / succession version is the same:
; A JTornado HTTP Server and a Sample RequestHandler Begins; Bit verbose due to compilation instructions The recommendation is to generate; To hide this, the set of macros (ns org.ctornadoweb;) compiles and applies a static main method to start the server: (import: prefix "server-")) (gene-class: name org.ctornadoweb.myhandler : Extends org.jtornadoweb.Web $ requestHandler: prefix "doo" (def-dot-dot [this] "HTTP handles the GET method" (writes "Hello Closer") (deferring-post [this] "HTTP Post method handles "(.write (.getArgument" name "" default "false)) (server-main [defn defn]" main method "(.listen (org.jto) Rnadoweb.HttpServer (.add (org.jtornadoweb.Web $ app.) "/" Org.ctornadoweb.MyHandler) false false false) 8089); (compilation 'org.ctornadoweb) The trace shows that the proxy is being used and then super.get, which is a default exception (throws).
HTTP 405: method is not allowed .jtornadoweb.Web $ RequestHandler.get (Web .Java 72) at Rg.ctornadoweb.proxy $ org.jtornadoweb.Web $ RequestHandler $ 0.get (unknown source) I close Finding a few words about the actual behavior of the proxy Have someone tried to help this? No, super method will not be automatically asked, although you obviously call it The following test cases should show work: If
user = & gt; (Def foo (proxy [java.util.ArrayList] [] (pronounced [] (println "not clearing")) # # user / foo user = & gt; (.size foo) 0user => (. Add foo "hi") real user => (.add foo "bye") real user => (.size foo) 2 user => (.clear foo) zero user => (. Isize foo) 2 was being called super.clear () , the size will appear as 0.
Comments
Post a Comment