Class WebsocketComponent

java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.DefaultComponent
org.apache.camel.component.websocket.WebsocketComponent
All Implemented Interfaces:
AutoCloseable, org.apache.camel.CamelContextAware, org.apache.camel.Component, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.SSLContextParametersAware, org.apache.camel.StatefulService, org.apache.camel.SuspendableService

@Component("websocket") public class WebsocketComponent extends org.apache.camel.support.DefaultComponent implements org.apache.camel.SSLContextParametersAware
  • Field Details

    • LOG

      protected static final org.slf4j.Logger LOG
    • CONNECTORS

      protected static final HashMap<String,org.apache.camel.component.websocket.WebsocketComponent.ConnectorRef> CONNECTORS
    • socketFactory

      protected Map<String,WebSocketFactory> socketFactory
    • staticResourcesServer

      protected org.eclipse.jetty.server.Server staticResourcesServer
    • mbContainer

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

      @Metadata(label="security") protected org.apache.camel.support.jsse.SSLContextParameters sslContextParameters
    • useGlobalSslContextParameters

      @Metadata(label="security", defaultValue="false") protected boolean useGlobalSslContextParameters
    • threadPool

      @Metadata(label="advanced") protected org.eclipse.jetty.util.thread.ThreadPool threadPool
    • port

      @Metadata(defaultValue="9292") protected Integer port
    • minThreads

      @Metadata(label="advanced") protected Integer minThreads
    • maxThreads

      @Metadata(label="advanced") protected Integer maxThreads
    • enableJmx

      @Metadata(label="advanced") protected boolean enableJmx
    • host

      @Metadata(defaultValue="0.0.0.0") protected String host
    • staticResources

      @Metadata(label="consumer") protected String staticResources
    • sslKeyPassword

      @Metadata(label="security", secret=true) protected String sslKeyPassword
    • sslPassword

      @Metadata(label="security", secret=true) protected String sslPassword
    • sslKeystore

      @Metadata(label="security", secret=true) protected String sslKeystore
    • subprotocol

      @Metadata(label="advanced", defaultValue="any") protected String subprotocol
  • Constructor Details

    • WebsocketComponent

      public WebsocketComponent()
  • Method Details

    • connect

      public void connect(WebsocketProducerConsumer prodcon) throws Exception
      Connects the URL specified on the endpoint to the specified processor.
      Throws:
      Exception
    • disconnect

      public void disconnect(WebsocketProducerConsumer prodcon) throws Exception
      Disconnects the URL specified on the endpoint from the specified processor.
      Throws:
      Exception
    • getMbContainer

      public org.eclipse.jetty.jmx.MBeanContainer getMbContainer()
    • 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
    • newEndpoint

      protected WebsocketEndpoint newEndpoint(String uri, String remaining)
    • setWebSocketComponentServletInitialParameter

      protected void setWebSocketComponentServletInitialParameter(org.eclipse.jetty.servlet.ServletContextHandler context, WebsocketEndpoint endpoint)
    • createServer

      protected org.eclipse.jetty.server.Server createServer() throws Exception
      Throws:
      Exception
    • createStaticResourcesServer

      protected org.eclipse.jetty.server.Server createStaticResourcesServer(org.eclipse.jetty.server.Server server, org.eclipse.jetty.servlet.ServletContextHandler context, String home) throws Exception
      Throws:
      Exception
    • createStaticResourcesServer

      protected org.eclipse.jetty.server.Server createStaticResourcesServer(org.eclipse.jetty.servlet.ServletContextHandler context, String host, int port, String home) throws Exception
      Throws:
      Exception
    • addServlet

      protected WebsocketComponentServlet addServlet(NodeSynchronization sync, WebsocketProducerConsumer prodcon, String resourceUri) throws Exception
      Throws:
      Exception
    • createServlet

      protected WebsocketComponentServlet createServlet(NodeSynchronization sync, String pathSpec, Map<String,WebsocketComponentServlet> servlets, org.eclipse.jetty.servlet.ServletContextHandler handler)
    • createContext

      protected org.eclipse.jetty.servlet.ServletContextHandler createContext(org.eclipse.jetty.server.Server server, org.eclipse.jetty.server.Connector connector, List<org.eclipse.jetty.server.Handler> handlers)
    • createPathSpec

      public static String createPathSpec(String remaining)
    • getStaticResources

      public String getStaticResources()
    • setStaticResources

      public void setStaticResources(String staticResources)
      Set a resource path for static resources (such as .html files etc).

      The resources can be loaded from classpath, if you prefix with classpath:, otherwise the resources is loaded from file system or from JAR files.

      For example to load from root classpath use classpath:., or classpath:WEB-INF/static

      If not configured (eg null) then no static resource is in use.

    • getHost

      public String getHost()
    • setHost

      public void setHost(String host)
      The hostname. The default value is 0.0.0.0
    • getPort

      public Integer getPort()
    • setPort

      public void setPort(Integer port)
      The port number. The default value is 9292
    • getSslKeyPassword

      public String getSslKeyPassword()
    • getSslPassword

      public String getSslPassword()
    • getSslKeystore

      public String getSslKeystore()
    • setSslKeyPassword

      public void setSslKeyPassword(String sslKeyPassword)
      The password for the keystore when using SSL.
    • setSslPassword

      public void setSslPassword(String sslPassword)
      The password when using SSL.
    • setSslKeystore

      public void setSslKeystore(String sslKeystore)
      The path to the keystore.
    • setEnableJmx

      public void setEnableJmx(boolean enableJmx)
      If this option is true, Jetty JMX support will be enabled for this endpoint. See Jetty JMX support for more details.
    • isEnableJmx

      public boolean isEnableJmx()
    • getMinThreads

      public Integer getMinThreads()
    • setMinThreads

      public void setMinThreads(Integer minThreads)
      To set a value for minimum number of threads in server thread pool. MaxThreads/minThreads or threadPool fields are required due to switch to Jetty9. The default values for minThreads is 1.
    • getMaxThreads

      public Integer getMaxThreads()
    • setMaxThreads

      public void setMaxThreads(Integer maxThreads)
      To set a value for maximum number of threads in server thread pool. MaxThreads/minThreads or threadPool fields are required due to switch to Jetty9. The default values for maxThreads is 1 + 2 * noCores.
    • getThreadPool

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

      public void setThreadPool(org.eclipse.jetty.util.thread.ThreadPool threadPool)
      To use a custom thread pool for the server. MaxThreads/minThreads or threadPool fields are required due to switch to Jetty9.
    • 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
    • isUseGlobalSslContextParameters

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

      public void setUseGlobalSslContextParameters(boolean useGlobalSslContextParameters)
      Enable usage of global SSL context parameters.
      Specified by:
      setUseGlobalSslContextParameters in interface org.apache.camel.SSLContextParametersAware
    • getSubprotocol

      public String getSubprotocol()
    • setSubprotocol

      public void setSubprotocol(String subprotocol)

      This is a comma-separated list of subprotocols that are supported by the application. The list is in priority order. The first subprotocol on this list that is proposed by the client is the one that will be accepted. If no subprotocol on this list is proposed by the client, then the websocket connection is refused. The special value 'any' means that any subprotocol is acceptable. 'any' can be used on its own, or as a failsafe at the end of a list of more specific protocols. 'any' will also match the case where no subprotocol is proposed by the client.

      See Also:
    • getSocketFactory

      public Map<String,WebSocketFactorygetSocketFactory()
    • setSocketFactory

      public void setSocketFactory(Map<String,WebSocketFactory> socketFactory)
      To configure a map which contains custom WebSocketFactory for sub protocols. The key in the map is the sub protocol.

      The default key is reserved for the default implementation.

    • getConnectors

      public static HashMap<String,org.apache.camel.component.websocket.WebsocketComponent.ConnectorRef> getConnectors()
    • doStart

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

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