Package org.apache.camel.component.rest
Class RestEndpoint
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.support.DefaultEndpoint
-
- org.apache.camel.component.rest.RestEndpoint
-
- 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
@UriEndpoint(firstVersion="2.14.0", scheme="rest", title="REST", syntax="rest:method:path:uriTemplate", category={CORE,REST}, lenientProperties=true, headersClass=RestConstants.class) public class RestEndpoint extends org.apache.camel.support.DefaultEndpointExpose REST services or call external REST services.
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_API_COMPONENT_NAMEstatic String[]DEFAULT_REST_CONSUMER_COMPONENTSstatic String[]DEFAULT_REST_PRODUCER_COMPONENTSstatic StringRESOURCE_PATH
-
Constructor Summary
Constructors Constructor Description RestEndpoint(String endpointUri, RestComponent component)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigureProperties(Map<String,Object> options)org.apache.camel.ConsumercreateConsumer(org.apache.camel.Processor processor)org.apache.camel.ProducercreateProducer()StringgetApiDoc()org.apache.camel.spi.RestConfiguration.RestBindingModegetBindingMode()RestComponentgetComponent()StringgetConsumerComponentName()StringgetConsumes()StringgetDescription()StringgetHost()StringgetInType()StringgetMethod()StringgetOutType()Map<String,Object>getParameters()StringgetPath()StringgetProducerComponentName()StringgetProduces()StringgetQueryParameters()StringgetRouteId()StringgetUriTemplate()booleanisLenientProperties()voidsetApiDoc(String apiDoc)The openapi api doc resource to use.voidsetBindingMode(String bindingMode)voidsetBindingMode(org.apache.camel.spi.RestConfiguration.RestBindingMode bindingMode)Configures the binding mode for the producer.voidsetConsumerComponentName(String consumerComponentName)The Camel Rest component to use for the consumer REST transport, such as jetty, servlet, undertow.voidsetConsumes(String consumes)Media type such as: 'text/xml', or 'application/json' this REST service accepts.voidsetDescription(String description)Human description to document this REST servicevoidsetHost(String host)Host and port of HTTP service to use (override host in openapi schema)voidsetInType(String inType)To declare the incoming POJO binding type as a FQN class namevoidsetMethod(String method)HTTP method to use.voidsetOutType(String outType)To declare the outgoing POJO binding type as a FQN class namevoidsetParameters(Map<String,Object> parameters)Additional parameters to configure the consumer of the REST transport for this REST servicevoidsetPath(String path)The base pathvoidsetProducerComponentName(String producerComponentName)The Camel Rest component to use for the producer REST transport, such as http, undertow.voidsetProduces(String produces)Media type such as: 'text/xml', or 'application/json' this REST service returns.voidsetQueryParameters(String queryParameters)Query parameters for the HTTP service to call.voidsetRouteId(String routeId)Name of the route this REST services createsvoidsetUriTemplate(String uriTemplate)The uri template-
Methods inherited from class org.apache.camel.support.DefaultEndpoint
configureConsumer, configureExchange, configurePollingConsumer, createAsyncProducer, createEndpointUri, createExchange, createExchange, createPollingConsumer, doInit, doStart, doStop, equals, getCamelContext, getEndpointKey, getEndpointUri, getExceptionHandler, getExchangePattern, getId, getPollingConsumerBlockTimeout, getPollingConsumerQueueSize, hashCode, isAutowiredEnabled, isBridgeErrorHandler, isLazyStartProducer, 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
-
-
-
-
Field Detail
-
DEFAULT_REST_CONSUMER_COMPONENTS
public static final String[] DEFAULT_REST_CONSUMER_COMPONENTS
-
DEFAULT_REST_PRODUCER_COMPONENTS
public static final String[] DEFAULT_REST_PRODUCER_COMPONENTS
-
DEFAULT_API_COMPONENT_NAME
public static final String DEFAULT_API_COMPONENT_NAME
- See Also:
- Constant Field Values
-
RESOURCE_PATH
public static final String RESOURCE_PATH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RestEndpoint
public RestEndpoint(String endpointUri, RestComponent component)
-
-
Method Detail
-
configureProperties
public void configureProperties(Map<String,Object> options)
- Specified by:
configurePropertiesin interfaceorg.apache.camel.Endpoint- Overrides:
configurePropertiesin classorg.apache.camel.support.DefaultEndpoint
-
getComponent
public RestComponent getComponent()
- Overrides:
getComponentin classorg.apache.camel.support.DefaultEndpoint
-
getMethod
public String getMethod()
-
setMethod
public void setMethod(String method)
HTTP method to use.
-
getPath
public String getPath()
-
setPath
public void setPath(String path)
The base path
-
getUriTemplate
public String getUriTemplate()
-
setUriTemplate
public void setUriTemplate(String uriTemplate)
The uri template
-
getConsumes
public String getConsumes()
-
setConsumes
public void setConsumes(String consumes)
Media type such as: 'text/xml', or 'application/json' this REST service accepts. By default we accept all kinds of types.
-
getProduces
public String getProduces()
-
setProduces
public void setProduces(String produces)
Media type such as: 'text/xml', or 'application/json' this REST service returns.
-
getProducerComponentName
public String getProducerComponentName()
-
setProducerComponentName
public void setProducerComponentName(String producerComponentName)
The Camel Rest component to use for the producer REST transport, such as http, undertow. If no component has been explicitly configured, then Camel will lookup if there is a Camel component that integrates with the Rest DSL, or if a org.apache.camel.spi.RestProducerFactory is registered in the registry. If either one is found, then that is being used.
-
getConsumerComponentName
public String getConsumerComponentName()
-
setConsumerComponentName
public void setConsumerComponentName(String consumerComponentName)
The Camel Rest component to use for the consumer REST transport, such as jetty, servlet, undertow. If no component has been explicitly configured, then Camel will lookup if there is a Camel component that integrates with the Rest DSL, or if a org.apache.camel.spi.RestConsumerFactory is registered in the registry. If either one is found, then that is being used.
-
getInType
public String getInType()
-
setInType
public void setInType(String inType)
To declare the incoming POJO binding type as a FQN class name
-
getOutType
public String getOutType()
-
setOutType
public void setOutType(String outType)
To declare the outgoing POJO binding type as a FQN class name
-
getRouteId
public String getRouteId()
-
setRouteId
public void setRouteId(String routeId)
Name of the route this REST services creates
-
getDescription
public String getDescription()
-
setDescription
public void setDescription(String description)
Human description to document this REST service
-
setParameters
public void setParameters(Map<String,Object> parameters)
Additional parameters to configure the consumer of the REST transport for this REST service
-
getApiDoc
public String getApiDoc()
-
setApiDoc
public void setApiDoc(String apiDoc)
The openapi api doc resource to use. The resource is loaded from classpath by default and must be in JSON format.
-
getHost
public String getHost()
-
setHost
public void setHost(String host)
Host and port of HTTP service to use (override host in openapi schema)
-
getQueryParameters
public String getQueryParameters()
-
setQueryParameters
public void setQueryParameters(String queryParameters)
Query parameters for the HTTP service to call. The query parameters can contain multiple parameters separated by ampersand such such as foo=123&bar=456.
-
getBindingMode
public org.apache.camel.spi.RestConfiguration.RestBindingMode getBindingMode()
-
setBindingMode
public void setBindingMode(org.apache.camel.spi.RestConfiguration.RestBindingMode bindingMode)
Configures the binding mode for the producer. If set to anything other than 'off' the producer will try to convert the body of the incoming message from inType to the json or xml, and the response from json or xml to outType.
-
setBindingMode
public void setBindingMode(String bindingMode)
-
createConsumer
public org.apache.camel.Consumer createConsumer(org.apache.camel.Processor processor) throws Exception- Throws:
Exception
-
isLenientProperties
public boolean isLenientProperties()
- Specified by:
isLenientPropertiesin interfaceorg.apache.camel.Endpoint- Overrides:
isLenientPropertiesin classorg.apache.camel.support.DefaultEndpoint
-
-