-
Notifications
You must be signed in to change notification settings - Fork 45
/
SiriusWebStarterConfiguration.java
97 lines (86 loc) · 3.72 KB
/
SiriusWebStarterConfiguration.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.sirius.web.starter;
import java.util.concurrent.Executors;
import org.eclipse.sirius.components.collaborative.api.ISubscriptionManagerFactory;
import org.eclipse.sirius.components.collaborative.editingcontext.api.IEditingContextEventProcessorExecutorServiceProvider;
import org.eclipse.sirius.components.collaborative.representations.SubscriptionManager;
import org.eclipse.sirius.components.graphql.api.IExceptionWrapper;
import org.eclipse.sirius.components.graphql.ws.api.IGraphQLWebSocketHandlerListener;
import org.eclipse.sirius.components.web.concurrent.DelegatingRequestContextExecutorService;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
/**
* AutoConfiguration of the Sirius Web application.
*
* @author sbegaudeau
*/
@AutoConfiguration
@ComponentScan(basePackages = {
"org.eclipse.sirius.components.core",
"org.eclipse.sirius.components.collaborative",
"org.eclipse.sirius.components.emf",
"org.eclipse.sirius.components.graphql",
"org.eclipse.sirius.components.web",
"org.eclipse.sirius.web.domain",
"org.eclipse.sirius.web.application",
"org.eclipse.sirius.web.infrastructure",
"org.eclipse.sirius.web.starter"
})
public class SiriusWebStarterConfiguration {
@Bean
@ConditionalOnMissingBean(IEditingContextEventProcessorExecutorServiceProvider.class)
public IEditingContextEventProcessorExecutorServiceProvider editingContextEventProcessorExecutorServiceProvider() {
return editingContext -> {
var executorService = Executors.newSingleThreadExecutor((Runnable runnable) -> {
Thread thread = Executors.defaultThreadFactory().newThread(runnable);
thread.setName("Editing context " + editingContext.getId());
return thread;
});
return new DelegatingRequestContextExecutorService(executorService);
};
}
@Bean
@ConditionalOnMissingBean(ISubscriptionManagerFactory.class)
public ISubscriptionManagerFactory subscriptionManagerFactory() {
return SubscriptionManager::new;
}
@Bean
@ConditionalOnMissingBean
public IExceptionWrapper exceptionWrapper() {
return new ExceptionWrapper();
}
@Bean
@ConditionalOnMissingBean(IGraphQLWebSocketHandlerListener.class)
public IGraphQLWebSocketHandlerListener graphQLWebSocketHandlerListener() {
return new IGraphQLWebSocketHandlerListener() {
@Override
public void handleTextMessage(WebSocketSession session, TextMessage message) {
// Do nothing
}
@Override
public void afterConnectionEstablished(WebSocketSession session) {
// Do nothing
}
@Override
public void afterConnectionClosed(WebSocketSession session, CloseStatus status) {
// Do nothing
}
};
}
}