Skip to content

Commit

Permalink
CHE-1081: remove workspace id from services that deployed on wsagent (#…
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
Vitalii Parfonov committed May 18, 2016
1 parent b0c8ddd commit a63a856
Show file tree
Hide file tree
Showing 97 changed files with 500 additions and 2,230 deletions.
3 changes: 1 addition & 2 deletions assembly/assembly-ide-war/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,7 @@
</goals>
<configuration>
<tasks>
<echo append="false" file="${project.build.directory}/classes/org/eclipse/che/ide/ext/help/client/BuildInfo.properties">
revision = ${revision}
<echo append="false" file="${project.build.directory}/classes/org/eclipse/che/ide/ext/help/client/BuildInfo.properties">revision = ${revision}
buildTime = ${timestamp}
version = ${project.version}</echo>
</tasks>
Expand Down
8 changes: 8 additions & 0 deletions assembly/assembly-wsagent-war/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
<param-name>org.everrest.websocket.context</param-name>
<param-value>/ext</param-value>
</context-param>
<context-param>
<param-name>org.eclipse.che.websocket.endpoint</param-name>
<param-value>/ws</param-value>
</context-param>
<context-param>
<param-name>org.eclipse.che.eventbus.endpoint</param-name>
<param-value>/eventbus/</param-value>
</context-param>
<listener>
<listener-class>org.eclipse.che.inject.CheBootstrap</listener-class>
</listener>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
<param-name>org.everrest.websocket.context</param-name>
<param-value>/api</param-value>
</context-param>
<context-param>
<param-name>org.eclipse.che.websocket.endpoint</param-name>
<param-value>/ws/{ws-id}</param-value>
</context-param>
<context-param>
<param-name>org.eclipse.che.eventbus.endpoint</param-name>
<param-value>/eventbus/</param-value>
</context-param>

<servlet>
<servlet-name>IDE</servlet-name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,15 @@ public class ServerContainerInitializeListener implements ServletContextListener
private ServerEndpointConfig wsServerEndpointConfig;
private ServerEndpointConfig eventbusServerEndpointConfig;
private String websocketContext;
private String websocketEndPoint;
private String eventBusEndPoint;

@Override
public final void contextInitialized(ServletContextEvent sce) {
final ServletContext servletContext = sce.getServletContext();
websocketContext = MoreObjects.firstNonNull(servletContext.getInitParameter("org.everrest.websocket.context"), "");
websocketEndPoint = MoreObjects.firstNonNull(servletContext.getInitParameter("org.eclipse.che.websocket.endpoint"), "");
eventBusEndPoint = MoreObjects.firstNonNull(servletContext.getInitParameter("org.eclipse.che.eventbus.endpoint"), "");
webApplicationDeclaredRoles = new WebApplicationDeclaredRoles(servletContext);
everrestConfiguration = (EverrestConfiguration)servletContext.getAttribute(EVERREST_CONFIG_ATTRIBUTE);
if (everrestConfiguration == null) {
Expand Down Expand Up @@ -115,7 +119,7 @@ protected ServerEndpointConfig createWsServerEndpointConfig(ServletContext servl
final List<Class<? extends Decoder>> decoders = new LinkedList<>();
encoders.add(OutputMessageEncoder.class);
decoders.add(InputMessageDecoder.class);
final ServerEndpointConfig endpointConfig = create(CheWSConnection.class, websocketContext+"/ws/{ws-id}")
final ServerEndpointConfig endpointConfig = create(CheWSConnection.class, websocketContext + websocketEndPoint)
.configurator(createConfigurator()).encoders(encoders).decoders(decoders).build();
endpointConfig.getUserProperties().put(EVERREST_PROCESSOR_ATTRIBUTE, getEverrestProcessor(servletContext));
endpointConfig.getUserProperties().put(EVERREST_CONFIG_ATTRIBUTE, getEverrestConfiguration(servletContext));
Expand All @@ -128,7 +132,7 @@ protected ServerEndpointConfig createEventbusServerEndpointConfig(ServletContext
final List<Class<? extends Decoder>> decoders = new LinkedList<>();
encoders.add(OutputMessageEncoder.class);
decoders.add(InputMessageDecoder.class);
final ServerEndpointConfig endpointConfig = create(CheWSConnection.class, websocketContext+"/eventbus/")
final ServerEndpointConfig endpointConfig = create(CheWSConnection.class, websocketContext + eventBusEndPoint)
.configurator(createConfigurator()).encoders(encoders).decoders(decoders).build();
endpointConfig.getUserProperties().put(EVERREST_PROCESSOR_ATTRIBUTE, getEverrestProcessor(servletContext));
endpointConfig.getUserProperties().put(EVERREST_CONFIG_ATTRIBUTE, getEverrestConfiguration(servletContext));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ protected DebuggerServiceClientImpl(AppContext appContext,

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

@Override
public Promise<Void> disconnect(String id) {
final String requestUrl = getBaseUrl() + "/" + id;
final String requestUrl = getBaseUrl(id);
return asyncRequestFactory.createDeleteRequest(requestUrl)
.loader(loaderFactory.newLoader())
.send();
}

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

@Override
public Promise<Void> addBreakpoint(String id, BreakpointDto breakpointDto) {
final String requestUrl = getBaseUrl() + "/" + id + "/breakpoint";
final String requestUrl = getBaseUrl(id) + "/breakpoint";
return asyncRequestFactory.createPostRequest(requestUrl, breakpointDto)
.loader(loaderFactory.newLoader())
.send();
}

@Override
public Promise<List<BreakpointDto>> getAllBreakpoints(String id) {
final String requestUrl = getBaseUrl() + "/" + id + "/breakpoint";
final String requestUrl = getBaseUrl(id) + "/breakpoint";
return asyncRequestFactory.createGetRequest(requestUrl)
.loader(loaderFactory.newLoader())
.send(dtoUnmarshallerFactory.newListUnmarshaller(BreakpointDto.class));
}

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

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

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

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

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

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

@Override
public Promise<String> evaluate(String id, String expression) {
String requestUrl = getBaseUrl() + "/" + id + "/evaluation";
String requestUrl = getBaseUrl(id) + "/evaluation";
String params = "?expression=" + URL.encodeQueryString(expression);
return asyncRequestFactory.createGetRequest(requestUrl + params)
.loader(loaderFactory.newLoader())
.send(new StringUnmarshaller());
}

private String getBaseUrl() {
DevMachine devMachine = appContext.getDevMachine();
return devMachine.getWsAgentBaseUrl() + "/debugger/" + devMachine.getWorkspace();
private String getBaseUrl(String id) {
final String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/debugger";
if (id != null) {
return url + "/" + id;
}
return url;
}

protected Promise<Void> performAction(String id, ActionDto actionDto) {
final String requestUrl = getBaseUrl() + "/" + id;
final String requestUrl = getBaseUrl(id);
return asyncRequestFactory.createPostRequest(requestUrl, actionDto)
.loader(loaderFactory.newLoader())
.send();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ public String getWsAgentWebSocketUrl() {
String url = server.getUrl();
String extUrl = url.substring(url.indexOf(':'), url.length());
final String protocol = Window.Location.getProtocol().equals("https:") ? "wss" : "ws";
return protocol
+ extUrl
+ (extUrl.endsWith("/") ? "ws/" : "/ws/")
+ getWorkspace();
return protocol + extUrl + (extUrl.endsWith("/") ? "ws" : "/ws");
} else {
//should not be
String message = "Reference " + Constants.WSAGENT_REFERENCE + " not found in DevMachine description";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public ProjectImportersServiceClientImpl(AsyncRequestFactory asyncRequestFactory

@Override
public void getProjectImporters(DevMachine devMachine, AsyncRequestCallback<ProjectImporterData> callback) {
asyncRequestFactory.createGetRequest(devMachine.getWsAgentBaseUrl() + "/project-importers/" + devMachine.getWorkspace())
asyncRequestFactory.createGetRequest(devMachine.getWsAgentBaseUrl() + "/project-importers")
.header(HTTPHeader.CONTENT_TYPE, MimeType.APPLICATION_JSON)
.send(callback);
}
Expand Down
Loading

0 comments on commit a63a856

Please sign in to comment.