I'm not completely sure what the point of this would be. If you have
an AOT compiled servlet, adding in the init method is straightforward:
(defn -init [config]
(my-init-stuff))
(defservice my-handler)
And if you have an adapter, then you can just do something like:
(defn run []
(my-init-stuff)
(run-jetty my-handler {:port 8080}))
So why would an init function on the adapter be useful?
- James
A proxy object can only be used within Clojure. If you want to
generate a HttpServlet class suitable for loading into a servlet
container like Jetty or Tomcat, you need AOT compilation. For example:
(ns my-servlet
(:gen-class :name MyServlet :extends javax.servlet.HttpServlet)
(:use [ring.util.servlet :only (defservice)]))
(defn -init [config]
your-init-code-goes-here)
(defservice
your-handler-function)
In this case, adding an "init" method is pretty straightforward.
- James
I'll add it to the Clojure Web Development book I'm writing, as it's a
general technique that isn't specific to Compojure.
- James