Skip to content

Commit a63a856

Browse files
author
Vitalii Parfonov
committed
CHE-1081: remove workspace id from services that deployed on wsagent (eclipse-che#1268)
remove workspace id from services that deployed on wsagent remove workspace Id usage in wsagent services in dashboard Add init params for websocket endpoint and eventbus end point It allow has different format of URL on wsmaster with ws-id like path param and on wsagent without it Signed-off-by: Vitaly Parfonov <vparfonov@codenvy.com>
1 parent b0c8ddd commit a63a856

97 files changed

Lines changed: 500 additions & 2230 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

assembly/assembly-ide-war/pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,7 @@
343343
</goals>
344344
<configuration>
345345
<tasks>
346-
<echo append="false" file="${project.build.directory}/classes/org/eclipse/che/ide/ext/help/client/BuildInfo.properties">
347-
revision = ${revision}
346+
<echo append="false" file="${project.build.directory}/classes/org/eclipse/che/ide/ext/help/client/BuildInfo.properties">revision = ${revision}
348347
buildTime = ${timestamp}
349348
version = ${project.version}</echo>
350349
</tasks>

assembly/assembly-wsagent-war/src/main/webapp/WEB-INF/web.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@
2121
<param-name>org.everrest.websocket.context</param-name>
2222
<param-value>/ext</param-value>
2323
</context-param>
24+
<context-param>
25+
<param-name>org.eclipse.che.websocket.endpoint</param-name>
26+
<param-value>/ws</param-value>
27+
</context-param>
28+
<context-param>
29+
<param-name>org.eclipse.che.eventbus.endpoint</param-name>
30+
<param-value>/eventbus/</param-value>
31+
</context-param>
2432
<listener>
2533
<listener-class>org.eclipse.che.inject.CheBootstrap</listener-class>
2634
</listener>

assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/web.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@
2121
<param-name>org.everrest.websocket.context</param-name>
2222
<param-value>/api</param-value>
2323
</context-param>
24+
<context-param>
25+
<param-name>org.eclipse.che.websocket.endpoint</param-name>
26+
<param-value>/ws/{ws-id}</param-value>
27+
</context-param>
28+
<context-param>
29+
<param-name>org.eclipse.che.eventbus.endpoint</param-name>
30+
<param-value>/eventbus/</param-value>
31+
</context-param>
2432

2533
<servlet>
2634
<servlet-name>IDE</servlet-name>

core/che-core-api-core/src/main/java/org/eclipse/che/everrest/ServerContainerInitializeListener.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,15 @@ public class ServerContainerInitializeListener implements ServletContextListener
7373
private ServerEndpointConfig wsServerEndpointConfig;
7474
private ServerEndpointConfig eventbusServerEndpointConfig;
7575
private String websocketContext;
76+
private String websocketEndPoint;
77+
private String eventBusEndPoint;
7678

7779
@Override
7880
public final void contextInitialized(ServletContextEvent sce) {
7981
final ServletContext servletContext = sce.getServletContext();
8082
websocketContext = MoreObjects.firstNonNull(servletContext.getInitParameter("org.everrest.websocket.context"), "");
83+
websocketEndPoint = MoreObjects.firstNonNull(servletContext.getInitParameter("org.eclipse.che.websocket.endpoint"), "");
84+
eventBusEndPoint = MoreObjects.firstNonNull(servletContext.getInitParameter("org.eclipse.che.eventbus.endpoint"), "");
8185
webApplicationDeclaredRoles = new WebApplicationDeclaredRoles(servletContext);
8286
everrestConfiguration = (EverrestConfiguration)servletContext.getAttribute(EVERREST_CONFIG_ATTRIBUTE);
8387
if (everrestConfiguration == null) {
@@ -115,7 +119,7 @@ protected ServerEndpointConfig createWsServerEndpointConfig(ServletContext servl
115119
final List<Class<? extends Decoder>> decoders = new LinkedList<>();
116120
encoders.add(OutputMessageEncoder.class);
117121
decoders.add(InputMessageDecoder.class);
118-
final ServerEndpointConfig endpointConfig = create(CheWSConnection.class, websocketContext+"/ws/{ws-id}")
122+
final ServerEndpointConfig endpointConfig = create(CheWSConnection.class, websocketContext + websocketEndPoint)
119123
.configurator(createConfigurator()).encoders(encoders).decoders(decoders).build();
120124
endpointConfig.getUserProperties().put(EVERREST_PROCESSOR_ATTRIBUTE, getEverrestProcessor(servletContext));
121125
endpointConfig.getUserProperties().put(EVERREST_CONFIG_ATTRIBUTE, getEverrestConfiguration(servletContext));
@@ -128,7 +132,7 @@ protected ServerEndpointConfig createEventbusServerEndpointConfig(ServletContext
128132
final List<Class<? extends Decoder>> decoders = new LinkedList<>();
129133
encoders.add(OutputMessageEncoder.class);
130134
decoders.add(InputMessageDecoder.class);
131-
final ServerEndpointConfig endpointConfig = create(CheWSConnection.class, websocketContext+"/eventbus/")
135+
final ServerEndpointConfig endpointConfig = create(CheWSConnection.class, websocketContext + eventBusEndPoint)
132136
.configurator(createConfigurator()).encoders(encoders).decoders(decoders).build();
133137
endpointConfig.getUserProperties().put(EVERREST_PROCESSOR_ATTRIBUTE, getEverrestProcessor(servletContext));
134138
endpointConfig.getUserProperties().put(EVERREST_CONFIG_ATTRIBUTE, getEverrestConfiguration(servletContext));

core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/debug/DebuggerServiceClientImpl.java

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ protected DebuggerServiceClientImpl(AppContext appContext,
6666

6767
@Override
6868
public Promise<DebugSessionDto> connect(String debuggerType, Map<String, String> connectionProperties) {
69-
final String requestUrl = getBaseUrl() + "?type=" + debuggerType;
69+
final String requestUrl = getBaseUrl(null) + "?type=" + debuggerType;
7070
return asyncRequestFactory.createPostRequest(requestUrl, null)
7171
.header(CONTENT_TYPE, APPLICATION_JSON)
7272
.data(JsonHelper.toJson(connectionProperties))
@@ -75,15 +75,15 @@ public Promise<DebugSessionDto> connect(String debuggerType, Map<String, String>
7575

7676
@Override
7777
public Promise<Void> disconnect(String id) {
78-
final String requestUrl = getBaseUrl() + "/" + id;
78+
final String requestUrl = getBaseUrl(id);
7979
return asyncRequestFactory.createDeleteRequest(requestUrl)
8080
.loader(loaderFactory.newLoader())
8181
.send();
8282
}
8383

8484
@Override
8585
public Promise<DebugSessionDto> getSessionInfo(String id) {
86-
final String requestUrl = getBaseUrl() + "/" + id;
86+
final String requestUrl = getBaseUrl(id);
8787
return asyncRequestFactory.createGetRequest(requestUrl)
8888
.send(dtoUnmarshallerFactory.newUnmarshaller(DebugSessionDto.class));
8989
}
@@ -95,36 +95,36 @@ public Promise<Void> start(String id, StartActionDto action) {
9595

9696
@Override
9797
public Promise<Void> addBreakpoint(String id, BreakpointDto breakpointDto) {
98-
final String requestUrl = getBaseUrl() + "/" + id + "/breakpoint";
98+
final String requestUrl = getBaseUrl(id) + "/breakpoint";
9999
return asyncRequestFactory.createPostRequest(requestUrl, breakpointDto)
100100
.loader(loaderFactory.newLoader())
101101
.send();
102102
}
103103

104104
@Override
105105
public Promise<List<BreakpointDto>> getAllBreakpoints(String id) {
106-
final String requestUrl = getBaseUrl() + "/" + id + "/breakpoint";
106+
final String requestUrl = getBaseUrl(id) + "/breakpoint";
107107
return asyncRequestFactory.createGetRequest(requestUrl)
108108
.loader(loaderFactory.newLoader())
109109
.send(dtoUnmarshallerFactory.newListUnmarshaller(BreakpointDto.class));
110110
}
111111

112112
@Override
113113
public Promise<Void> deleteBreakpoint(String id, LocationDto locationDto) {
114-
final String requestUrl = getBaseUrl() + "/" + id + "/breakpoint";
114+
final String requestUrl = getBaseUrl(id) + "/breakpoint";
115115
final String params = "?target=" + locationDto.getTarget() + "&line=" + locationDto.getLineNumber();
116116
return asyncRequestFactory.createDeleteRequest(requestUrl + params).send();
117117
}
118118

119119
@Override
120120
public Promise<Void> deleteAllBreakpoints(String id) {
121-
final String requestUrl = getBaseUrl() + "/" + id + "/breakpoint";
121+
final String requestUrl = getBaseUrl(id) + "/breakpoint";
122122
return asyncRequestFactory.createDeleteRequest(requestUrl).send();
123123
}
124124

125125
@Override
126126
public Promise<StackFrameDumpDto> getStackFrameDump(String id) {
127-
final String requestUrl = getBaseUrl() + "/" + id + "/dump";
127+
final String requestUrl = getBaseUrl(id) + "/dump";
128128
return asyncRequestFactory.createGetRequest(requestUrl)
129129
.loader(loaderFactory.newLoader())
130130
.send(dtoUnmarshallerFactory.newUnmarshaller(StackFrameDumpDto.class));
@@ -137,7 +137,7 @@ public Promise<Void> resume(String id, ResumeActionDto action) {
137137

138138
@Override
139139
public Promise<SimpleValueDto> getValue(String id, VariableDto variableDto) {
140-
final String requestUrl = getBaseUrl() + "/" + id + "/value";
140+
final String requestUrl = getBaseUrl(id) + "/value";
141141
List<String> path = variableDto.getVariablePath().getPath();
142142

143143
StringBuilder params = new StringBuilder();
@@ -156,7 +156,7 @@ public Promise<SimpleValueDto> getValue(String id, VariableDto variableDto) {
156156

157157
@Override
158158
public Promise<Void> setValue(String id, VariableDto variableDto) {
159-
final String requestUrl = getBaseUrl() + "/" + id + "/value";
159+
final String requestUrl = getBaseUrl(id) + "/value";
160160
return asyncRequestFactory.createPutRequest(requestUrl, variableDto)
161161
.loader(loaderFactory.newLoader())
162162
.send();
@@ -179,20 +179,23 @@ public Promise<Void> stepOut(String id, StepOutActionDto action) {
179179

180180
@Override
181181
public Promise<String> evaluate(String id, String expression) {
182-
String requestUrl = getBaseUrl() + "/" + id + "/evaluation";
182+
String requestUrl = getBaseUrl(id) + "/evaluation";
183183
String params = "?expression=" + URL.encodeQueryString(expression);
184184
return asyncRequestFactory.createGetRequest(requestUrl + params)
185185
.loader(loaderFactory.newLoader())
186186
.send(new StringUnmarshaller());
187187
}
188188

189-
private String getBaseUrl() {
190-
DevMachine devMachine = appContext.getDevMachine();
191-
return devMachine.getWsAgentBaseUrl() + "/debugger/" + devMachine.getWorkspace();
189+
private String getBaseUrl(String id) {
190+
final String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/debugger";
191+
if (id != null) {
192+
return url + "/" + id;
193+
}
194+
return url;
192195
}
193196

194197
protected Promise<Void> performAction(String id, ActionDto actionDto) {
195-
final String requestUrl = getBaseUrl() + "/" + id;
198+
final String requestUrl = getBaseUrl(id);
196199
return asyncRequestFactory.createPostRequest(requestUrl, actionDto)
197200
.loader(loaderFactory.newLoader())
198201
.send();

core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/machine/DevMachine.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,7 @@ public String getWsAgentWebSocketUrl() {
7171
String url = server.getUrl();
7272
String extUrl = url.substring(url.indexOf(':'), url.length());
7373
final String protocol = Window.Location.getProtocol().equals("https:") ? "wss" : "ws";
74-
return protocol
75-
+ extUrl
76-
+ (extUrl.endsWith("/") ? "ws/" : "/ws/")
77-
+ getWorkspace();
74+
return protocol + extUrl + (extUrl.endsWith("/") ? "ws" : "/ws");
7875
} else {
7976
//should not be
8077
String message = "Reference " + Constants.WSAGENT_REFERENCE + " not found in DevMachine description";

core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/project/ProjectImportersServiceClientImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public ProjectImportersServiceClientImpl(AsyncRequestFactory asyncRequestFactory
3333

3434
@Override
3535
public void getProjectImporters(DevMachine devMachine, AsyncRequestCallback<ProjectImporterData> callback) {
36-
asyncRequestFactory.createGetRequest(devMachine.getWsAgentBaseUrl() + "/project-importers/" + devMachine.getWorkspace())
36+
asyncRequestFactory.createGetRequest(devMachine.getWsAgentBaseUrl() + "/project-importers")
3737
.header(HTTPHeader.CONTENT_TYPE, MimeType.APPLICATION_JSON)
3838
.send(callback);
3939
}

0 commit comments

Comments
 (0)