Search in sources :

Example 1 with WSConnection

use of org.everrest.websockets.WSConnection in project che by eclipse.

the class WebSocketMethodInvokerDecorator method invokeMethod.

@Override
public Object invokeMethod(Object resource, GenericResourceMethod genericMethodResource, ApplicationContext context) {
    WSConnection wsConnection = (WSConnection) org.everrest.core.impl.EnvironmentContext.getCurrent().get(WSConnection.class);
    if (wsConnection != null) {
        EnvironmentContext environmentContext = (EnvironmentContext) wsConnection.getAttribute(ENVIRONMENT_CONTEXT);
        if (environmentContext != null) {
            try {
                EnvironmentContext.setCurrent(environmentContext);
                LOG.debug("Websocket {} in http session {}", wsConnection.getId(), wsConnection.getHttpSession());
                return super.invokeMethod(resource, genericMethodResource, context);
            } finally {
                EnvironmentContext.reset();
            }
        } else {
            LOG.warn("EnvironmentContext  is null");
        }
    }
    return super.invokeMethod(resource, genericMethodResource, context);
}
Also used : EnvironmentContext(org.eclipse.che.commons.env.EnvironmentContext) WSConnection(org.everrest.websockets.WSConnection)

Aggregations

EnvironmentContext (org.eclipse.che.commons.env.EnvironmentContext)1 WSConnection (org.everrest.websockets.WSConnection)1