 
 (ns ^{:no-doc true} immutant.cache.core
     (:require [immutant.registry :as registry]
+              [clojure.java.io :as io]
               [clojure.tools.logging :as log])
     (:import [org.infinispan.configuration.cache ConfigurationBuilder VersioningScheme CacheMode]
              [org.infinispan.transaction TransactionMode LockingMode]

  builder)

(defn build-config
  [{:keys [locking template] :as opts}]
  (let [builder (ConfigurationBuilder.)]
    (if template (.read builder template))
    (.classLoader builder (.getContextClassLoader (Thread/currentThread)))

        (transactionMode TransactionMode/TRANSACTIONAL))
    (.. builder clustering
        (cacheMode (cache-mode opts)))
    (if persist
      (let [store (.. builder loaders addFileCacheStore)]
        (.. store (location (if (string? persist) persist file-store-path)))))
    (cond
      (= locking :pessimistic) (set-pessimistic-locking! builder)
      (= locking :optimistic) (set-optimistic-locking! builder)
