Package org.apache.camel.model.rest
Class RestBindingDefinition
- java.lang.Object
-
- org.apache.camel.model.OptionalIdentifiedDefinition<RestBindingDefinition>
-
- org.apache.camel.model.rest.RestBindingDefinition
-
- All Implemented Interfaces:
org.apache.camel.CamelContextAware
,org.apache.camel.LineNumberAware
,org.apache.camel.NamedNode
,org.apache.camel.spi.HasId
,org.apache.camel.spi.IdAware
@Metadata(label="rest") public class RestBindingDefinition extends OptionalIdentifiedDefinition<RestBindingDefinition>
To configure rest binding
-
-
Constructor Summary
Constructors Constructor Description RestBindingDefinition()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDefaultValue(String paramName, String defaultValue)
Adds a default value for the query parametervoid
addRequiredHeader(String headerName)
Adds a required HTTP headervoid
addRequiredQueryParameter(String paramName)
Adds a required query parameterString
getBindingMode()
String
getClientRequestValidation()
String
getComponent()
String
getConsumes()
Map<String,String>
getDefaultValues()
Gets the registered default values for query parametersString
getEnableCORS()
String
getLabel()
String
getOutType()
Class<?>
getOutTypeClass()
String
getProduces()
Boolean
getRequiredBody()
Set<String>
getRequiredHeaders()
Set<String>
getRequiredQueryParameters()
String
getShortName()
String
getSkipBindingOnErrorCode()
String
getType()
Class<?>
getTypeClass()
void
setBindingMode(String bindingMode)
Sets the binding mode to use.void
setClientRequestValidation(String clientRequestValidation)
Whether to enable validation of the client request to check: 1) Content-Type header matches what the Rest DSL consumes; returns HTTP Status 415 if validation error.void
setComponent(String component)
Sets the component name that this definition will apply tovoid
setConsumes(String consumes)
To define the content type what the REST service consumes (accept as input), such as application/xml or application/jsonvoid
setEnableCORS(String enableCORS)
Whether to enable CORS headers in the HTTP response.void
setOutType(String outType)
Sets the class name to use for binding from POJO to output for the outgoing datavoid
setOutTypeClass(Class<?> outTypeClass)
Sets the class name to use for binding from POJO to output for the outgoing datavoid
setProduces(String produces)
To define the content type what the REST service produces (uses for output), such as application/xml or application/jsonvoid
setRequiredBody(Boolean requiredBody)
void
setSkipBindingOnErrorCode(String skipBindingOnErrorCode)
Whether to skip binding on output if there is a custom HTTP error code header.void
setType(String type)
Sets the class name to use for binding from input to POJO for the incoming datavoid
setTypeClass(Class<?> typeClass)
Sets the class to use for binding from input to POJO for the incoming dataString
toString()
-
Methods inherited from class org.apache.camel.model.OptionalIdentifiedDefinition
description, description, getCamelContext, getCustomId, getDescription, getDescriptionText, getId, getLineNumber, getLocation, getParent, hasCustomIdAssigned, id, idOrCreate, setCamelContext, setCustomId, setDescription, setGeneratedId, setId, setLineNumber, setLocation
-
-
-
-
Method Detail
-
getConsumes
public String getConsumes()
-
addDefaultValue
public void addDefaultValue(String paramName, String defaultValue)
Adds a default value for the query parameter- Parameters:
paramName
- query parameter namedefaultValue
- the default value
-
addRequiredQueryParameter
public void addRequiredQueryParameter(String paramName)
Adds a required query parameter- Parameters:
paramName
- query parameter name
-
addRequiredHeader
public void addRequiredHeader(String headerName)
Adds a required HTTP header- Parameters:
headerName
- HTTP header name
-
getRequiredBody
public Boolean getRequiredBody()
-
setRequiredBody
public void setRequiredBody(Boolean requiredBody)
-
getDefaultValues
public Map<String,String> getDefaultValues()
Gets the registered default values for query parameters
-
setComponent
public void setComponent(String component)
Sets the component name that this definition will apply to
-
getComponent
public String getComponent()
-
setConsumes
public void setConsumes(String consumes)
To define the content type what the REST service consumes (accept as input), such as application/xml or application/json
-
getProduces
public String getProduces()
-
setProduces
public void setProduces(String produces)
To define the content type what the REST service produces (uses for output), such as application/xml or application/json
-
getBindingMode
public String getBindingMode()
-
setBindingMode
public void setBindingMode(String bindingMode)
Sets the binding mode to use. The default value is off
-
getType
public String getType()
-
setType
public void setType(String type)
Sets the class name to use for binding from input to POJO for the incoming data The name of the class of the input data. Append a [] to the end of the name if you want the input to be an array type.
-
getTypeClass
public Class<?> getTypeClass()
-
setTypeClass
public void setTypeClass(Class<?> typeClass)
Sets the class to use for binding from input to POJO for the incoming data
-
getOutType
public String getOutType()
-
setOutType
public void setOutType(String outType)
Sets the class name to use for binding from POJO to output for the outgoing data The name of the class of the input data. Append a [] to the end of the name if you want the input to be an array type.
-
getOutTypeClass
public Class<?> getOutTypeClass()
-
setOutTypeClass
public void setOutTypeClass(Class<?> outTypeClass)
Sets the class name to use for binding from POJO to output for the outgoing data
-
getSkipBindingOnErrorCode
public String getSkipBindingOnErrorCode()
-
setSkipBindingOnErrorCode
public void setSkipBindingOnErrorCode(String skipBindingOnErrorCode)
Whether to skip binding on output if there is a custom HTTP error code header. This allows to build custom error messages that do not bind to json / xml etc, as success messages otherwise will do.
-
getClientRequestValidation
public String getClientRequestValidation()
-
setClientRequestValidation
public void setClientRequestValidation(String clientRequestValidation)
Whether to enable validation of the client request to check: 1) Content-Type header matches what the Rest DSL consumes; returns HTTP Status 415 if validation error. 2) Accept header matches what the Rest DSL produces; returns HTTP Status 406 if validation error. 3) Missing required data (query parameters, HTTP headers, body); returns HTTP Status 400 if validation error. 4) Parsing error of the message body (JSon, XML or Auto binding mode must be enabled); returns HTTP Status 400 if validation error.
-
getEnableCORS
public String getEnableCORS()
-
setEnableCORS
public void setEnableCORS(String enableCORS)
Whether to enable CORS headers in the HTTP response. The default value is false.
-
getShortName
public String getShortName()
-
getLabel
public String getLabel()
-
-