diff --git a/apis/ec2/src/main/clojure/org/jclouds/ec2/ebs.clj b/apis/ec2/src/main/clojure/org/jclouds/ec2/ebs.clj index d709871246..d7f178d612 100644 --- a/apis/ec2/src/main/clojure/org/jclouds/ec2/ebs.clj +++ b/apis/ec2/src/main/clojure/org/jclouds/ec2/ebs.clj @@ -22,7 +22,6 @@ :doc "A clojure binding to the jclouds EBS service interface."} org.jclouds.ec2.ebs (:require (org.jclouds [compute :as compute])) - (:use (clojure.contrib def core)) (:import org.jclouds.aws.domain.Region org.jclouds.compute.domain.NodeMetadata (org.jclouds.ec2.domain Volume Volume$Status Snapshot Snapshot$Status AvailabilityZoneInfo) diff --git a/apis/ec2/src/main/clojure/org/jclouds/ec2/ebs2.clj b/apis/ec2/src/main/clojure/org/jclouds/ec2/ebs2.clj index 7871ceae25..975411c8a2 100644 --- a/apis/ec2/src/main/clojure/org/jclouds/ec2/ebs2.clj +++ b/apis/ec2/src/main/clojure/org/jclouds/ec2/ebs2.clj @@ -22,7 +22,6 @@ :doc "A clojure binding to the jclouds EBS service interface."} org.jclouds.ec2.ebs2 (:use [org.jclouds.compute2]) - (:use (clojure.contrib def core)) (:import org.jclouds.aws.domain.Region org.jclouds.compute.domain.NodeMetadata (org.jclouds.ec2.domain Volume Volume$Status Snapshot Snapshot$Status AvailabilityZoneInfo) diff --git a/apis/ec2/src/main/clojure/org/jclouds/ec2/elastic_ip.clj b/apis/ec2/src/main/clojure/org/jclouds/ec2/elastic_ip.clj index 3e3dde2df3..6c52c4cc7f 100644 --- a/apis/ec2/src/main/clojure/org/jclouds/ec2/elastic_ip.clj +++ b/apis/ec2/src/main/clojure/org/jclouds/ec2/elastic_ip.clj @@ -23,7 +23,6 @@ org.jclouds.ec2.elastic-ip (:require (org.jclouds [compute :as compute]) [org.jclouds.ec2.ebs :as ebs]) - (:use (clojure.contrib def core)) (:import org.jclouds.compute.domain.NodeMetadata (org.jclouds.ec2.domain PublicIpInstanceIdPair))) diff --git a/apis/ec2/src/main/clojure/org/jclouds/ec2/elastic_ip2.clj b/apis/ec2/src/main/clojure/org/jclouds/ec2/elastic_ip2.clj index 22d8fdf97c..92883f2322 100644 --- a/apis/ec2/src/main/clojure/org/jclouds/ec2/elastic_ip2.clj +++ b/apis/ec2/src/main/clojure/org/jclouds/ec2/elastic_ip2.clj @@ -23,7 +23,6 @@ org.jclouds.ec2.elastic-ip2 (:require (org.jclouds [compute2 :as compute]) [org.jclouds.ec2.ebs :as ebs]) - (:use (clojure.contrib def core)) (:import org.jclouds.compute.domain.NodeMetadata (org.jclouds.ec2.domain PublicIpInstanceIdPair))) diff --git a/blobstore/src/main/clojure/org/jclouds/blobstore.clj b/blobstore/src/main/clojure/org/jclouds/blobstore.clj index 7c8308995e..3ae9545754 100644 --- a/blobstore/src/main/clojure/org/jclouds/blobstore.clj +++ b/blobstore/src/main/clojure/org/jclouds/blobstore.clj @@ -53,11 +53,6 @@ See http://code.google.com/p/jclouds for details." [java.security DigestOutputStream MessageDigest] com.google.common.collect.ImmutableSet)) -(try - (require '[clojure.contrib.io :as io]) - (catch Exception e - (require '[clojure.contrib.duck-streams :as io]))) - (defn blobstore "Create a logged in context. Options for communication style diff --git a/blobstore/src/main/clojure/org/jclouds/blobstore2.clj b/blobstore/src/main/clojure/org/jclouds/blobstore2.clj index 30b4386157..a34e6a8328 100644 --- a/blobstore/src/main/clojure/org/jclouds/blobstore2.clj +++ b/blobstore/src/main/clojure/org/jclouds/blobstore2.clj @@ -56,11 +56,6 @@ See http://code.google.com/p/jclouds for details." com.google.common.collect.ImmutableSet org.jclouds.encryption.internal.JCECrypto)) -(try - (require '[clojure.contrib.io :as io]) - (catch Exception e - (require '[clojure.contrib.duck-streams :as io]))) - (def ^{:private true} crypto-impl ;; BouncyCastle might not be present. Try to load it, but fall back to @@ -77,11 +72,6 @@ See http://code.google.com/p/jclouds for details." ;; Payload support for creating Blobs. ;; -(def ^{:doc "Type object for a Java primitive byte array, for use in the - PayloadSource protocol." - :private true} - byte-array-type (class (make-array Byte/TYPE 0))) - (defprotocol PayloadSource "Various types can have PayloadSource extended onto them so that they are easily coerced into a Payload." @@ -92,8 +82,6 @@ See http://code.google.com/p/jclouds for details." (payload [p] p) java.io.InputStream (payload [is] (Payloads/newInputStreamPayload is)) - byte-array-type - (payload [ba] (Payloads/newByteArrayPayload ba)) String (payload [s] (Payloads/newStringPayload s)) java.io.File @@ -106,6 +94,13 @@ See http://code.google.com/p/jclouds for details." (writeTo [this output-stream] (func output-stream)))))) +;; something in clojure 1.3 (namespaces?) does not like a private type called byte-array-type, +;; so we refer to (class (make-array ...)) directly; and it only parses if it is its own block, +;; hence separating it from the above +(extend-protocol PayloadSource + (class (make-array Byte/TYPE 0)) + (payload [ba] (Payloads/newByteArrayPayload ba))) + (defn blobstore "Create a logged in context. Options for communication style diff --git a/compute/src/main/clojure/org/jclouds/compute.clj b/compute/src/main/clojure/org/jclouds/compute.clj index 9516dbbbc8..021c4c05c5 100644 --- a/compute/src/main/clojure/org/jclouds/compute.clj +++ b/compute/src/main/clojure/org/jclouds/compute.clj @@ -30,7 +30,6 @@ Current supported providers are: Here's an example of getting some compute configuration from rackspace: (use 'org.jclouds.compute) - (use 'clojure.contrib.pprint) (def provider \"cloudservers\") (def provider-identity \"username\") @@ -57,10 +56,7 @@ webserver: (create-node \"webserver\" compute) See http://code.google.com/p/jclouds for details." - (:use org.jclouds.core - (clojure.contrib logging core)) - (:require - [clojure.contrib.condition :as condition]) + (:use org.jclouds.core (clojure.core incubator)) (:import java.io.File java.util.Properties [org.jclouds.domain Location] @@ -74,13 +70,6 @@ See http://code.google.com/p/jclouds for details." NodePredicates] [com.google.common.collect ImmutableSet])) -(try - (use '[clojure.contrib.reflect :only [get-field]]) - (catch Exception e - (use '[clojure.contrib.java-utils - :only [wall-hack-field] - :rename {wall-hack-field get-field}]))) - (defmacro deprecate-fwd [old-name new-name] `(defn ~old-name {:deprecated "beta-9"} [& args#] (apply ~new-name args#))) (defn compute-service @@ -455,19 +444,15 @@ Options correspond to TemplateBuilder methods." (let [builder (.. compute (templateBuilder))] (doseq [[option value] options] (when-not (known-template-options option) - (condition/raise - :type :invalid-template-builder-option - :message (format "Invalid template builder option : %s" option))) + (throw (Exception. (format "Invalid template builder option : %s" option)))) ;; apply template builder options (try (apply-option builder template-map option value) (catch Exception e - (condition/raise - :type :invalid-template-builder - :message (format + (throw (Exception. (format "Problem applying template builder %s with value %s: %s" option (pr-str value) (.getMessage e)) - :cause e)))) + e))))) (let [template (.build builder) template-options (.getOptions template)] (doseq [[option value] options] @@ -475,10 +460,9 @@ Options correspond to TemplateBuilder methods." (try (apply-option template-options options-map option value) (catch Exception e - (condition/raise - :type :invalid-template-option - :message (format + (throw (Exception. + (format "Problem applying template option %s with value %s: %s" option (pr-str value) (.getMessage e)) - :cause e)))) + e))))) template))) diff --git a/compute/src/main/clojure/org/jclouds/compute2.clj b/compute/src/main/clojure/org/jclouds/compute2.clj index 0109f90ea9..e14d218338 100644 --- a/compute/src/main/clojure/org/jclouds/compute2.clj +++ b/compute/src/main/clojure/org/jclouds/compute2.clj @@ -60,10 +60,7 @@ Here's an example of creating and running a small linux node in the group webser See http://code.google.com/p/jclouds for details. " (:use org.jclouds.core - (clojure.contrib logging core) - (org.jclouds predicate)) - (:require - [clojure.contrib.condition :as condition]) + (org.jclouds predicate) (clojure.core incubator)) (:import java.io.File java.util.Properties [org.jclouds.domain Location] @@ -79,13 +76,6 @@ Here's an example of creating and running a small linux node in the group webser [com.google.common.collect ImmutableSet]) ) -(try - (use '[clojure.contrib.reflect :only [get-field]]) - (catch Exception e - (use '[clojure.contrib.java-utils - :only [wall-hack-field] - :rename {wall-hack-field get-field}]))) - (defn compute-service "Create a logged in context." ([#^String provider #^String provider-identity #^String provider-credential @@ -407,19 +397,16 @@ Options correspond to TemplateBuilder methods." (let [builder (.. compute (templateBuilder))] (doseq [[option value] options] (when-not (known-template-options option) - (condition/raise - :type :invalid-template-builder-option - :message (format "Invalid template builder option : %s" option))) + (throw (Exception. (format "Invalid template builder option : %s" option)))) ;; apply template builder options (try (apply-option builder template-map option value) (catch Exception e - (condition/raise - :type :invalid-template-builder - :message (format - "Problem applying template builder %s with value %s: %s" - option (pr-str value) (.getMessage e)) - :cause e)))) + (throw (Exception. + (format + "Problem applying template builder %s with value %s: %s" + option (pr-str value) (.getMessage e)) + e))))) (let [template (.build builder) template-options (.getOptions template)] (doseq [[option value] options] @@ -427,10 +414,9 @@ Options correspond to TemplateBuilder methods." (try (apply-option template-options options-map option value) (catch Exception e - (condition/raise - :type :invalid-template-option - :message (format - "Problem applying template option %s with value %s: %s" - option (pr-str value) (.getMessage e)) - :cause e)))) + (throw (Exception. + (format + "Problem applying template option %s with value %s: %s" + option (pr-str value) (.getMessage e)) + e))))) template))) diff --git a/compute/src/test/clojure/org/jclouds/compute2_test.clj b/compute/src/test/clojure/org/jclouds/compute2_test.clj index 64b8f919c3..0f4d039e9d 100644 --- a/compute/src/test/clojure/org/jclouds/compute2_test.clj +++ b/compute/src/test/clojure/org/jclouds/compute2_test.clj @@ -23,7 +23,6 @@ (:require [org.jclouds.ssh-test :as ssh-test]) (:import org.jclouds.compute.domain.OsFamily - clojure.contrib.condition.Condition java.net.InetAddress org.jclouds.scriptbuilder.domain.Statements org.jclouds.compute.options.TemplateOptions @@ -158,4 +157,4 @@ list, Alan Dipert and MeikelBrandmeyer." (-> (build-template service {:inbound-ports [22 8080]}) bean :options bean :inboundPorts)))) (testing "invalid" - (is (thrown? Condition (build-template service {:xx :yy})))))) + (is (thrown? Exception (build-template service {:xx :yy})))))) diff --git a/compute/src/test/clojure/org/jclouds/compute_test.clj b/compute/src/test/clojure/org/jclouds/compute_test.clj index 5aa2ea094f..8330943f0c 100644 --- a/compute/src/test/clojure/org/jclouds/compute_test.clj +++ b/compute/src/test/clojure/org/jclouds/compute_test.clj @@ -21,8 +21,7 @@ (:use [org.jclouds.compute] :reload-all) (:use clojure.test) (:import - org.jclouds.compute.domain.OsFamily - clojure.contrib.condition.Condition)) + org.jclouds.compute.domain.OsFamily)) (defmacro with-private-vars [[ns fns] & tests] "Refers private fns from ns and runs tests in context. From users mailing @@ -128,4 +127,4 @@ list, Alan Dipert and MeikelBrandmeyer." (-> (build-template service {:inbound-ports [22 8080]}) bean :options bean :inboundPorts)))) (testing "invalid" - (is (thrown? Condition (build-template service {:xx :yy})))))) + (is (thrown? Exception (build-template service {:xx :yy})))))) diff --git a/compute/src/test/clojure/org/jclouds/ssh_test.clj b/compute/src/test/clojure/org/jclouds/ssh_test.clj index 75d2006400..3ca63dd0c5 100644 --- a/compute/src/test/clojure/org/jclouds/ssh_test.clj +++ b/compute/src/test/clojure/org/jclouds/ssh_test.clj @@ -19,7 +19,7 @@ (ns org.jclouds.ssh-test (:require - [clojure.contrib.logging :as logging]) + [clojure.tools.logging :as logging]) (:import org.jclouds.ssh.SshClient org.jclouds.domain.Credentials diff --git a/core/src/main/clojure/org/jclouds/core.clj b/core/src/main/clojure/org/jclouds/core.clj index cebf07ae8e..6c8787de7c 100644 --- a/core/src/main/clojure/org/jclouds/core.clj +++ b/core/src/main/clojure/org/jclouds/core.clj @@ -19,14 +19,10 @@ (ns org.jclouds.core "Core functionality used across blobstore and compute." - (:use clojure.contrib.logging) + (:use clojure.tools.logging) (:import java.io.File - (com.google.common.collect ImmutableSet))) - -(try - (require '[clojure.contrib.string :as string]) - (catch Exception e - (require '[clojure.contrib.str-utils2 :as string]))) + (com.google.common.collect ImmutableSet)) + (:require [clojure.string :as string])) (def module-lookup {:log4j 'org.jclouds.logging.log4j.config.Log4JLoggingModule @@ -73,11 +69,17 @@ Ensure the module is on the classpath. You are maybe missing a dependency on (apply str (interpose "-" (map string/lower-case (re-seq #"[A-Z][^A-Z]*" a))))) +(defn ^String map-str + "Apply f to each element of coll, concatenate all results into a + String." + [f coll] + (apply str (map f coll))) + (defn camelize "Takes a string, or anything named, and converts it to camel case (capitalised initial component" [a] - (string/map-str string/capitalize (.split (name a) "-"))) + (map-str string/capitalize (.split (name a) "-"))) (defn camelize-mixed "Takes a string, or anything named, and converts it to mixed camel case diff --git a/project/pom.xml b/project/pom.xml index 3693a9f624..1be363108f 100644 --- a/project/pom.xml +++ b/project/pom.xml @@ -236,8 +236,14 @@ org.clojure - clojure-contrib - 1.2.0 + tools.logging + 0.2.3 + true + + + org.clojure + core.incubator + 0.1.0 true @@ -689,23 +695,6 @@ pageTracker._trackPageview(); - - clojure-1.1 - - - org.clojure - clojure - 1.1.0 - true - - - org.clojure - clojure-contrib - 1.1.0 - true - - - site