use of org.ballerinalang.net.http.HttpConnectorPortBindingListener in project ballerina by ballerina-lang.
the class Register method startServerConnector.
private void startServerConnector(Struct serviceEndpoint, HTTPServicesRegistry httpServicesRegistry, WebSocketServicesRegistry webSocketServicesRegistry) {
ServerConnector serverConnector = getServerConnector(serviceEndpoint);
ServerConnectorFuture serverConnectorFuture = serverConnector.start();
HashSet<FilterHolder> filterHolder = getFilters(serviceEndpoint);
serverConnectorFuture.setHttpConnectorListener(new BallerinaHTTPConnectorListener(httpServicesRegistry, filterHolder));
serverConnectorFuture.setWSConnectorListener(new WebSocketServerConnectorListener(webSocketServicesRegistry));
serverConnectorFuture.setPortBindingEventListener(new HttpConnectorPortBindingListener());
try {
serverConnectorFuture.sync();
} catch (Throwable ex) {
throw new BallerinaException("failed to start server connector '" + serverConnector.getConnectorID() + "': " + ex.getMessage(), ex);
}
serviceEndpoint.addNativeData(HttpConstants.CONNECTOR_STARTED, true);
}
use of org.ballerinalang.net.http.HttpConnectorPortBindingListener in project ballerina by ballerina-lang.
the class StartWebSubSubscriberServiceEndpoint method execute.
@Override
public void execute(Context context) {
Struct subscriberServiceEndpoint = BLangConnectorSPIUtil.getConnectorEndpointStruct(context);
Struct serviceEndpoint = ConnectorSPIModelHelper.createStruct((BStruct) ((BStruct) (subscriberServiceEndpoint.getVMValue())).getRefField(1));
ServerConnector serverConnector = getServerConnector(serviceEndpoint);
if (isHTTPTraceLoggerEnabled()) {
try {
((BLogManager) BLogManager.getLogManager()).setHttpTraceLogHandler();
} catch (IOException e) {
throw new BallerinaConnectorException("Invalid HTTP trace log parameters found.", e);
} catch (TraceLogConfigurationException e) {
throw new BallerinaConnectorException("Unsupported HTTP trace log configuration. " + e.getMessage(), e);
}
}
ServerConnectorFuture serverConnectorFuture = serverConnector.start();
WebSubServicesRegistry webSubServicesRegistry = (WebSubServicesRegistry) serviceEndpoint.getNativeData(WebSubSubscriberConstants.WEBSUB_SERVICE_REGISTRY);
HashSet<FilterHolder> filterHolder = getFilters(serviceEndpoint);
serverConnectorFuture.setHttpConnectorListener(new BallerinaWebSubConnectionListener(webSubServicesRegistry, filterHolder));
serverConnectorFuture.setPortBindingEventListener(new HttpConnectorPortBindingListener());
context.setReturnValues();
}
Aggregations