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 Summary
FieldsModifier and TypeFieldDescriptionprotected static final HashMap<String,
org.apache.camel.component.websocket.WebsocketComponent.ConnectorRef> protected boolean
protected String
protected static final org.slf4j.Logger
protected Integer
protected org.eclipse.jetty.jmx.MBeanContainer
protected Integer
protected Integer
protected Map<String,
WebSocketFactory> protected org.apache.camel.support.jsse.SSLContextParameters
protected String
protected String
protected String
protected String
protected org.eclipse.jetty.server.Server
protected String
protected org.eclipse.jetty.util.thread.ThreadPool
protected boolean
Fields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected WebsocketComponentServlet
addServlet
(NodeSynchronization sync, WebsocketProducerConsumer prodcon, String resourceUri) void
connect
(WebsocketProducerConsumer prodcon) Connects the URL specified on the endpoint to the specified processor.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) protected org.apache.camel.Endpoint
static String
createPathSpec
(String remaining) protected org.eclipse.jetty.server.Server
protected WebsocketComponentServlet
createServlet
(NodeSynchronization sync, String pathSpec, Map<String, WebsocketComponentServlet> servlets, org.eclipse.jetty.servlet.ServletContextHandler handler) protected org.eclipse.jetty.server.Server
createStaticResourcesServer
(org.eclipse.jetty.server.Server server, org.eclipse.jetty.servlet.ServletContextHandler context, String home) protected org.eclipse.jetty.server.Server
createStaticResourcesServer
(org.eclipse.jetty.servlet.ServletContextHandler context, String host, int port, String home) void
disconnect
(WebsocketProducerConsumer prodcon) Disconnects the URL specified on the endpoint from the specified processor.protected void
doStart()
void
doStop()
getHost()
org.eclipse.jetty.jmx.MBeanContainer
getPort()
org.apache.camel.support.jsse.SSLContextParameters
SeegetSubprotocol()
org.eclipse.jetty.util.thread.ThreadPool
boolean
boolean
protected WebsocketEndpoint
newEndpoint
(String uri, String remaining) void
setEnableJmx
(boolean enableJmx) If this option is true, Jetty JMX support will be enabled for this endpoint.void
The hostname.void
setMaxThreads
(Integer maxThreads) To set a value for maximum number of threads in server thread pool.void
setMinThreads
(Integer minThreads) To set a value for minimum number of threads in server thread pool.void
The port number.void
setSocketFactory
(Map<String, WebSocketFactory> socketFactory) To configure a map which contains custom WebSocketFactory for sub protocols.void
setSslContextParameters
(org.apache.camel.support.jsse.SSLContextParameters sslContextParameters) To configure security using SSLContextParametersvoid
setSslKeyPassword
(String sslKeyPassword) The password for the keystore when using SSL.void
setSslKeystore
(String sslKeystore) The path to the keystore.void
setSslPassword
(String sslPassword) The password when using SSL.void
setStaticResources
(String staticResources) Set a resource path for static resources (such as .html files etc).void
setSubprotocol
(String subprotocol) This is a comma-separated list of subprotocols that are supported by the application.void
setThreadPool
(org.eclipse.jetty.util.thread.ThreadPool threadPool) To use a custom thread pool for the server.void
setUseGlobalSslContextParameters
(boolean useGlobalSslContextParameters) Enable usage of global SSL context parameters.protected void
setWebSocketComponentServletInitialParameter
(org.eclipse.jetty.servlet.ServletContextHandler context, WebsocketEndpoint endpoint) Methods inherited from class org.apache.camel.support.DefaultComponent
afterConfiguration, createEndpoint, createEndpoint, doBuild, doInit, getAndRemoveOrResolveReferenceParameter, getAndRemoveOrResolveReferenceParameter, getAndRemoveParameter, getAndRemoveParameter, getCamelContext, getComponentPropertyConfigurer, getDefaultName, getEndpointPropertyConfigurer, getExtension, getSupportedExtensions, ifStartsWithReturnRemainder, isAutowiredEnabled, isBridgeErrorHandler, isLazyStartProducer, registerExtension, registerExtension, resolveAndRemoveReferenceListParameter, resolveAndRemoveReferenceListParameter, resolveAndRemoveReferenceParameter, resolveAndRemoveReferenceParameter, resolveRawParameterValues, setAutowiredEnabled, setBridgeErrorHandler, setCamelContext, setLazyStartProducer, setProperties, setProperties, setProperties, useIntrospectionOnEndpoint, useRawUri, validateParameters, validateURI
Methods inherited from class org.apache.camel.support.service.BaseService
build, 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, 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.Service
build, close, init, start, stop
Methods inherited from interface org.apache.camel.ShutdownableService
shutdown
Methods inherited from interface org.apache.camel.SSLContextParametersAware
retrieveGlobalSslContextParameters
Methods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending
Methods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Field Details
-
LOG
protected static final org.slf4j.Logger LOG -
CONNECTORS
-
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
-
minThreads
-
maxThreads
-
enableJmx
@Metadata(label="advanced") protected boolean enableJmx -
host
-
staticResources
-
sslKeyPassword
-
sslPassword
-
sslKeystore
-
subprotocol
-
-
Constructor Details
-
WebsocketComponent
public WebsocketComponent()
-
-
Method Details
-
connect
Connects the URL specified on the endpoint to the specified processor.- Throws:
Exception
-
disconnect
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 classorg.apache.camel.support.DefaultComponent
- Throws:
Exception
-
newEndpoint
-
setWebSocketComponentServletInitialParameter
protected void setWebSocketComponentServletInitialParameter(org.eclipse.jetty.servlet.ServletContextHandler context, WebsocketEndpoint endpoint) -
createServer
- 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
-
getStaticResources
-
setStaticResources
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
-
setHost
The hostname. The default value is 0.0.0.0 -
getPort
-
setPort
The port number. The default value is 9292 -
getSslKeyPassword
-
getSslPassword
-
getSslKeystore
-
setSslKeyPassword
The password for the keystore when using SSL. -
setSslPassword
The password when using SSL. -
setSslKeystore
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
-
setMinThreads
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
-
setMaxThreads
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 interfaceorg.apache.camel.SSLContextParametersAware
-
setUseGlobalSslContextParameters
public void setUseGlobalSslContextParameters(boolean useGlobalSslContextParameters) Enable usage of global SSL context parameters.- Specified by:
setUseGlobalSslContextParameters
in interfaceorg.apache.camel.SSLContextParametersAware
-
getSubprotocol
SeegetSubprotocol()
-
setSubprotocol
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.
-
getSocketFactory
-
setSocketFactory
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
-
doStart
- Overrides:
doStart
in classorg.apache.camel.support.DefaultComponent
- Throws:
Exception
-
doStop
- Overrides:
doStop
in classorg.apache.camel.support.DefaultComponent
- Throws:
Exception
-