org.mule.module.json.transformers
Class JsonSchemaXsdValidationFilter

java.lang.Object
  extended by org.mule.module.xml.filters.AbstractJaxpFilter
      extended by org.mule.module.xml.filters.SchemaValidationFilter
          extended by org.mule.module.json.transformers.JsonSchemaXsdValidationFilter
All Implemented Interfaces:
MuleContextAware, Initialisable, Filter, JsonSchemaFilter

public class JsonSchemaXsdValidationFilter
extends SchemaValidationFilter
implements JsonSchemaFilter

Validate a JSON string against an XML schema.

Note: Ideally, this would call the Validator using STAX. Unfortunately, 1. xalan.jar is needed to avoid bugs in the version of Xalan built into the JRE 2. Xalan does not work with STAX 3. Having Xalan in the classpath overrides the default (STAX-compliant) factories for transformations, validators, etc with ones that aren't STAX-compliant

The result is that, while the ideal would be to implement this class by validating a STAXSource, that won't be possible until either we can assume a JRE with bith STAX and a working Xalan fork, or there';s a xalan.jar that supports StAX.


Field Summary
protected  JsonToXml jToX
           
protected  MuleContext muleContext
           
 
Fields inherited from class org.mule.module.xml.filters.SchemaValidationFilter
DEFAULT_SCHEMA_LANGUAGE, logger
 
Fields inherited from interface org.mule.api.lifecycle.Initialisable
PHASE_NAME
 
Constructor Summary
JsonSchemaXsdValidationFilter()
           
 
Method Summary
 boolean accept(MuleMessage msg)
          Accepts the message if schema validation passes.
 void initialise()
          Method used to perform any initialisation work.
 void setMuleContext(MuleContext muleContext)
           
 void setSchemaLocations(String schemaLocations)
           
 
Methods inherited from class org.mule.module.xml.filters.SchemaValidationFilter
createValidator, getDelayedResult, getErrorHandler, getResourceResolver, getSchemaLanguage, getSchemaLocations, getSchemaObject, getValidatorFeatures, getValidatorProperties, getXMLInputFactory, isReturnResult, isUseStaxSource, loadSchemaStream, loadSource, setErrorHandler, setResourceResolver, setReturnResult, setSchemaLanguage, setSchemaObject, setUseStaxSource, setValidatorFeatures, setValidatorProperties, setXMLInputFactory
 
Methods inherited from class org.mule.module.xml.filters.AbstractJaxpFilter
getDocumentBuilderFactory, setDocumentBuilderFactory, toDOMNode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mule.module.json.transformers.JsonSchemaFilter
createValidator, getErrorHandler, getResourceResolver, getSchemaLanguage, getSchemaLocations, getSchemaObject, getValidatorFeatures, getValidatorProperties, getXMLInputFactory, isReturnResult, isUseStaxSource, setErrorHandler, setResourceResolver, setReturnResult, setSchemaLanguage, setSchemaObject, setUseStaxSource, setValidatorFeatures, setValidatorProperties, setXMLInputFactory
 

Field Detail

muleContext

protected MuleContext muleContext

jToX

protected JsonToXml jToX
Constructor Detail

JsonSchemaXsdValidationFilter

public JsonSchemaXsdValidationFilter()
Method Detail

accept

public boolean accept(MuleMessage msg)
Description copied from class: SchemaValidationFilter
Accepts the message if schema validation passes.

Specified by:
accept in interface Filter
Overrides:
accept in class SchemaValidationFilter
Parameters:
msg - The message.
Returns:
Whether the message passes schema validation.

setMuleContext

public void setMuleContext(MuleContext muleContext)
Specified by:
setMuleContext in interface MuleContextAware

initialise

public void initialise()
                throws InitialisationException
Description copied from interface: Initialisable
Method used to perform any initialisation work. If a fatal error occurs during initialisation an InitialisationException should be thrown, causing the Mule instance to shutdown. If the error is recoverable, say by retrying to connect, a RecoverableException should be thrown. There is no guarantee that by throwing a Recoverable exception that the Mule instance will not shut down.

Specified by:
initialise in interface Initialisable
Overrides:
initialise in class SchemaValidationFilter
Throws:
InitialisationException - if a fatal error occurs causing the Mule instance to shutdown
RecoverableException - if an error occurs that can be recovered from

setSchemaLocations

public void setSchemaLocations(String schemaLocations)
Specified by:
setSchemaLocations in interface JsonSchemaFilter
Overrides:
setSchemaLocations in class SchemaValidationFilter


Copyright © 2003-2014 MuleSoft, Inc.. All Rights Reserved.