   (.. servlet (getBayeux)
               (getChannel channel true)))
 
+(defn- json-generator
+  "Creates a JSON.Generator object for outputting Clojure data structures."
+  [data]
+  (proxy [JSON$Generator] []
+    (addJSON [buffer]
+      (.append buffer (json data)))))
+
 (defn publish
   "Publish a message to a channel."
   ([channel message]

  ([client channel message]
    (publish *cometd* client channel message))
  ([servlet client channel message]
    (.publish (get-channel servlet channel) client message nil)))

(defn subscribe
  "Subscribe to a channel."

            (func mesg))))
      (.subscribe (get-channel servlet channel) client))))

;;;; Security ;;;;

(comment
(defn allowed-to?)

(defn create-security-policy
  "Create a extensible security policy for an existing cometd servlet."
  [servlet]
  (.. servlet
      (getBayeux)
      (setSecurityPolicy
        (proxy SecurityPolicy
          (canPublish [])))))

(defn deny-subscribe
  "Deny subscription requests matching a predicate."
  [pred])
  

(defn deny-publish
  [pred])

)
