Search in sources :

Example 1 with WebSubServicesRegistry

use of org.ballerinalang.net.websub.WebSubServicesRegistry in project ballerina by ballerina-lang.

the class InitWebSubSubscriberServiceEndpoint method execute.

@Override
public void execute(Context context) {
    Struct subscriberServiceEndpoint = BLangConnectorSPIUtil.getConnectorEndpointStruct(context);
    Struct serviceEndpoint = ConnectorSPIModelHelper.createStruct((BStruct) ((BStruct) (subscriberServiceEndpoint.getVMValue())).getRefField(1));
    WebSubServicesRegistry webSubServicesRegistry = new WebSubServicesRegistry(new WebSocketServicesRegistry());
    serviceEndpoint.addNativeData(WebSubSubscriberConstants.WEBSUB_SERVICE_REGISTRY, webSubServicesRegistry);
    context.setReturnValues();
}
Also used : BStruct(org.ballerinalang.model.values.BStruct) WebSocketServicesRegistry(org.ballerinalang.net.http.WebSocketServicesRegistry) WebSubServicesRegistry(org.ballerinalang.net.websub.WebSubServicesRegistry) BStruct(org.ballerinalang.model.values.BStruct) Struct(org.ballerinalang.connector.api.Struct)

Example 2 with WebSubServicesRegistry

use of org.ballerinalang.net.websub.WebSubServicesRegistry in project ballerina by ballerina-lang.

the class RegisterWebSubSubscriberServiceEndpoint method execute.

@Override
public void execute(Context context) {
    Service service = BLangConnectorSPIUtil.getServiceRegistered(context);
    Struct subscriberServiceEndpoint = BLangConnectorSPIUtil.getConnectorEndpointStruct(context);
    Struct serviceEndpoint = ConnectorSPIModelHelper.createStruct((BStruct) ((BStruct) (subscriberServiceEndpoint.getVMValue())).getRefField(1));
    WebSubServicesRegistry webSubServicesRegistry = (WebSubServicesRegistry) serviceEndpoint.getNativeData(WebSubSubscriberConstants.WEBSUB_SERVICE_REGISTRY);
    webSubServicesRegistry.registerWebSubSubscriberService(service);
    context.setReturnValues();
}
Also used : BStruct(org.ballerinalang.model.values.BStruct) WebSubServicesRegistry(org.ballerinalang.net.websub.WebSubServicesRegistry) Service(org.ballerinalang.connector.api.Service) BStruct(org.ballerinalang.model.values.BStruct) Struct(org.ballerinalang.connector.api.Struct)

Example 3 with WebSubServicesRegistry

use of org.ballerinalang.net.websub.WebSubServicesRegistry 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

Struct (org.ballerinalang.connector.api.Struct)3 BStruct (org.ballerinalang.model.values.BStruct)3 WebSubServicesRegistry (org.ballerinalang.net.websub.WebSubServicesRegistry)3 IOException (java.io.IOException)1 BallerinaConnectorException (org.ballerinalang.connector.api.BallerinaConnectorException)1 Service (org.ballerinalang.connector.api.Service)1 BLogManager (org.ballerinalang.logging.BLogManager)1 TraceLogConfigurationException (org.ballerinalang.logging.exceptions.TraceLogConfigurationException)1 HttpConnectorPortBindingListener (org.ballerinalang.net.http.HttpConnectorPortBindingListener)1 WebSocketServicesRegistry (org.ballerinalang.net.http.WebSocketServicesRegistry)1 FilterHolder (org.ballerinalang.net.http.serviceendpoint.FilterHolder)1 BallerinaWebSubConnectionListener (org.ballerinalang.net.websub.BallerinaWebSubConnectionListener)1 ServerConnector (org.wso2.transport.http.netty.contract.ServerConnector)1 ServerConnectorFuture (org.wso2.transport.http.netty.contract.ServerConnectorFuture)1