Class ValidateMediator
- java.lang.Object
-
- org.apache.synapse.mediators.AbstractMediator
-
- org.apache.synapse.mediators.AbstractListMediator
-
- org.apache.synapse.mediators.builtin.ValidateMediator
-
- All Implemented Interfaces:
AspectConfigurable,ManagedLifecycle,Mediator,FlowContinuableMediator,ListMediator,SynapseArtifact
public class ValidateMediator extends AbstractListMediator implements FlowContinuableMediator
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, msgBuildFailureExpattern
-
Fields inherited from class org.apache.synapse.mediators.AbstractMediator
log, trace, traceState
-
-
Constructor Summary
Constructors Constructor Description ValidateMediator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFeature(String featureName, boolean isFeatureEnable)add a feature which need to set for the Schema FactoryObjectgetFeature(String key)Get a mediator feature.List<MediatorProperty>getFeatures()Features for the actual Xerces validatorResourceMapgetResourceMap()ResourceMap for the external schema resources to be used for the validationList<Value>getSchemaKeys()The keys for the schema resources used for validationSynapsePathgetSource()Get the source XPath which yields the source element for validationvoidinit(SynapseEnvironment synapseEnvironment)Initialize child mediators recursivelybooleanisCacheSchema()Check whether to cahce the schemas.booleanisContentAware()booleanmediate(MessageContext synCtx)Invokes the mediator passing the current message for mediation.booleanmediate(MessageContext synCtx, ContinuationState continuationState)Mediate the message using a ContinuationState.voidsetCacheSchema(boolean cacheSchema)Set whether schema need to cache or not.voidsetComponentStatisticsId(ArtifactHolder holder)voidsetResourceMap(ResourceMap resourceMap)Set the External Schema ResourceMap that will required for schema validationvoidsetSchemaKeys(List<Value> schemaKeys)Set a list of local property names which refer to a list of schemas to be used for validationvoidsetSource(SynapsePath source)Set the given XPath as the source XPath-
Methods inherited from class org.apache.synapse.mediators.AbstractListMediator
addAll, addChild, addChild, destroy, getChild, getList, mediate, removeChild, removeChild, setStatisticIdForMediators
-
Methods inherited from class org.apache.synapse.mediators.AbstractMediator
auditLog, auditWarn, configure, disableStatistics, disableTracing, divertMediationRoute, enableStatistics, enableTracing, getAspectConfiguration, getCommentsList, getDescription, getInputType, getLastSequenceFaultHandler, getLog, getMediatorName, getMediatorPosition, getOutputType, getRegisteredMediationFlowPoint, getShortDescription, getTraceState, getType, handleException, handleException, isBreakPoint, isContentAltering, isSkipEnabled, isStatisticsEnable, isTraceOn, isTraceOrDebugOn, isTracingEnabled, registerMediationFlowPoint, reportCloseStatistics, reportOpenStatistics, setBreakPoint, setCommentsList, setDescription, setEffectiveTraceState, setMediatorPosition, setShortDescription, setSkipEnabled, setTraceState, shouldCaptureTracing, shouldTrace, shouldTrace, traceOrDebug, traceOrDebugWarn, unregisterMediationFlowPoint
-
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
getMediatorName, getMediatorPosition, getShortDescription, getTraceState, getType, isContentAltering, reportCloseStatistics, reportOpenStatistics, setMediatorPosition, setShortDescription, setTraceState
-
Methods inherited from interface org.apache.synapse.SynapseArtifact
getDescription, setDescription
-
-
-
-
Method Detail
-
mediate
public boolean mediate(MessageContext synCtx)
Description copied from interface:MediatorInvokes 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:
mediatein interfaceMediator- Overrides:
mediatein classAbstractListMediator- Parameters:
synCtx- the current message for mediation- Returns:
- true if further mediation should continue
-
mediate
public boolean mediate(MessageContext synCtx, ContinuationState continuationState)
Description copied from interface:FlowContinuableMediatorMediate the message using a ContinuationState. This is used when mediating the response message when service is invoked using a Call Mediator.- Specified by:
mediatein interfaceFlowContinuableMediator- Parameters:
synCtx- MessageContextcontinuationState- ContinuationState- Returns:
- whether mediation flow is completed
-
init
public void init(SynapseEnvironment synapseEnvironment)
Description copied from class:AbstractListMediatorInitialize child mediators recursively- Specified by:
initin interfaceManagedLifecycle- Overrides:
initin classAbstractListMediator- Parameters:
synapseEnvironment- synapse environment
-
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 featureisFeatureEnable- 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(SynapsePath 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 SynapsePath 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
-
setCacheSchema
public void setCacheSchema(boolean cacheSchema)
Set whether schema need to cache or not.- Parameters:
cacheSchema- cache the schema or not.
-
isCacheSchema
public boolean isCacheSchema()
Check whether to cahce the schemas.- Returns:
- whether to cache or not.
-
isContentAware
public boolean isContentAware()
- Specified by:
isContentAwarein interfaceMediator- Overrides:
isContentAwarein classAbstractListMediator
-
setComponentStatisticsId
public void setComponentStatisticsId(ArtifactHolder holder)
- Specified by:
setComponentStatisticsIdin interfaceMediator- Overrides:
setComponentStatisticsIdin classAbstractMediator
-
-