mirror of https://github.com/apache/jclouds.git
Removed static dependency on extension modules. Removed lein project.clj files.
This commit is contained in:
parent
33a31c03ed
commit
6ad07515c5
|
@ -1,14 +0,0 @@
|
||||||
(defproject org.jclouds/clj-blobstore "0.1-SNAPSHOT"
|
|
||||||
:description "clojure binding for jclouds blobstore library"
|
|
||||||
:source-path "src/main/clojure"
|
|
||||||
:test-path "src/test/clojure"
|
|
||||||
:compile-path "target/classes"
|
|
||||||
:library-path "target"
|
|
||||||
:dependencies [[org.clojure/clojure "1.1.0"]
|
|
||||||
[org.clojure/clojure-contrib "1.1.0"]
|
|
||||||
[org.jclouds/jclouds-blobstore "1.0-beta-4"]
|
|
||||||
[org.jclouds/jclouds-log4j "1.0-beta-4"]
|
|
||||||
[log4j/log4j "1.2.14"]]
|
|
||||||
:dev-dependencies [[org.clojure/swank-clojure "1.0"]]
|
|
||||||
:repositories [["jclouds" "http://jclouds.googlecode.com/svn/repo"]
|
|
||||||
["jclouds-snapshot" "http://jclouds.rimuhosting.com/maven2/snapshots"]])
|
|
|
@ -1,17 +0,0 @@
|
||||||
(defproject org.jclouds/clj-compute "0.1-SNAPSHOT"
|
|
||||||
:description "clojure binding for jclouds compute library"
|
|
||||||
:source-path "src/main/clojure"
|
|
||||||
:test-path "src/test/clojure"
|
|
||||||
:compile-path "target/classes"
|
|
||||||
:library-path "target"
|
|
||||||
:dependencies [[org.clojure/clojure "1.1.0"]
|
|
||||||
[org.clojure/clojure-contrib "1.1.0"]
|
|
||||||
[org.jclouds/jclouds-compute "1.0-beta-4"]
|
|
||||||
[org.jclouds/jclouds-jsch "1.0-beta-4"]
|
|
||||||
[org.jclouds/jclouds-log4j "1.0-beta-4"]
|
|
||||||
[org.jclouds/jclouds-enterprise "1.0-beta-4"]
|
|
||||||
[log4j/log4j "1.2.14"]
|
|
||||||
[com.jcraft/jsch "0.1.42"]]
|
|
||||||
:dev-dependencies [[org.clojure/swank-clojure "1.0"]]
|
|
||||||
:repositories [["jclouds" "http://jclouds.googlecode.com/svn/repo"]
|
|
||||||
["jclouds-snapshot" "http://jclouds.rimuhosting.com/maven2/snapshots"]])
|
|
|
@ -25,6 +25,7 @@ Here's an example of getting some compute configuration from rackspace:
|
||||||
"}
|
"}
|
||||||
org.jclouds.compute
|
org.jclouds.compute
|
||||||
(:use clojure.contrib.duck-streams
|
(:use clojure.contrib.duck-streams
|
||||||
|
clojure.contrib.logging
|
||||||
[clojure.contrib.str-utils2 :only [capitalize lower-case map-str]]
|
[clojure.contrib.str-utils2 :only [capitalize lower-case map-str]]
|
||||||
[clojure.contrib.java-utils :only [wall-hack-field]])
|
[clojure.contrib.java-utils :only [wall-hack-field]])
|
||||||
(:import java.io.File
|
(:import java.io.File
|
||||||
|
@ -39,18 +40,29 @@ Here's an example of getting some compute configuration from rackspace:
|
||||||
(com.google.common.collect ImmutableSet)))
|
(com.google.common.collect ImmutableSet)))
|
||||||
|
|
||||||
(def module-lookup
|
(def module-lookup
|
||||||
{:log4j org.jclouds.logging.log4j.config.Log4JLoggingModule
|
{:log4j 'org.jclouds.logging.log4j.config.Log4JLoggingModule
|
||||||
:ssh org.jclouds.ssh.jsch.config.JschSshClientModule
|
:ssh 'org.jclouds.ssh.jsch.config.JschSshClientModule
|
||||||
:enterprise org.jclouds.enterprise.config.EnterpriseConfigurationModule})
|
:enterprise 'org.jclouds.enterprise.config.EnterpriseConfigurationModule})
|
||||||
|
|
||||||
|
(defn- instantiate [sym]
|
||||||
|
(let [loader (.getContextClassLoader (Thread/currentThread))]
|
||||||
|
(try
|
||||||
|
(.newInstance #^Class (.loadClass loader (name sym)))
|
||||||
|
(catch java.lang.ClassNotFoundException e
|
||||||
|
(warn (str "Could not find " (name sym) " module.
|
||||||
|
Ensure the module is on the classpath. You are maybe missing a dependency on
|
||||||
|
org.jclouds/jclouds-jsch
|
||||||
|
org.jclouds/jclouds-log4j
|
||||||
|
or org.jclouds/jclouds-enterprise."))))))
|
||||||
|
|
||||||
(defn modules
|
(defn modules
|
||||||
"Build a list of modules suitable for passing to compute-context"
|
"Build a list of modules suitable for passing to compute-context"
|
||||||
[& modules]
|
[& modules]
|
||||||
(.build #^com.google.common.collect.ImmutableSet$Builder
|
(.build #^com.google.common.collect.ImmutableSet$Builder
|
||||||
(reduce #(.add #^com.google.common.collect.ImmutableSet$Builder %1
|
(reduce #(.add #^com.google.common.collect.ImmutableSet$Builder %1 %2)
|
||||||
(.newInstance #^Class (%2 module-lookup)))
|
|
||||||
(com.google.common.collect.ImmutableSet/builder)
|
(com.google.common.collect.ImmutableSet/builder)
|
||||||
modules)))
|
(filter (complement nil?)
|
||||||
|
(map (comp instantiate module-lookup) modules)))))
|
||||||
|
|
||||||
(defn compute-context
|
(defn compute-context
|
||||||
"Create a logged in context."
|
"Create a logged in context."
|
||||||
|
|
|
@ -2,5 +2,31 @@
|
||||||
(:use [org.jclouds.compute] :reload-all)
|
(:use [org.jclouds.compute] :reload-all)
|
||||||
(:use clojure.test))
|
(:use clojure.test))
|
||||||
|
|
||||||
|
(defmacro with-private-vars [[ns fns] & tests]
|
||||||
|
"Refers private fns from ns and runs tests in context. From users mailing
|
||||||
|
list, Alan Dipert and MeikelBrandmeyer."
|
||||||
|
`(let ~(reduce #(conj %1 %2 `@(ns-resolve '~ns '~%2)) [] fns)
|
||||||
|
~@tests))
|
||||||
|
|
||||||
|
(with-private-vars [org.jclouds.compute [instantiate]]
|
||||||
|
(deftest instantiate-test
|
||||||
|
(is (instance? String (instantiate 'java.lang.String)))))
|
||||||
|
|
||||||
(deftest os-families-test
|
(deftest os-families-test
|
||||||
(is (some #{"centos"} (map str (os-families)))))
|
(is (some #{"centos"} (map str (os-families)))))
|
||||||
|
|
||||||
|
(deftest modules-empty-test
|
||||||
|
(is (.isEmpty (modules))))
|
||||||
|
|
||||||
|
(deftest modules-instantiate-test
|
||||||
|
(binding [org.jclouds.compute/module-lookup
|
||||||
|
(assoc org.jclouds.compute/module-lookup
|
||||||
|
:string 'java.lang.String)]
|
||||||
|
(is (instance? String (first (modules :string))))
|
||||||
|
(is (= 1 (count (modules :string))))))
|
||||||
|
|
||||||
|
(deftest modules-instantiate-fail-test
|
||||||
|
(binding [org.jclouds.compute/module-lookup
|
||||||
|
(assoc org.jclouds.compute/module-lookup
|
||||||
|
:non-existing 'this.doesnt.Exist)]
|
||||||
|
(is (.isEmpty (modules :non-existing)))))
|
||||||
|
|
Loading…
Reference in New Issue