use of org.wso2.transport.http.netty.contract.HttpWsConnectorFactory in project ballerina by ballerina-lang.
the class Start method execute.
@Override
public void execute(Context context) {
HttpWsConnectorFactory connectorFactory = HttpUtil.createHttpWsConnectionFactory();
Struct clientEndpoint = BLangConnectorSPIUtil.getConnectorEndpointStruct(context);
Struct clientEndpointConfig = clientEndpoint.getStructField(HttpConstants.CLIENT_ENDPOINT_CONFIG);
Object configs = clientEndpointConfig.getNativeData(WebSocketConstants.CLIENT_CONNECTOR_CONFIGS);
if (configs == null || !(configs instanceof WsClientConnectorConfig)) {
throw new BallerinaConnectorException("Initialize the service before starting it");
}
WebSocketClientConnector clientConnector = connectorFactory.createWsClientConnector((WsClientConnectorConfig) configs);
WebSocketClientConnectorListener clientConnectorListener = new WebSocketClientConnectorListener();
Object serviceConfig = clientEndpointConfig.getNativeData(WebSocketConstants.CLIENT_SERVICE_CONFIG);
if (serviceConfig == null || !(serviceConfig instanceof WebSocketService)) {
throw new BallerinaConnectorException("Initialize the service before starting it");
}
WebSocketService wsService = (WebSocketService) serviceConfig;
HandshakeFuture handshakeFuture = clientConnector.connect(clientConnectorListener);
handshakeFuture.setHandshakeListener(new WsHandshakeListener(context, wsService, clientConnectorListener));
context.setReturnValues();
}
use of org.wso2.transport.http.netty.contract.HttpWsConnectorFactory in project wso2-synapse by wso2.
the class Axis2HttpTransportSender method init.
@Override
public void init(ConfigurationContext configurationContext, TransportOutDescription transportOutDescription) throws AxisFault {
httpWsConnectorFactory = new DefaultHttpWsConnectorFactory();
connectionManager = HttpUtils.getConnectionManager();
bootstrapConfiguration = new BootstrapConfiguration(new HashMap<>());
targetConfiguration = new TargetConfiguration(configurationContext, transportOutDescription);
targetConfiguration.build();
}
use of org.wso2.transport.http.netty.contract.HttpWsConnectorFactory in project wso2-synapse by wso2.
the class TargetRequestHandler method createHttpClient.
public static HttpClientConnector createHttpClient(URL url, MessageContext msgContext, HttpWsConnectorFactory httpWsConnectorFactory, ConnectionManager connectionManager, BootstrapConfiguration bootstrapConfiguration, TargetConfiguration targetConfiguration) throws AxisFault {
try {
SenderConfiguration senderConfiguration = new SenderConfiguration();
populateSenderConfigurations(msgContext, senderConfiguration, targetConfiguration, url);
return httpWsConnectorFactory.createHttpClientConnector(bootstrapConfiguration, senderConfiguration, connectionManager);
} catch (Exception ex) {
throw new AxisFault("Error while creating the HTTP Client Connector. ", ex);
}
}
use of org.wso2.transport.http.netty.contract.HttpWsConnectorFactory in project wso2-synapse by wso2.
the class Axis2HttpTransportListener method init.
@Override
public void init(ConfigurationContext configurationContext, TransportInDescription transportInDescription) throws AxisFault {
Scheme scheme = initScheme();
this.transportInDescription = transportInDescription;
// build source configuration
sourceConfiguration = new SourceConfiguration(configurationContext, transportInDescription, scheme, messagingHandlers);
sourceConfiguration.build();
sourceConfiguration.getHttpGetRequestProcessor().init(sourceConfiguration.getConfigurationContext());
ListenerConfiguration listenerConfiguration = initListenerConfiguration();
httpWsConnectorFactory = new DefaultHttpWsConnectorFactory();
this.serverConnector = httpWsConnectorFactory.createServerConnector(new ServerBootstrapConfiguration(new HashMap<>()), listenerConfiguration);
}
use of org.wso2.transport.http.netty.contract.HttpWsConnectorFactory in project wso2-synapse by wso2.
the class Axis2HttpTransportSender method sendRequestToBackendService.
/**
* Sends an outbound request to the backend service.
*
* @param msgCtx axis2 message context
* @param url request URL of the backend service
* @throws IOException if something goes wrong when sending the outbound request to the backend service
*/
private void sendRequestToBackendService(MessageContext msgCtx, URL url) throws IOException {
HttpCarbonMessage outboundRequestMsg = TargetRequestHandler.createOutboundRequestMsg(url, msgCtx, targetConfiguration);
HttpClientConnector clientConnector = TargetRequestHandler.createHttpClient(url, msgCtx, httpWsConnectorFactory, connectionManager, bootstrapConfiguration, targetConfiguration);
TargetRequestHandler.sendRequest(clientConnector, outboundRequestMsg, msgCtx, targetConfiguration);
}
Aggregations