Package org.apache.camel.spi
Class Validator
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.spi.Validator
-
- All Implemented Interfaces:
AutoCloseable
,CamelContextAware
,Service
,ShutdownableService
,StatefulService
,SuspendableService
public abstract class Validator extends ServiceSupport implements CamelContextAware
Validator performs message content validation according to the declared data type.org.apache.camel.processor.ContractAdvice
applies Validator if input/output type is declared on a route with validation enabled.
-
-
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
-
-
Constructor Summary
Constructors Constructor Description Validator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
doStart()
Implementations override this method to support customized start/stop.protected void
doStop()
Implementations override this method to support customized start/stop.CamelContext
getCamelContext()
Get theCamelContext
DataType
getType()
Get 'from' data type.void
setCamelContext(CamelContext context)
Injects theCamelContext
Validator
setType(String type)
Set data type.String
toString()
abstract void
validate(Message message, DataType type)
Perform data validation with specified type.-
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, 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, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
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
-
-
-
-
Method Detail
-
validate
public abstract void validate(Message message, DataType type) throws ValidationException
Perform data validation with specified type.- Parameters:
message
- message to apply validationtype
- the data type- Throws:
ValidationException
- thrown if any validation error is detected
-
getType
public DataType getType()
Get 'from' data type.
-
getCamelContext
public CamelContext getCamelContext()
Description copied from interface:CamelContextAware
Get theCamelContext
- Specified by:
getCamelContext
in interfaceCamelContextAware
- Returns:
- the Camel context
-
setCamelContext
public void setCamelContext(CamelContext context)
Description copied from interface:CamelContextAware
Injects theCamelContext
- Specified by:
setCamelContext
in interfaceCamelContextAware
- Parameters:
context
- the Camel context
-
doStart
protected void doStart() throws Exception
Description copied from class:BaseService
Implementations override this method to support customized start/stop. Important: SeeBaseService.doStop()
for more details.- Overrides:
doStart
in classBaseService
- Throws:
Exception
- See Also:
BaseService.doStop()
-
doStop
protected void doStop() throws Exception
Description copied from class:BaseService
Implementations override this method to support customized start/stop. Important: Camel will invoke thisBaseService.doStop()
method when the service is being stopped. This method will also be invoked if the service is still in uninitialized state (eg has not been started). The method is always called to allow the service to do custom logic when the service is being stopped, such as whenCamelContext
is shutting down.- Overrides:
doStop
in classBaseService
- Throws:
Exception
- See Also:
BaseService.doStart()
-
-