@ComponentProfile(summary="Validate a JSON document against a schema", tag="service,json,schema,validation,metadata") public class JsonSchemaService extends ServiceImp
In the adapter configuration file this class is aliased as json-schema-service which is the preferred alternative to the fully qualified classname when building your configuration.
log
Constructor and Description |
---|
JsonSchemaService() |
JsonSchemaService(DataInputParameter<java.lang.String> url) |
Modifier and Type | Method and Description |
---|---|
protected void |
closeService() |
void |
doService(AdaptrisMessage message) |
JsonDeserializer |
getDeserializer()
Configure a
JsonDeserializer if you want to explicitly dictate the behaviour when
attempting to convert to JSON. |
@NonNull JsonSchemaLoader |
getJsonSchemaLoader()
How we load the schema from the URL you have specified
|
@NonNull ValidationExceptionHandler |
getOnValidationException()
What to do when a schema validation is encountered.
|
@NonNull DataInputParameter<java.lang.String> |
getSchemaUrl()
The URL of the schema to use for JSON validation.
|
protected void |
initService() |
void |
prepare() |
void |
setDeserializer(JsonDeserializer deserializer)
Configure a
JsonDeserializer if you want to explicitly dictate the behaviour when
attempting to convert to JSON. |
void |
setJsonSchemaLoader(@NonNull JsonSchemaLoader jsonSchemaLoader)
How we load the schema from the URL you have specified
|
void |
setOnValidationException(@NonNull ValidationExceptionHandler onValidationException)
What to do when a schema validation is encountered.
|
void |
setSchemaUrl(@NonNull DataInputParameter<java.lang.String> schemaUrl)
The URL of the schema to use for JSON validation.
|
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId, start, stop
public JsonSchemaService()
public JsonSchemaService(DataInputParameter<java.lang.String> url)
public void doService(AdaptrisMessage message) throws ServiceException
ServiceException
public void prepare() throws CoreException
CoreException
protected void closeService()
closeService
in class ServiceImp
protected void initService() throws CoreException
initService
in class ServiceImp
CoreException
@NonNull public @NonNull DataInputParameter<java.lang.String> getSchemaUrl()
public void setSchemaUrl(@NonNull @NonNull DataInputParameter<java.lang.String> schemaUrl)
@NonNull public @NonNull ValidationExceptionHandler getOnValidationException()
public void setOnValidationException(@NonNull @NonNull ValidationExceptionHandler onValidationException)
@NonNull public @NonNull JsonSchemaLoader getJsonSchemaLoader()
public void setJsonSchemaLoader(@NonNull @NonNull JsonSchemaLoader jsonSchemaLoader)
public JsonDeserializer getDeserializer()
JsonDeserializer
if you want to explicitly dictate the behaviour when
attempting to convert to JSON.
Note that BasicJsonDeserializer
can coerce invalid json into validity (e.g. {
"key": value}
is coerced into {"key":"value"}
under the covers which means that your
input might pass schema validation but isn't really valid json.
Switch to JacksonJsonDeserializer
if you want a stricter interpretation of the json
data before validating it against a schema. This defaults to BasicJsonDeserializer
for
backwards compatibility reasons.
public void setDeserializer(JsonDeserializer deserializer)
JsonDeserializer
if you want to explicitly dictate the behaviour when
attempting to convert to JSON.
Note that BasicJsonDeserializer
can coerce invalid json into validity (e.g. {
"key": value}
is coerced into {"key":"value"}
under the covers which means that your
input might pass schema validation but isn't really valid json.
Switch to JacksonJsonDeserializer
if you want a stricter interpretation of the json
data before validating it against a schema. This defaults to BasicJsonDeserializer
for
backwards compatibility reasons.