Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
;; Copyright (C) 2015, Jozef Wagner. All rights reserved.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0
;; ( which can be
;; found in the file epl-v10.html at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound
;; by the terms of this license.
;; You must not remove this notice, or any other, from this software.
(ns jogurt.system
(:api dunaj)
(:require [dunaj.resource :as dr]
[dunaj.uuid :as du]
[jogurt.util :as ju]
[jogurt.util.cfg :as juc :refer [sget-in]]
[jogurt.server :refer [server-factory]]
[jogurt.servlet.basic :refer [basic-servlet-factory]]
[jogurt.ring.routes :refer [routes-factory]]
[jogurt.servlet.myvaadinservlet :refer [servlet-factory]])
(:import [jogurt.servlet MyVaadinServlet]))
(def cfg
(assoc (juc/cfg)
:anti-forgery (du/random)))
(def default-auth-factory "jogurt.auth.openid/auth-factory")
(def default-store-factory "")
(def auth-factory
(let [sym (sget-in cfg [:env :jogurt-auth] default-auth-factory)]
@(ju/fetch-var sym)))
(def store-factory
(let [sym (sget-in cfg [:env :jogurt-store] default-store-factory)]
@(ju/fetch-var sym)))
(def jogurt-system
:cfg cfg
:auth auth-factory
:store store-factory
:routes routes-factory
:server server-factory
:servlet servlet-factory))
(defonce jogurt (atom nil))
(defn shutdown!
(shutdown! jogurt))
(let [[sys scope] @jref]
(when scope (release-scope! scope))
(reset! jref nil))))
(defn launch!
(launch! jogurt))
(shutdown! jref)
(reset! jref (grab-scope (start! jogurt-system)))))
;;;; Scratch
(scratch []
(:servlet (first @jogurt))
(:routes jogurt)
(seq (map first (seq jogurt-system)))
( (get (first @jogurt) :store) :users "1")
(! (get (first @jogurt) :store) :users "a"
{:foo "bar"})
( (get (first @jogurt) :store) :users "109257541881760522726")
( (get (first @jogurt) :store) :posts "e41f2229-421d-48ba-81d0-277cd9578edb")