Search in sources :

Example 1 with IRegistrationHandle

use of org.eclipse.scout.rt.server.context.RunMonitorCancelRegistry.IRegistrationHandle in project scout.rt by eclipse.

the class ServiceTunnelServlet method doPost.

protected ServiceTunnelResponse doPost(ServiceTunnelRequest serviceRequest) throws ServletException {
    ClientNotificationCollector collector = new ClientNotificationCollector();
    ServerRunContext serverRunContext = ServerRunContexts.copyCurrent().withLocale(serviceRequest.getLocale()).withUserAgent(UserAgents.createByIdentifier(serviceRequest.getUserAgent())).withClientNotificationCollector(collector).withClientNodeId(serviceRequest.getClientNodeId());
    if (serviceRequest.getSessionId() != null) {
        serverRunContext.withSession(lookupServerSessionOnHttpSession(serviceRequest.getSessionId(), serverRunContext));
    }
    final IRegistrationHandle registrationHandle = registerForCancellation(serverRunContext, serviceRequest);
    try {
        ServiceTunnelResponse serviceResponse = invokeService(serverRunContext, serviceRequest);
        // include client notifications in response (piggyback)
        serviceResponse.setNotifications(collector.consume());
        return serviceResponse;
    } finally {
        registrationHandle.unregister();
    }
}
Also used : ServerRunContext(org.eclipse.scout.rt.server.context.ServerRunContext) ClientNotificationCollector(org.eclipse.scout.rt.server.clientnotification.ClientNotificationCollector) IRegistrationHandle(org.eclipse.scout.rt.server.context.RunMonitorCancelRegistry.IRegistrationHandle) ServiceTunnelResponse(org.eclipse.scout.rt.shared.servicetunnel.ServiceTunnelResponse)

Aggregations

ClientNotificationCollector (org.eclipse.scout.rt.server.clientnotification.ClientNotificationCollector)1 IRegistrationHandle (org.eclipse.scout.rt.server.context.RunMonitorCancelRegistry.IRegistrationHandle)1 ServerRunContext (org.eclipse.scout.rt.server.context.ServerRunContext)1 ServiceTunnelResponse (org.eclipse.scout.rt.shared.servicetunnel.ServiceTunnelResponse)1