|
|
@ -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(); |
|
|
|
|
|
|
|
|
|
|
|