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 booleanprotected Stringprotected static final org.slf4j.Loggerprotected Integerprotected org.eclipse.jetty.jmx.MBeanContainerprotected Integerprotected Integerprotected Map<String,WebSocketFactory> protected org.apache.camel.support.jsse.SSLContextParametersprotected Stringprotected Stringprotected Stringprotected Stringprotected org.eclipse.jetty.server.Serverprotected Stringprotected org.eclipse.jetty.util.thread.ThreadPoolprotected booleanFields 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 WebsocketComponentServletaddServlet(NodeSynchronization sync, WebsocketProducerConsumer prodcon, String resourceUri) voidconnect(WebsocketProducerConsumer prodcon) Connects the URL specified on the endpoint to the specified processor.protected org.eclipse.jetty.servlet.ServletContextHandlercreateContext(org.eclipse.jetty.server.Server server, org.eclipse.jetty.server.Connector connector, List<org.eclipse.jetty.server.Handler> handlers) protected org.apache.camel.Endpointstatic StringcreatePathSpec(String remaining) protected org.eclipse.jetty.server.Serverprotected WebsocketComponentServletcreateServlet(NodeSynchronization sync, String pathSpec, Map<String, WebsocketComponentServlet> servlets, org.eclipse.jetty.servlet.ServletContextHandler handler) protected org.eclipse.jetty.server.ServercreateStaticResourcesServer(org.eclipse.jetty.server.Server server, org.eclipse.jetty.servlet.ServletContextHandler context, String home) protected org.eclipse.jetty.server.ServercreateStaticResourcesServer(org.eclipse.jetty.servlet.ServletContextHandler context, String host, int port, String home) voiddisconnect(WebsocketProducerConsumer prodcon) Disconnects the URL specified on the endpoint from the specified processor.protected voiddoStart()voiddoStop()getHost()org.eclipse.jetty.jmx.MBeanContainergetPort()org.apache.camel.support.jsse.SSLContextParametersSeegetSubprotocol()org.eclipse.jetty.util.thread.ThreadPoolbooleanbooleanprotected WebsocketEndpointnewEndpoint(String uri, String remaining) voidsetEnableJmx(boolean enableJmx) If this option is true, Jetty JMX support will be enabled for this endpoint.voidThe hostname.voidsetMaxThreads(Integer maxThreads) To set a value for maximum number of threads in server thread pool.voidsetMinThreads(Integer minThreads) To set a value for minimum number of threads in server thread pool.voidThe port number.voidsetSocketFactory(Map<String, WebSocketFactory> socketFactory) To configure a map which contains custom WebSocketFactory for sub protocols.voidsetSslContextParameters(org.apache.camel.support.jsse.SSLContextParameters sslContextParameters) To configure security using SSLContextParametersvoidsetSslKeyPassword(String sslKeyPassword) The password for the keystore when using SSL.voidsetSslKeystore(String sslKeystore) The path to the keystore.voidsetSslPassword(String sslPassword) The password when using SSL.voidsetStaticResources(String staticResources) Set a resource path for static resources (such as .html files etc).voidsetSubprotocol(String subprotocol) This is a comma-separated list of subprotocols that are supported by the application.voidsetThreadPool(org.eclipse.jetty.util.thread.ThreadPool threadPool) To use a custom thread pool for the server.voidsetUseGlobalSslContextParameters(boolean useGlobalSslContextParameters) Enable usage of global SSL context parameters.protected voidsetWebSocketComponentServletInitialParameter(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, validateURIMethods 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, suspendMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.camel.CamelContextAware
getCamelContext, setCamelContextMethods inherited from interface org.apache.camel.Service
build, close, init, start, stopMethods inherited from interface org.apache.camel.ShutdownableService
shutdownMethods inherited from interface org.apache.camel.SSLContextParametersAware
retrieveGlobalSslContextParametersMethods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods 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:
createEndpointin 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:
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
-
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:
doStartin classorg.apache.camel.support.DefaultComponent- Throws:
Exception
-
doStop
- Overrides:
doStopin classorg.apache.camel.support.DefaultComponent- Throws:
Exception
-