org.apache.synapse.mediators.builtin
Class ValidateMediator

java.lang.Object
  extended by org.apache.synapse.mediators.AbstractMediator
      extended by org.apache.synapse.mediators.AbstractListMediator
          extended by org.apache.synapse.mediators.builtin.ValidateMediator
All Implemented Interfaces:
AspectConfigurable, ManagedLifecycle, Mediator, ListMediator, SynapseArtifact

public class ValidateMediator
extends AbstractListMediator

Validate a message or an element against a schema

This internally uses the Xerces2-j parser, which cautions a lot about thread-safety and memory leaks. Hence this initial implementation will create a single parser instance for each unique mediator instance, and re-use it to validate multiple messages - even concurrently - by synchronizing access


Field Summary
 
Fields inherited from class org.apache.synapse.mediators.AbstractListMediator
mediators
 
Fields inherited from class org.apache.synapse.mediators.AbstractMediator
log, trace, traceState
 
Constructor Summary
ValidateMediator()
           
 
Method Summary
 void addFeature(String featureName, boolean isFeatureEnable)
          add a feature which need to set for the Schema Factory
 Object getFeature(String key)
          Get a mediator feature.
 List<MediatorProperty> getFeatures()
          Features for the actual Xerces validator
 ResourceMap getResourceMap()
          ResourceMap for the external schema resources to be used for the validation
 List<Value> getSchemaKeys()
          The keys for the schema resources used for validation
 SynapseXPath getSource()
          Get the source XPath which yields the source element for validation
 boolean mediate(MessageContext synCtx)
          Invokes the mediator passing the current message for mediation.
 void setResourceMap(ResourceMap resourceMap)
          Set the External Schema ResourceMap that will required for schema validation
 void setSchemaKeys(List<Value> schemaKeys)
          Set a list of local property names which refer to a list of schemas to be used for validation
 void setSource(SynapseXPath source)
          Set the given XPath as the source XPath
 
Methods inherited from class org.apache.synapse.mediators.AbstractListMediator
addAll, addChild, destroy, getChild, getList, init, removeChild, removeChild
 
Methods inherited from class org.apache.synapse.mediators.AbstractMediator
auditLog, auditWarn, configure, disableStatistics, enableStatistics, getAspectConfiguration, getDescription, getLog, getTraceState, getType, handleException, handleException, isStatisticsEnable, isTraceOn, isTraceOrDebugOn, setDescription, setEffectiveTraceState, setTraceState, shouldTrace, traceOrDebug, traceOrDebugWarn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.synapse.Mediator
getTraceState, getType, setTraceState
 
Methods inherited from interface org.apache.synapse.SynapseArtifact
getDescription, setDescription
 

Constructor Detail

ValidateMediator

public ValidateMediator()
Method Detail

mediate

public boolean mediate(MessageContext synCtx)
Description copied from interface: Mediator
Invokes the mediator passing the current message for mediation. Each mediator performs its mediation action, and returns true if mediation should continue, or false if further mediation should be aborted.

Specified by:
mediate in interface Mediator
Overrides:
mediate in class AbstractListMediator
Parameters:
synCtx - the current message for mediation
Returns:
true if further mediation should continue

getFeature

public Object getFeature(String key)
Get a mediator feature. The common use case is a feature for the underlying Xerces validator

Parameters:
key - property key / feature name
Returns:
property string value (usually true|false)

addFeature

public void addFeature(String featureName,
                       boolean isFeatureEnable)
                throws SAXException
add a feature which need to set for the Schema Factory

Parameters:
featureName - The name of the feature
isFeatureEnable - should this feature enable?(true|false)
Throws:
SAXException - on an unknown feature
See Also:
getFeature(String)

setSchemaKeys

public void setSchemaKeys(List<Value> schemaKeys)
Set a list of local property names which refer to a list of schemas to be used for validation

Parameters:
schemaKeys - list of local property names

setSource

public void setSource(SynapseXPath source)
Set the given XPath as the source XPath

Parameters:
source - an XPath to be set as the source

setResourceMap

public void setResourceMap(ResourceMap resourceMap)
Set the External Schema ResourceMap that will required for schema validation

Parameters:
resourceMap - the ResourceMap which contains external schema resources

getSource

public SynapseXPath getSource()
Get the source XPath which yields the source element for validation

Returns:
the XPath which yields the source element for validation

getSchemaKeys

public List<Value> getSchemaKeys()
The keys for the schema resources used for validation

Returns:
schema registry keys

getFeatures

public List<MediatorProperty> getFeatures()
Features for the actual Xerces validator

Returns:
explicityFeatures to be passed to the Xerces validator

getResourceMap

public ResourceMap getResourceMap()
ResourceMap for the external schema resources to be used for the validation

Returns:
the ResourceMap with external schema resources


Copyright © 2005-2012 Apache Software Foundation. All Rights Reserved.