Class ValidatorEndpoint
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.support.DefaultEndpoint
-
- org.apache.camel.component.validator.ValidatorEndpoint
-
- All Implemented Interfaces:
AutoCloseable
,org.apache.camel.CamelContextAware
,org.apache.camel.Endpoint
,org.apache.camel.IsSingleton
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.spi.HasId
,org.apache.camel.StatefulService
,org.apache.camel.SuspendableService
@ManagedResource(description="Managed ValidatorEndpoint") @UriEndpoint(firstVersion="1.1.0", scheme="validator", title="Validator", syntax="validator:resourceUri", producerOnly=true, category={CORE,VALIDATION}) public class ValidatorEndpoint extends org.apache.camel.support.DefaultEndpoint
Validate the payload using XML Schema and JAXP Validation.
-
-
Constructor Summary
Constructors Constructor Description ValidatorEndpoint()
ValidatorEndpoint(String endpointUri, org.apache.camel.Component component, String resourceUri)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearCachedSchema()
protected void
configureValidator(org.apache.camel.support.processor.validation.ValidatingProcessor validator)
org.apache.camel.Consumer
createConsumer(org.apache.camel.Processor processor)
org.apache.camel.Producer
createProducer()
org.apache.camel.support.processor.validation.ValidatorErrorHandler
getErrorHandler()
String
getHeaderName()
LSResourceResolver
getResourceResolver()
ValidatorResourceResolverFactory
getResourceResolverFactory()
String
getResourceUri()
SchemaFactory
getSchemaFactory()
String
getSchemaLanguage()
boolean
isFailOnNullBody()
boolean
isFailOnNullHeader()
boolean
isUseSharedSchema()
void
setErrorHandler(org.apache.camel.support.processor.validation.ValidatorErrorHandler errorHandler)
To use a custom org.apache.camel.processor.validation.ValidatorErrorHandler.void
setFailOnNullBody(boolean failOnNullBody)
Whether to fail if no body exists.void
setFailOnNullHeader(boolean failOnNullHeader)
Whether to fail if no header exists when validating against a header.void
setHeaderName(String headerName)
To validate against a header instead of the message body.void
setResourceResolver(LSResourceResolver resourceResolver)
To use a custom LSResourceResolver.void
setResourceResolverFactory(ValidatorResourceResolverFactory resourceResolverFactory)
For creating a resource resolver which depends on the endpoint resource URI.void
setResourceUri(String resourceUri)
URL to a local resource on the classpath,or a reference to lookup a bean in the Registry, or a full URL to a remote resource or resource on the file system which contains the XSD to validate against.void
setSchemaFactory(SchemaFactory schemaFactory)
To use a custom javax.xml.validation.SchemaFactoryvoid
setSchemaLanguage(String schemaLanguage)
Configures the W3C XML Schema Namespace URI.void
setUseSharedSchema(boolean useSharedSchema)
Whether the Schema instance should be shared or not.-
Methods inherited from class org.apache.camel.support.DefaultEndpoint
configureConsumer, configureExchange, configurePollingConsumer, configureProperties, createAsyncProducer, createEndpointUri, createExchange, createExchange, createPollingConsumer, doInit, doStart, doStop, equals, getCamelContext, getComponent, getEndpointKey, getEndpointUri, getExceptionHandler, getExchangePattern, getId, getPollingConsumerBlockTimeout, getPollingConsumerQueueSize, hashCode, isAutowiredEnabled, isBridgeErrorHandler, isLazyStartProducer, isLenientProperties, isPollingConsumerBlockWhenFull, isPollingConsumerCopy, isSingleton, setAutowiredEnabled, setBridgeErrorHandler, setCamelContext, setComponent, setEndpointUri, setEndpointUriIfNotSpecified, setExceptionHandler, setExchangePattern, setLazyStartProducer, setPollingConsumerBlockTimeout, setPollingConsumerBlockWhenFull, setPollingConsumerCopy, setPollingConsumerQueueSize, setProperties, toString
-
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
-
-
-
Method Detail
-
clearCachedSchema
@ManagedOperation(description="Clears the cached schema, forcing to re-load the schema on next request") public void clearCachedSchema()
-
createConsumer
public org.apache.camel.Consumer createConsumer(org.apache.camel.Processor processor) throws Exception
- Throws:
Exception
-
configureValidator
protected void configureValidator(org.apache.camel.support.processor.validation.ValidatingProcessor validator) throws Exception
- Throws:
Exception
-
getResourceUri
public String getResourceUri()
-
setResourceUri
public void setResourceUri(String resourceUri)
URL to a local resource on the classpath,or a reference to lookup a bean in the Registry, or a full URL to a remote resource or resource on the file system which contains the XSD to validate against.
-
getSchemaLanguage
public String getSchemaLanguage()
-
setSchemaLanguage
public void setSchemaLanguage(String schemaLanguage)
Configures the W3C XML Schema Namespace URI.
-
getSchemaFactory
public SchemaFactory getSchemaFactory()
-
setSchemaFactory
public void setSchemaFactory(SchemaFactory schemaFactory)
To use a custom javax.xml.validation.SchemaFactory
-
getErrorHandler
public org.apache.camel.support.processor.validation.ValidatorErrorHandler getErrorHandler()
-
setErrorHandler
public void setErrorHandler(org.apache.camel.support.processor.validation.ValidatorErrorHandler errorHandler)
To use a custom org.apache.camel.processor.validation.ValidatorErrorHandler. The default error handler captures the errors and throws an exception.
-
isUseSharedSchema
public boolean isUseSharedSchema()
-
setUseSharedSchema
public void setUseSharedSchema(boolean useSharedSchema)
Whether the Schema instance should be shared or not. This option is introduced to work around a JDK 1.6.x bug. Xerces should not have this issue.
-
getResourceResolver
public LSResourceResolver getResourceResolver()
-
setResourceResolver
public void setResourceResolver(LSResourceResolver resourceResolver)
To use a custom LSResourceResolver. See alsosetResourceResolverFactory(ValidatorResourceResolverFactory)
-
getResourceResolverFactory
public ValidatorResourceResolverFactory getResourceResolverFactory()
-
setResourceResolverFactory
public void setResourceResolverFactory(ValidatorResourceResolverFactory resourceResolverFactory)
For creating a resource resolver which depends on the endpoint resource URI. Must not be used in combination with methodsetResourceResolver(LSResourceResolver)
. If not set thenDefaultValidatorResourceResolverFactory
is used
-
isFailOnNullBody
public boolean isFailOnNullBody()
-
setFailOnNullBody
public void setFailOnNullBody(boolean failOnNullBody)
Whether to fail if no body exists.
-
isFailOnNullHeader
public boolean isFailOnNullHeader()
-
setFailOnNullHeader
public void setFailOnNullHeader(boolean failOnNullHeader)
Whether to fail if no header exists when validating against a header.
-
getHeaderName
public String getHeaderName()
-
setHeaderName
public void setHeaderName(String headerName)
To validate against a header instead of the message body.
-
-