clojureinfinispaninfinispan-9

access infinispan .class in Clojure


I am trying to replicate a snippet of code from the Infinispan documentation in Clojure:

ConfigurationBuilder b = new ConfigurationBuilder();
b.persistence()
  .addStore(SoftIndexFileStoreConfigurationBuilder.class)
  .indexLocation("/tmp/sifs/testCache/index");
  .dataLocation("/tmp/sifs/testCache/data")

Here is my attempt:

(import '[org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfigurationBuilder])
(import '[org.infinispan.configuration.cache ConfigurationBuilder])

(def b (ConfigurationBuilder.))

(.addStore (.persistence b)
           (class org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfigurationBuilder))

;; java.lang.ClassNotFoundException: org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfigurationBuilder

How do I get past this exception? This is the SIFS source


Solution

  • For your case, you should have in your dependencies:

    :dependencies  ... others here ...
                   [org.infinispan/infinispan-core "9.0.1.Final"]
                   [org.infinispan/infinispan-persistence-soft-index "9.0.1.Final"]
    

    Also, you are using import incorrectly. You can either do:

    (import full.package.name.ClassNameHere)
    

    or

    (import [full.package.name ClassNameOne ClassNameTwo])
    

    For your case, you should be doing:

    (import org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfigurationBuilder)
    

    Note that unlike require, where a nil result means "everything's good," with import a nil return means "nothing was imported."