Class JettyHttpComponent

  • 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.RestApiConsumerFactory, org.apache.camel.spi.RestConsumerFactory, org.apache.camel.SSLContextParametersAware, org.apache.camel.StatefulService, org.apache.camel.SuspendableService

    public abstract class JettyHttpComponent
    extends org.apache.camel.http.common.HttpCommonComponent
    implements org.apache.camel.spi.RestConsumerFactory, org.apache.camel.spi.RestApiConsumerFactory, org.apache.camel.SSLContextParametersAware
    An HttpComponent which starts an embedded Jetty for to handle consuming from the http endpoints.
    • Field Detail

      • CONNECTORS

        protected static final HashMap<String,​org.apache.camel.component.jetty.JettyHttpComponent.ConnectorRef> CONNECTORS
      • sslKeyPassword

        protected String sslKeyPassword
      • sslPassword

        protected String sslPassword
      • sslKeystore

        protected String sslKeystore
      • sslSocketConnectors

        protected Map<Integer,​org.eclipse.jetty.server.Connector> sslSocketConnectors
      • socketConnectors

        protected Map<Integer,​org.eclipse.jetty.server.Connector> socketConnectors
      • sslSocketConnectorProperties

        protected Map<String,​Object> sslSocketConnectorProperties
      • socketConnectorProperties

        protected Map<String,​Object> socketConnectorProperties
      • minThreads

        protected Integer minThreads
      • maxThreads

        protected Integer maxThreads
      • threadPool

        protected org.eclipse.jetty.util.thread.ThreadPool threadPool
      • mbContainer

        protected org.eclipse.jetty.jmx.MBeanContainer mbContainer
      • enableJmx

        protected boolean enableJmx
      • continuationTimeout

        protected Long continuationTimeout
      • useContinuation

        protected boolean useContinuation
      • sslContextParameters

        protected org.apache.camel.support.jsse.SSLContextParameters sslContextParameters
      • useGlobalSslContextParameters

        protected boolean useGlobalSslContextParameters
      • requestBufferSize

        protected Integer requestBufferSize
      • requestHeaderSize

        protected Integer requestHeaderSize
      • responseBufferSize

        protected Integer responseBufferSize
      • responseHeaderSize

        protected Integer responseHeaderSize
      • proxyHost

        protected String proxyHost
      • errorHandler

        protected org.eclipse.jetty.server.handler.ErrorHandler errorHandler
      • useXForwardedForHeader

        protected boolean useXForwardedForHeader
    • Constructor Detail

      • JettyHttpComponent

        public JettyHttpComponent()
    • Method Detail

      • createEndpoint

        protected org.apache.camel.Endpoint createEndpoint​(String uri,
                                                           String remaining,
                                                           Map<String,​Object> parameters)
                                                    throws Exception
        Specified by:
        createEndpoint in class org.apache.camel.support.DefaultComponent
        Throws:
        Exception
      • canConnect

        public boolean canConnect​(org.apache.camel.http.common.HttpConsumer consumer)
                           throws Exception
        Overrides:
        canConnect in class org.apache.camel.http.common.HttpCommonComponent
        Throws:
        Exception
      • connect

        public void connect​(org.apache.camel.http.common.HttpConsumer consumer)
                     throws Exception
        Connects the URL specified on the endpoint to the specified processor.
        Overrides:
        connect in class org.apache.camel.http.common.HttpCommonComponent
        Throws:
        Exception
      • disconnect

        public void disconnect​(org.apache.camel.http.common.HttpConsumer consumer)
                        throws Exception
        Disconnects the URL specified on the endpoint from the specified processor.
        Overrides:
        disconnect in class org.apache.camel.http.common.HttpCommonComponent
        Throws:
        Exception
      • getSslKeyPassword

        public String getSslKeyPassword()
      • setSslKeyPassword

        @Metadata(description="The key password, which is used to access the certificate\'s key entry in the keystore (this is the same password that is supplied to the keystore command\'s -keypass option).",
                  label="security",
                  secret=true)
        public void setSslKeyPassword​(String sslKeyPassword)
        The key password, which is used to access the certificate's key entry in the keystore (this is the same password that is supplied to the keystore command's -keypass option).
      • getSslPassword

        public String getSslPassword()
      • setSslPassword

        @Metadata(description="The ssl password, which is required to access the keystore file (this is the same password that is supplied to the keystore command\'s -storepass option).",
                  label="security",
                  secret=true)
        public void setSslPassword​(String sslPassword)
        The ssl password, which is required to access the keystore file (this is the same password that is supplied to the keystore command's -storepass option).
      • setKeystore

        @Metadata(description="Specifies the location of the Java keystore file, which contains the Jetty server\'s own X.509 certificate in a key entry.",
                  label="security",
                  secret=true)
        public void setKeystore​(String sslKeystore)
        Specifies the location of the Java keystore file, which contains the Jetty server's own X.509 certificate in a key entry.
      • getKeystore

        public String getKeystore()
      • getErrorHandler

        public org.eclipse.jetty.server.handler.ErrorHandler getErrorHandler()
      • setErrorHandler

        @Metadata(description="This option is used to set the ErrorHandler that Jetty server uses.",
                  label="advanced")
        public void setErrorHandler​(org.eclipse.jetty.server.handler.ErrorHandler errorHandler)
        This option is used to set the ErrorHandler that Jetty server uses.
      • getConnector

        protected org.eclipse.jetty.server.Connector getConnector​(org.eclipse.jetty.server.Server server,
                                                                  JettyHttpEndpoint endpoint)
      • getSocketConnector

        protected org.eclipse.jetty.server.Connector getSocketConnector​(org.eclipse.jetty.server.Server server,
                                                                        JettyHttpEndpoint endpoint)
      • getSslSocketConnector

        protected org.eclipse.jetty.server.Connector getSslSocketConnector​(org.eclipse.jetty.server.Server server,
                                                                           JettyHttpEndpoint endpoint)
      • createConnector

        protected org.eclipse.jetty.server.Connector createConnector​(org.eclipse.jetty.server.Server server,
                                                                     JettyHttpEndpoint endpoint)
      • createConnectorJettyInternal

        protected abstract org.eclipse.jetty.server.AbstractConnector createConnectorJettyInternal​(org.eclipse.jetty.server.Server server,
                                                                                                   JettyHttpEndpoint endpoint,
                                                                                                   org.eclipse.jetty.util.ssl.SslContextFactory sslcf)
      • checkSSLContextFactoryConfig

        protected boolean checkSSLContextFactoryConfig​(Object instance)
      • getSslSocketConnectors

        public Map<Integer,​org.eclipse.jetty.server.Connector> getSslSocketConnectors()
      • setSslSocketConnectors

        @Metadata(description="A map which contains per port number specific SSL connectors.",
                  label="security")
        public void setSslSocketConnectors​(Map<Integer,​org.eclipse.jetty.server.Connector> connectors)
        A map which contains per port number specific SSL connectors.
      • setSocketConnectors

        @Metadata(description="A map which contains per port number specific HTTP connectors. Uses the same principle as sslSocketConnectors.",
                  label="security")
        public void setSocketConnectors​(Map<Integer,​org.eclipse.jetty.server.Connector> socketConnectors)
        A map which contains per port number specific HTTP connectors. Uses the same principle as sslSocketConnectors.
      • getSocketConnectors

        public Map<Integer,​org.eclipse.jetty.server.Connector> getSocketConnectors()
      • getMinThreads

        public Integer getMinThreads()
      • setMinThreads

        @Metadata(description="To set a value for minimum number of threads in server thread pool. Notice that both a min and max size must be configured.",
                  label="consumer")
        public void setMinThreads​(Integer minThreads)
        To set a value for minimum number of threads in server thread pool. Notice that both a min and max size must be configured.
      • getMaxThreads

        public Integer getMaxThreads()
      • setMaxThreads

        @Metadata(description="To set a value for maximum number of threads in server thread pool. Notice that both a min and max size must be configured.",
                  label="consumer")
        public void setMaxThreads​(Integer maxThreads)
        To set a value for maximum number of threads in server thread pool. Notice that both a min and max size must be configured.
      • getThreadPool

        public org.eclipse.jetty.util.thread.ThreadPool getThreadPool()
      • setThreadPool

        @Metadata(description="To use a custom thread pool for the server. This option should only be used in special circumstances.",
                  label="consumer,advanced")
        public void setThreadPool​(org.eclipse.jetty.util.thread.ThreadPool threadPool)
        To use a custom thread pool for the server. This option should only be used in special circumstances.
      • isEnableJmx

        public boolean isEnableJmx()
      • setEnableJmx

        @Metadata(description="If this option is true, Jetty JMX support will be enabled for this endpoint.")
        public void setEnableJmx​(boolean enableJmx)
        If this option is true, Jetty JMX support will be enabled for this endpoint.
      • setJettyHttpBinding

        @Metadata(description="To use a custom org.apache.camel.component.jetty.JettyHttpBinding, which are used to customize how a response should be written for the producer.",
                  label="advanced")
        public void setJettyHttpBinding​(JettyHttpBinding jettyHttpBinding)
        To use a custom org.apache.camel.component.jetty.JettyHttpBinding, which are used to customize how a response should be written for the producer.
      • setHttpBinding

        @Metadata(description="Not to be used - use JettyHttpBinding instead.",
                  label="advanced")
        public void setHttpBinding​(org.apache.camel.http.common.HttpBinding httpBinding)
        Not to be used - use JettyHttpBinding instead.
        Overrides:
        setHttpBinding in class org.apache.camel.http.common.HttpCommonComponent
      • setHttpConfiguration

        @Metadata(description="Jetty component does not use HttpConfiguration.",
                  label="advanced")
        public void setHttpConfiguration​(org.apache.camel.http.common.HttpConfiguration httpConfiguration)
        Jetty component does not use HttpConfiguration.
        Overrides:
        setHttpConfiguration in class org.apache.camel.http.common.HttpCommonComponent
      • getMbContainer

        public org.eclipse.jetty.jmx.MBeanContainer getMbContainer()
      • setMbContainer

        @Metadata(description="To use a existing configured org.eclipse.jetty.jmx.MBeanContainer if JMX is enabled that Jetty uses for registering mbeans.",
                  label="advanced")
        public void setMbContainer​(org.eclipse.jetty.jmx.MBeanContainer mbContainer)
        To use a existing configured org.eclipse.jetty.jmx.MBeanContainer if JMX is enabled that Jetty uses for registering mbeans.
      • getSslSocketConnectorProperties

        public Map<String,​Object> getSslSocketConnectorProperties()
      • setSslSocketConnectorProperties

        @Metadata(description="A map which contains general SSL connector properties.",
                  label="security")
        public void setSslSocketConnectorProperties​(Map<String,​Object> sslSocketConnectorProperties)
        A map which contains general SSL connector properties.
      • getSocketConnectorProperties

        public Map<String,​Object> getSocketConnectorProperties()
      • setSocketConnectorProperties

        @Metadata(description="A map which contains general HTTP connector properties. Uses the same principle as sslSocketConnectorProperties.",
                  label="security")
        public void setSocketConnectorProperties​(Map<String,​Object> socketConnectorProperties)
        A map which contains general HTTP connector properties. Uses the same principle as sslSocketConnectorProperties.
      • addSocketConnectorProperty

        public void addSocketConnectorProperty​(String key,
                                               Object value)
      • addSslSocketConnectorProperty

        public void addSslSocketConnectorProperty​(String key,
                                                  Object value)
      • getContinuationTimeout

        public Long getContinuationTimeout()
      • setContinuationTimeout

        @Metadata(description="Allows to set a timeout in millis when using Jetty as consumer (server). By default Jetty uses 30000. You can use a value of <= 0 to never expire. If a timeout occurs then the request will be expired and Jetty will return back a http error 503 to the client. This option is only in use when using Jetty with the Asynchronous Routing Engine.",
                  defaultValue="30000",
                  label="consumer")
        public void setContinuationTimeout​(Long continuationTimeout)
        Allows to set a timeout in millis when using Jetty as consumer (server). By default Jetty uses 30000. You can use a value of <= 0 to never expire. If a timeout occurs then the request will be expired and Jetty will return back a http error 503 to the client. This option is only in use when using Jetty with the Asynchronous Routing Engine.
      • isUseContinuation

        public boolean isUseContinuation()
      • setUseContinuation

        @Metadata(description="Whether or not to use Jetty continuations for the Jetty Server.",
                  defaultValue="true",
                  label="consumer")
        public void setUseContinuation​(boolean useContinuation)
        Whether or not to use Jetty continuations for the Jetty Server.
      • getSslContextParameters

        public org.apache.camel.support.jsse.SSLContextParameters getSslContextParameters()
      • setSslContextParameters

        @Metadata(description="To configure security using SSLContextParameters",
                  label="security")
        public void setSslContextParameters​(org.apache.camel.support.jsse.SSLContextParameters sslContextParameters)
        To configure security using SSLContextParameters
      • isUseGlobalSslContextParameters

        public boolean isUseGlobalSslContextParameters()
        Specified by:
        isUseGlobalSslContextParameters in interface org.apache.camel.SSLContextParametersAware
      • setUseGlobalSslContextParameters

        @Metadata(description="Enable usage of global SSL context parameters",
                  label="security",
                  defaultValue="false")
        public void setUseGlobalSslContextParameters​(boolean useGlobalSslContextParameters)
        Enable usage of global SSL context parameters
        Specified by:
        setUseGlobalSslContextParameters in interface org.apache.camel.SSLContextParametersAware
      • getResponseBufferSize

        public Integer getResponseBufferSize()
      • setResponseBufferSize

        @Metadata(description="Allows to configure a custom value of the response buffer size on the Jetty connectors.")
        public void setResponseBufferSize​(Integer responseBufferSize)
        Allows to configure a custom value of the response buffer size on the Jetty connectors.
      • getRequestBufferSize

        public Integer getRequestBufferSize()
      • setRequestBufferSize

        @Metadata(description="Allows to configure a custom value of the request buffer size on the Jetty connectors.")
        public void setRequestBufferSize​(Integer requestBufferSize)
        Allows to configure a custom value of the request buffer size on the Jetty connectors.
      • getRequestHeaderSize

        public Integer getRequestHeaderSize()
      • setRequestHeaderSize

        @Metadata(description="Allows to configure a custom value of the request header size on the Jetty connectors.")
        public void setRequestHeaderSize​(Integer requestHeaderSize)
        Allows to configure a custom value of the request header size on the Jetty connectors.
      • getResponseHeaderSize

        public Integer getResponseHeaderSize()
      • setResponseHeaderSize

        @Metadata(description="Allows to configure a custom value of the response header size on the Jetty connectors.")
        public void setResponseHeaderSize​(Integer responseHeaderSize)
        Allows to configure a custom value of the response header size on the Jetty connectors.
      • getProxyHost

        public String getProxyHost()
      • setProxyHost

        @Metadata(description="To use a http proxy to configure the hostname.",
                  label="proxy")
        public void setProxyHost​(String proxyHost)
        To use a http proxy to configure the hostname.
      • getProxyPort

        public Integer getProxyPort()
      • setProxyPort

        @Metadata(description="To use a http proxy to configure the port number.",
                  label="proxy")
        public void setProxyPort​(Integer proxyPort)
        To use a http proxy to configure the port number.
      • isUseXForwardedForHeader

        public boolean isUseXForwardedForHeader()
      • setUseXForwardedForHeader

        @Metadata(description="To use the X-Forwarded-For header in HttpServletRequest.getRemoteAddr.")
        public void setUseXForwardedForHeader​(boolean useXForwardedForHeader)
        To use the X-Forwarded-For header in HttpServletRequest.getRemoteAddr.
      • isSendServerVersion

        public boolean isSendServerVersion()
      • setSendServerVersion

        @Metadata(description="If the option is true, jetty will send the server header with the jetty version information to the client which sends the request. NOTE please make sure there is no any other camel-jetty endpoint is share the same port, otherwise this option may not work as expected.",
                  defaultValue="true",
                  label="consumer")
        public void setSendServerVersion​(boolean sendServerVersion)
        If the option is true, jetty will send the server header with the jetty version information to the client which sends the request. NOTE please make sure there is no any other camel-jetty endpoint is share the same port, otherwise this option may not work as expected.
      • createConsumer

        public org.apache.camel.Consumer createConsumer​(org.apache.camel.CamelContext camelContext,
                                                        org.apache.camel.Processor processor,
                                                        String verb,
                                                        String basePath,
                                                        String uriTemplate,
                                                        String consumes,
                                                        String produces,
                                                        org.apache.camel.spi.RestConfiguration configuration,
                                                        Map<String,​Object> parameters)
                                                 throws Exception
        Specified by:
        createConsumer in interface org.apache.camel.spi.RestConsumerFactory
        Throws:
        Exception
      • createApiConsumer

        public org.apache.camel.Consumer createApiConsumer​(org.apache.camel.CamelContext camelContext,
                                                           org.apache.camel.Processor processor,
                                                           String contextPath,
                                                           org.apache.camel.spi.RestConfiguration configuration,
                                                           Map<String,​Object> parameters)
                                                    throws Exception
        Specified by:
        createApiConsumer in interface org.apache.camel.spi.RestApiConsumerFactory
        Throws:
        Exception
      • createServletForConnector

        protected org.apache.camel.http.common.CamelServlet createServletForConnector​(org.eclipse.jetty.server.Server server,
                                                                                      org.eclipse.jetty.server.Connector connector,
                                                                                      List<org.eclipse.jetty.server.Handler> handlers,
                                                                                      JettyHttpEndpoint endpoint)
                                                                               throws Exception
        Throws:
        Exception
      • addJettyHandlers

        protected void addJettyHandlers​(org.eclipse.jetty.server.Server server,
                                        List<org.eclipse.jetty.server.Handler> handlers)
      • isHandlerInChain

        protected boolean isHandlerInChain​(org.eclipse.jetty.server.Handler current,
                                           org.eclipse.jetty.server.Handler handler)
      • createServer

        protected org.eclipse.jetty.server.Server createServer()
      • doInit

        protected void doInit()
                       throws Exception
        Overrides:
        doInit in class org.apache.camel.support.DefaultComponent
        Throws:
        Exception
      • doStop

        protected void doStop()
                       throws Exception
        Overrides:
        doStop in class org.apache.camel.support.DefaultComponent
        Throws:
        Exception