Class 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.
    • Field Summary

      • Fields inherited from class org.apache.camel.support.service.BaseService

        BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
    • 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.SchemaFactory
      void 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 interface org.apache.camel.Endpoint

        getEndpointBaseUri, isSingletonProducer
      • Methods inherited from interface org.apache.camel.Service

        build, close, init, start, stop
      • Methods inherited from interface org.apache.camel.ShutdownableService

        shutdown
      • Methods inherited from interface org.apache.camel.StatefulService

        getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending
      • Methods inherited from interface org.apache.camel.SuspendableService

        isSuspended, resume, suspend
    • Constructor Detail

      • ValidatorEndpoint

        public ValidatorEndpoint()
      • ValidatorEndpoint

        public ValidatorEndpoint​(String endpointUri,
                                 org.apache.camel.Component component,
                                 String resourceUri)
    • Method Detail

      • clearCachedSchema

        @ManagedOperation(description="Clears the cached schema, forcing to re-load the schema on next request")
        public void clearCachedSchema()
      • createProducer

        public org.apache.camel.Producer createProducer()
                                                 throws Exception
        Throws:
        Exception
      • 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.
      • 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.
      • 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.