use of org.eclipse.che.ide.websocket.MessageBus in project che by eclipse.
the class JavaSearchServiceWS method findUsages.
@Override
public Promise<FindUsagesResponse> findUsages(final FindUsagesRequest request) {
final MessageBus messageBus = provider.getMachineMessageBus();
return createFromAsyncRequest(callback -> {
final MessageBuilder builder = new MessageBuilder(POST, pathToService + "find/usages");
builder.data(dtoFactory.toJson(request)).header(CONTENTTYPE, APPLICATION_JSON).header(ACCEPT, APPLICATION_JSON);
loader.show();
try {
messageBus.send(builder.build(), new RequestCallback<FindUsagesResponse>(unmarshallerFactory.newWSUnmarshaller(FindUsagesResponse.class)) {
@Override
protected void onSuccess(FindUsagesResponse result) {
loader.hide();
callback.onSuccess(result);
}
@Override
protected void onFailure(Throwable exception) {
loader.hide();
callback.onFailure(exception);
}
});
} catch (WebSocketException e) {
loader.hide();
callback.onFailure(e);
}
});
}
use of org.eclipse.che.ide.websocket.MessageBus in project che by eclipse.
the class MavenMessagesHandler method handleOperations.
private void handleOperations(final DtoFactory factory, final WsAgentStateController wsAgentStateController) {
eventBus.addHandler(WsAgentStateEvent.TYPE, new WsAgentStateHandler() {
@Override
public void onWsAgentStarted(WsAgentStateEvent event) {
wsAgentStateController.getMessageBus().then(new Operation<MessageBus>() {
@Override
public void apply(MessageBus messageBus) throws OperationException {
try {
handleMavenServerEvents(messageBus);
handleMavenArchetype(messageBus);
} catch (WebSocketException e) {
dependencyResolver.hide();
Log.error(getClass(), e);
}
}
});
}
@Override
public void onWsAgentStopped(WsAgentStateEvent event) {
dependencyResolver.hide();
}
});
eventBus.addHandler(WorkspaceStoppedEvent.TYPE, new WorkspaceStoppedEvent.Handler() {
@Override
public void onWorkspaceStopped(WorkspaceStoppedEvent event) {
dependencyResolver.hide();
}
});
}
use of org.eclipse.che.ide.websocket.MessageBus in project che by eclipse.
the class ResolvingMavenProjectStateHolder method onWsAgentStarted.
@Override
public void onWsAgentStarted(WsAgentStateEvent event) {
wsAgentStateController.getMessageBus().then(new Operation<MessageBus>() {
@Override
public void apply(MessageBus messageBus) throws OperationException {
try {
messageBus.subscribe(MAVEN_CHANEL_NAME, new MessageHandler() {
@Override
public void onMessage(String message) {
Jso jso = Jso.deserialize(message);
int type = jso.getFieldCastedToInteger("$type");
MessageType messageType = MessageType.valueOf(type);
if (messageType == START_STOP) {
handleStartStop(factory.createDtoFromJson(message, StartStopNotification.class));
}
}
});
} catch (WebSocketException e) {
Log.error(getClass(), e);
}
}
});
}
Aggregations