Package io.helidon.webclient.websocket
Class WsClientEndpointFactoryBase
java.lang.Object
io.helidon.webclient.websocket.WsClientEndpointFactoryBase
This class is intended for generated code, and we do not expect this to be used directly by users.
For each declarative WebSocket client a factory is generated to allow connecting to the remote server(s). The factory is named by the endpoint class + "Factory" suffix.
In case there are path parameters in the configured Http.Path, they can either be provided
in a map in connect(java.util.Map), or a method will be generated with all path parameters typed according
to usage in the endpoint, or as Strings if not used. The generated method name is also connect.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract WsClientclient()The client used by this factory.voidConnect to the WebSocket endpoint using a custom client.voidConnect to the WebSocket endpoint.protected abstract voidImplement this method to correctly type path parameters provided by a user.protected voidConnects using the provided client.Path parameter names configured in theHttp.Path.
-
Constructor Details
-
WsClientEndpointFactoryBase
protected WsClientEndpointFactoryBase(Config config, String uri, String path, Set<String> pathParamNames) Create a new factory.- Parameters:
config- configuration (root) to use to set this factory upuri- base URI of this endpoint (in declarative, this would be theWebSocketClient.Endpoint.value())path- HTTP path, may contain path parameters (in declarative, this would be theHttp.Path.value()pathParamNames- names of path parameters present inpath, to avoid runtime parsing
-
-
Method Details
-
connect
Connect to the WebSocket endpoint.- Parameters:
pathParameters- if the configured path has path parameters, these must be provided in the map
-
connect
Connect to the WebSocket endpoint using a custom client.- Parameters:
wsClient- client to usepathParameters- if the configured path has path parameters, these must be provided in the map
-
client
The client used by this factory. This may be from service registry, or a new client. A custom client can be specified by callingconnect(WsClient, java.util.Map), or in generated factories a method that has typed path parameters.- Returns:
- WebSocket client used by this factory
-
pathParameterNames
Path parameter names configured in theHttp.Path.- Returns:
- path parameter names
-
doConnect
Implement this method to correctly type path parameters provided by a user. The implementation is expected to calldoConnect(WsClient, java.util.Map, java.util.function.Supplier).- Parameters:
wsClient- client to usepathParameters- provided path parameters, already validate that they contain all path parameters
-
doConnect
protected void doConnect(WsClient client, Map<String, String> pathParameters, Supplier<WsListener> listener) Connects using the provided client. If the client has a base URI specified,uriis ignored, and only HTTP path will be used.- Parameters:
client- client to usepathParameters- path parameter maplistener- listener supplier
-