Search in sources :

Example 6 with ServerConnector

use of org.wso2.transport.http.netty.contract.ServerConnector 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();
}
Also used : BLogManager(org.ballerinalang.logging.BLogManager) BStruct(org.ballerinalang.model.values.BStruct) BallerinaConnectorException(org.ballerinalang.connector.api.BallerinaConnectorException) FilterHolder(org.ballerinalang.net.http.serviceendpoint.FilterHolder) HttpConnectorPortBindingListener(org.ballerinalang.net.http.HttpConnectorPortBindingListener) ServerConnectorFuture(org.wso2.transport.http.netty.contract.ServerConnectorFuture) BallerinaWebSubConnectionListener(org.ballerinalang.net.websub.BallerinaWebSubConnectionListener) IOException(java.io.IOException) BStruct(org.ballerinalang.model.values.BStruct) Struct(org.ballerinalang.connector.api.Struct) ServerConnector(org.wso2.transport.http.netty.contract.ServerConnector) TraceLogConfigurationException(org.ballerinalang.logging.exceptions.TraceLogConfigurationException) WebSubServicesRegistry(org.ballerinalang.net.websub.WebSubServicesRegistry)

Aggregations

BStruct (org.ballerinalang.model.values.BStruct)4 ServerConnector (org.wso2.transport.http.netty.contract.ServerConnector)4 BallerinaConnectorException (org.ballerinalang.connector.api.BallerinaConnectorException)3 Struct (org.ballerinalang.connector.api.Struct)2 HttpConnectorPortBindingListener (org.ballerinalang.net.http.HttpConnectorPortBindingListener)2 ServerConnectorFuture (org.wso2.transport.http.netty.contract.ServerConnectorFuture)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Semaphore (java.util.concurrent.Semaphore)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 BLangVMErrors (org.ballerinalang.bre.bvm.BLangVMErrors)1 CallableUnitCallback (org.ballerinalang.bre.bvm.CallableUnitCallback)1 BLangConnectorSPIUtil (org.ballerinalang.connector.api.BLangConnectorSPIUtil)1 Executor (org.ballerinalang.connector.api.Executor)1 ParamDetail (org.ballerinalang.connector.api.ParamDetail)1 Resource (org.ballerinalang.connector.api.Resource)1 BLogManager (org.ballerinalang.logging.BLogManager)1 TraceLogConfigurationException (org.ballerinalang.logging.exceptions.TraceLogConfigurationException)1