Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added ability to create config directly from JSON object.

Change-Id: Ieeef63d2cfed87b586b01eadb8bd5c0b2c192a24
Reviewed-on: http://review.northscale.com/1404
Reviewed-by: Steve Yen <steve.yen@gmail.com>
Tested-by: Steve Yen <steve.yen@gmail.com>
  • Loading branch information...
commit eee8e57622c4634d4218c7579e9342dc2ca4c126 1 parent 61b272a
@eshelestovich eshelestovich authored steveyen committed
View
3  src/main/java/com/northscale/jvbucket/ConfigFactory.java
@@ -9,6 +9,8 @@
package com.northscale.jvbucket;
+import org.codehaus.jettison.json.JSONObject;
+
/**
* @author Eugene Shelestovich
*/
@@ -18,4 +20,5 @@
Config createConfigFromString(String data);
+ Config createConfigFromJSON(JSONObject jsonObject);
}
View
8 src/main/java/com/northscale/jvbucket/DefaultConfigFactory.java
@@ -56,6 +56,14 @@ public Config createConfigFromString(String data) {
}
}
+ public Config createConfigFromJSON(JSONObject jsonObject) {
+ try {
+ return parseJSON(jsonObject);
+ } catch (JSONException e) {
+ throw new ConfigParsingException("Exception parsing JSON data: " + e.getMessage());
+ }
+ }
+
private HashAlgorithm lookupHashAlgorithm(String algorithm) {
HashAlgorithm ha = HashAlgorithm.NATIVE_HASH;
if ("crc".equalsIgnoreCase(algorithm)) {
Please sign in to comment.
Something went wrong with that request. Please try again.