Browse Source

Merge branch 'master' of https://github.com/dvasilen/JsonPath into dvasilen-master

pull/13/merge
Kalle Stenflo 12 years ago
parent
commit
0a566c5402
  1. 18
      json-path/src/main/java/com/jayway/jsonpath/spi/JsonProviderFactory.java

18
json-path/src/main/java/com/jayway/jsonpath/spi/JsonProviderFactory.java

@ -21,10 +21,23 @@ import com.jayway.jsonpath.spi.impl.JsonSmartJsonProvider;
*/ */
public abstract class JsonProviderFactory { public abstract class JsonProviderFactory {
private static Class defaultProvider = null;
public static JsonProviderFactory factory = new JsonProviderFactory() { public static JsonProviderFactory factory = new JsonProviderFactory() {
@Override @Override
protected JsonProvider create() { protected JsonProvider create() {
return new JsonSmartJsonProvider(); JsonProvider provider = null;
try {
if(defaultProvider != null) {
provider = (JsonProvider)defaultProvider.newInstance();
}
} catch(Throwable t) {
}
if(provider == null) {
provider = new JsonSmartJsonProvider();
}
return provider;
//return new JacksonProvider(); //return new JacksonProvider();
} }
}; };
@ -33,6 +46,9 @@ public abstract class JsonProviderFactory {
return factory.create(); return factory.create();
} }
public static synchronized void setDefaultProvider(Class<? extends JsonProvider> jsonProvider) {
defaultProvider = jsonProvider;
}
protected abstract JsonProvider create(); protected abstract JsonProvider create();

Loading…
Cancel
Save