Package org.apache.camel.component.http
Class HttpComponent
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.support.DefaultComponent
-
- org.apache.camel.support.HeaderFilterStrategyComponent
-
- org.apache.camel.http.common.HttpCommonComponent
-
- org.apache.camel.component.http.HttpComponent
-
- All Implemented Interfaces:
AutoCloseable,org.apache.camel.CamelContextAware,org.apache.camel.Component,org.apache.camel.Service,org.apache.camel.ShutdownableService,org.apache.camel.spi.HeaderFilterStrategyAware,org.apache.camel.spi.RestProducerFactory,org.apache.camel.SSLContextParametersAware,org.apache.camel.StatefulService,org.apache.camel.SuspendableService
@Metadata(label="verifiers", enums="parameters,connectivity") @Component("http,https") public class HttpComponent extends org.apache.camel.http.common.HttpCommonComponent implements org.apache.camel.spi.RestProducerFactory, org.apache.camel.SSLContextParametersAwareDefines the HTTP Component
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.http.conn.HttpClientConnectionManagerclientConnectionManagerprotected intconnectionRequestTimeoutprotected intconnectionsPerRouteprotected longconnectionTimeToLiveprotected intconnectTimeoutprotected org.apache.http.client.CookieStorecookieStoreprotected HttpClientConfigurerhttpClientConfigurerprotected org.apache.http.protocol.HttpContexthttpContextprotected intmaxTotalConnectionsprotected intsocketTimeoutprotected org.apache.camel.support.jsse.SSLContextParameterssslContextParametersprotected HostnameVerifierx509HostnameVerifier
-
Constructor Summary
Constructors Constructor Description HttpComponent()HttpComponent(Class<? extends HttpEndpoint> endpointClass)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.apache.http.conn.HttpClientConnectionManagercreateConnectionManager(Map<String,Object> parameters, org.apache.camel.support.jsse.SSLContextParameters sslContextParameters)protected org.apache.http.conn.HttpClientConnectionManagercreateConnectionManager(org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> registry)protected org.apache.http.conn.HttpClientConnectionManagercreateConnectionManager(org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> registry, int maxTotalConnections, int connectionsPerRoute)protected org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory>createConnectionRegistry(HostnameVerifier x509HostnameVerifier, org.apache.camel.support.jsse.SSLContextParameters sslContextParams)protected org.apache.camel.EndpointcreateEndpoint(String uri, String remaining, Map<String,Object> parameters)protected org.apache.http.impl.client.HttpClientBuildercreateHttpClientBuilder(String uri, Map<String,Object> parameters, Map<String,Object> httpClientOptions)protected HttpClientConfigurercreateHttpClientConfigurer(Map<String,Object> parameters, boolean secure)Creates the HttpClientConfigurer based on the given parametersorg.apache.camel.ProducercreateProducer(org.apache.camel.CamelContext camelContext, String host, String verb, String basePath, String uriTemplate, String queryParameters, String consumes, String produces, org.apache.camel.spi.RestConfiguration configuration, Map<String,Object> parameters)voiddoStart()voiddoStop()org.apache.http.conn.HttpClientConnectionManagergetClientConnectionManager()intgetConnectionRequestTimeout()intgetConnectionsPerRoute()longgetConnectionTimeToLive()intgetConnectTimeout()org.apache.http.client.CookieStoregetCookieStore()HttpClientConfigurergetHttpClientConfigurer()org.apache.http.protocol.HttpContextgetHttpContext()intgetMaxTotalConnections()intgetSocketTimeout()org.apache.camel.support.jsse.SSLContextParametersgetSslContextParameters()org.apache.camel.component.extension.ComponentVerifierExtensiongetVerifier()HostnameVerifiergetX509HostnameVerifier()booleanisUseGlobalSslContextParameters()voidsetClientConnectionManager(org.apache.http.conn.HttpClientConnectionManager clientConnectionManager)To use a custom and shared HttpClientConnectionManager to manage connections.voidsetConnectionRequestTimeout(int connectionRequestTimeout)The timeout in milliseconds used when requesting a connection from the connection manager.voidsetConnectionsPerRoute(int connectionsPerRoute)The maximum number of connections per route.voidsetConnectionTimeToLive(long connectionTimeToLive)The time for connection to live, the time unit is millisecond, the default value is always keep alive.voidsetConnectTimeout(int connectTimeout)Determines the timeout in milliseconds until a connection is established.voidsetCookieStore(org.apache.http.client.CookieStore cookieStore)To use a custom org.apache.http.client.CookieStore.voidsetHttpClientConfigurer(HttpClientConfigurer httpClientConfigurer)To use the custom HttpClientConfigurer to perform configuration of the HttpClient that will be used.voidsetHttpContext(org.apache.http.protocol.HttpContext httpContext)To use a custom org.apache.http.protocol.HttpContext when executing requests.voidsetMaxTotalConnections(int maxTotalConnections)The maximum number of connections.voidsetSocketTimeout(int socketTimeout)Defines the socket timeout (SO_TIMEOUT) in milliseconds, which is the timeout for waiting for data or, put differently, a maximum period inactivity between two consecutive data packets).voidsetSslContextParameters(org.apache.camel.support.jsse.SSLContextParameters sslContextParameters)To configure security using SSLContextParameters.voidsetUseGlobalSslContextParameters(boolean useGlobalSslContextParameters)Enable usage of global SSL context parameters.voidsetX509HostnameVerifier(HostnameVerifier x509HostnameVerifier)To use a custom X509HostnameVerifier such as DefaultHostnameVerifier or NoopHostnameVerifier.protected booleanuseIntrospectionOnEndpoint()-
Methods inherited from class org.apache.camel.http.common.HttpCommonComponent
canConnect, connect, disconnect, getHttpBinding, getHttpConfiguration, getParameter, getParameter, isAllowJavaSerializedObject, setAllowJavaSerializedObject, setHttpBinding, setHttpConfiguration
-
Methods inherited from class org.apache.camel.support.HeaderFilterStrategyComponent
getHeaderFilterStrategy, setEndpointHeaderFilterStrategy, setHeaderFilterStrategy
-
Methods inherited from class org.apache.camel.support.DefaultComponent
afterConfiguration, createEndpoint, createEndpoint, doBuild, getAndRemoveOrResolveReferenceParameter, getAndRemoveOrResolveReferenceParameter, getAndRemoveParameter, getAndRemoveParameter, getCamelContext, getComponentPropertyConfigurer, getEndpointPropertyConfigurer, getExtension, getSupportedExtensions, ifStartsWithReturnRemainder, isBasicPropertyBinding, isBridgeErrorHandler, isLazyStartProducer, registerExtension, registerExtension, resolveAndRemoveReferenceListParameter, resolveAndRemoveReferenceListParameter, resolveAndRemoveReferenceParameter, resolveAndRemoveReferenceParameter, setBasicPropertyBinding, setBridgeErrorHandler, setCamelContext, setLazyStartProducer, setProperties, setProperties, setProperties, useRawUri, validateParameters, validateURI
-
Methods inherited from class org.apache.camel.support.service.BaseService
build, 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, toString, wait, wait, wait
-
Methods inherited from interface org.apache.camel.CamelContextAware
getCamelContext, setCamelContext
-
Methods inherited from interface org.apache.camel.SSLContextParametersAware
retrieveGlobalSslContextParameters
-
-
-
-
Field Detail
-
httpClientConfigurer
@Metadata(label="advanced", description="To use the custom HttpClientConfigurer to perform configuration of the HttpClient that will be used.") protected HttpClientConfigurer httpClientConfigurer
-
clientConnectionManager
@Metadata(label="advanced", description="To use a custom and shared HttpClientConnectionManager to manage connections. If this has been configured then this is always used for all endpoints created by this component.") protected org.apache.http.conn.HttpClientConnectionManager clientConnectionManager
-
httpContext
@Metadata(label="advanced", description="To use a custom org.apache.http.protocol.HttpContext when executing requests.") protected org.apache.http.protocol.HttpContext httpContext
-
sslContextParameters
@Metadata(label="security", description="To configure security using SSLContextParameters. Important: Only one instance of org.apache.camel.support.jsse.SSLContextParameters is supported per HttpComponent. If you need to use 2 or more different instances, you need to define a new HttpComponent per instance you need.") protected org.apache.camel.support.jsse.SSLContextParameters sslContextParameters
-
x509HostnameVerifier
@Metadata(label="security", description="To use a custom X509HostnameVerifier such as DefaultHostnameVerifier or NoopHostnameVerifier.") protected HostnameVerifier x509HostnameVerifier
-
cookieStore
@Metadata(label="producer", description="To use a custom org.apache.http.client.CookieStore. By default the org.apache.http.impl.client.BasicCookieStore is used which is an in-memory only cookie store. Notice if bridgeEndpoint=true then the cookie store is forced to be a noop cookie store as cookie shouldn\'t be stored as we are just bridging (eg acting as a proxy).") protected org.apache.http.client.CookieStore cookieStore
-
connectionRequestTimeout
@Metadata(label="timeout", defaultValue="-1", description="The timeout in milliseconds used when requesting a connection from the connection manager. A timeout value of zero is interpreted as an infinite timeout. A timeout value of zero is interpreted as an infinite timeout. A negative value is interpreted as undefined (system default).") protected int connectionRequestTimeout
-
connectTimeout
@Metadata(label="timeout", defaultValue="-1", description="Determines the timeout in milliseconds until a connection is established. A timeout value of zero is interpreted as an infinite timeout. A timeout value of zero is interpreted as an infinite timeout. A negative value is interpreted as undefined (system default).") protected int connectTimeout
-
socketTimeout
@Metadata(label="timeout", defaultValue="-1", description="Defines the socket timeout in milliseconds, which is the timeout for waiting for data or, put differently, a maximum period inactivity between two consecutive data packets). A timeout value of zero is interpreted as an infinite timeout. A negative value is interpreted as undefined (system default).") protected int socketTimeout
-
maxTotalConnections
@Metadata(label="advanced", defaultValue="200", description="The maximum number of connections.") protected int maxTotalConnections
-
connectionsPerRoute
@Metadata(label="advanced", defaultValue="20", description="The maximum number of connections per route.") protected int connectionsPerRoute
-
connectionTimeToLive
@Metadata(label="advanced", description="The time for connection to live, the time unit is millisecond, the default value is always keep alive.") protected long connectionTimeToLive
-
-
Constructor Detail
-
HttpComponent
public HttpComponent()
-
HttpComponent
public HttpComponent(Class<? extends HttpEndpoint> endpointClass)
-
-
Method Detail
-
createHttpClientConfigurer
protected HttpClientConfigurer createHttpClientConfigurer(Map<String,Object> parameters, boolean secure) throws Exception
Creates the HttpClientConfigurer based on the given parameters- Parameters:
parameters- the map of parameterssecure- whether the endpoint is secure (eg https)- Returns:
- the configurer
- Throws:
Exception- is thrown if error creating configurer
-
createEndpoint
protected org.apache.camel.Endpoint createEndpoint(String uri, String remaining, Map<String,Object> parameters) throws Exception
- Specified by:
createEndpointin classorg.apache.camel.support.DefaultComponent- Throws:
Exception
-
createConnectionManager
protected org.apache.http.conn.HttpClientConnectionManager createConnectionManager(Map<String,Object> parameters, org.apache.camel.support.jsse.SSLContextParameters sslContextParameters) throws GeneralSecurityException, IOException
- Throws:
GeneralSecurityExceptionIOException
-
createHttpClientBuilder
protected org.apache.http.impl.client.HttpClientBuilder createHttpClientBuilder(String uri, Map<String,Object> parameters, Map<String,Object> httpClientOptions) throws Exception
- Throws:
Exception
-
createConnectionRegistry
protected org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> createConnectionRegistry(HostnameVerifier x509HostnameVerifier, org.apache.camel.support.jsse.SSLContextParameters sslContextParams) throws GeneralSecurityException, IOException
- Throws:
GeneralSecurityExceptionIOException
-
createConnectionManager
protected org.apache.http.conn.HttpClientConnectionManager createConnectionManager(org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> registry)
-
createConnectionManager
protected org.apache.http.conn.HttpClientConnectionManager createConnectionManager(org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> registry, int maxTotalConnections, int connectionsPerRoute)
-
useIntrospectionOnEndpoint
protected boolean useIntrospectionOnEndpoint()
- Overrides:
useIntrospectionOnEndpointin classorg.apache.camel.http.common.HttpCommonComponent
-
createProducer
public org.apache.camel.Producer createProducer(org.apache.camel.CamelContext camelContext, String host, String verb, String basePath, String uriTemplate, String queryParameters, String consumes, String produces, org.apache.camel.spi.RestConfiguration configuration, Map<String,Object> parameters) throws Exception- Specified by:
createProducerin interfaceorg.apache.camel.spi.RestProducerFactory- Throws:
Exception
-
getHttpClientConfigurer
public HttpClientConfigurer getHttpClientConfigurer()
-
setHttpClientConfigurer
public void setHttpClientConfigurer(HttpClientConfigurer httpClientConfigurer)
To use the custom HttpClientConfigurer to perform configuration of the HttpClient that will be used.
-
getClientConnectionManager
public org.apache.http.conn.HttpClientConnectionManager getClientConnectionManager()
-
setClientConnectionManager
public void setClientConnectionManager(org.apache.http.conn.HttpClientConnectionManager clientConnectionManager)
To use a custom and shared HttpClientConnectionManager to manage connections. If this has been configured then this is always used for all endpoints created by this component.
-
getHttpContext
public org.apache.http.protocol.HttpContext getHttpContext()
-
setHttpContext
public void setHttpContext(org.apache.http.protocol.HttpContext httpContext)
To use a custom org.apache.http.protocol.HttpContext when executing requests.
-
getSslContextParameters
public org.apache.camel.support.jsse.SSLContextParameters getSslContextParameters()
-
setSslContextParameters
public void setSslContextParameters(org.apache.camel.support.jsse.SSLContextParameters sslContextParameters)
To configure security using SSLContextParameters. Important: Only one instance of org.apache.camel.support.jsse.SSLContextParameters is supported per HttpComponent. If you need to use 2 or more different instances, you need to define a new HttpComponent per instance you need.
-
isUseGlobalSslContextParameters
public boolean isUseGlobalSslContextParameters()
- Specified by:
isUseGlobalSslContextParametersin interfaceorg.apache.camel.SSLContextParametersAware
-
setUseGlobalSslContextParameters
public void setUseGlobalSslContextParameters(boolean useGlobalSslContextParameters)
Enable usage of global SSL context parameters.- Specified by:
setUseGlobalSslContextParametersin interfaceorg.apache.camel.SSLContextParametersAware
-
getX509HostnameVerifier
public HostnameVerifier getX509HostnameVerifier()
-
setX509HostnameVerifier
public void setX509HostnameVerifier(HostnameVerifier x509HostnameVerifier)
To use a custom X509HostnameVerifier such as DefaultHostnameVerifier or NoopHostnameVerifier.
-
getMaxTotalConnections
public int getMaxTotalConnections()
-
setMaxTotalConnections
public void setMaxTotalConnections(int maxTotalConnections)
The maximum number of connections.
-
getConnectionsPerRoute
public int getConnectionsPerRoute()
-
setConnectionsPerRoute
public void setConnectionsPerRoute(int connectionsPerRoute)
The maximum number of connections per route.
-
getConnectionTimeToLive
public long getConnectionTimeToLive()
-
setConnectionTimeToLive
public void setConnectionTimeToLive(long connectionTimeToLive)
The time for connection to live, the time unit is millisecond, the default value is always keep alive.
-
getCookieStore
public org.apache.http.client.CookieStore getCookieStore()
-
setCookieStore
public void setCookieStore(org.apache.http.client.CookieStore cookieStore)
To use a custom org.apache.http.client.CookieStore. By default the org.apache.http.impl.client.BasicCookieStore is used which is an in-memory only cookie store. Notice if bridgeEndpoint=true then the cookie store is forced to be a noop cookie store as cookie shouldn't be stored as we are just bridging (eg acting as a proxy).
-
getConnectionRequestTimeout
public int getConnectionRequestTimeout()
-
setConnectionRequestTimeout
public void setConnectionRequestTimeout(int connectionRequestTimeout)
The timeout in milliseconds used when requesting a connection from the connection manager. A timeout value of zero is interpreted as an infinite timeout.A timeout value of zero is interpreted as an infinite timeout. A negative value is interpreted as undefined (system default).
Default: -1
-
getConnectTimeout
public int getConnectTimeout()
-
setConnectTimeout
public void setConnectTimeout(int connectTimeout)
Determines the timeout in milliseconds until a connection is established. A timeout value of zero is interpreted as an infinite timeout.A timeout value of zero is interpreted as an infinite timeout. A negative value is interpreted as undefined (system default).
Default: -1
-
getSocketTimeout
public int getSocketTimeout()
-
setSocketTimeout
public void setSocketTimeout(int socketTimeout)
Defines the socket timeout (SO_TIMEOUT) in milliseconds, which is the timeout for waiting for data or, put differently, a maximum period inactivity between two consecutive data packets).A timeout value of zero is interpreted as an infinite timeout. A negative value is interpreted as undefined (system default).
Default: -1
-
doStart
public void doStart() throws Exception- Overrides:
doStartin classorg.apache.camel.support.DefaultComponent- Throws:
Exception
-
doStop
public void doStop() throws Exception- Overrides:
doStopin classorg.apache.camel.support.DefaultComponent- Throws:
Exception
-
getVerifier
public org.apache.camel.component.extension.ComponentVerifierExtension getVerifier()
-
-