Skip to content

Commit 3bba361

Browse files
authored
GLSP-975 Ensure generic GLSP Server implementation (#44)
- Introduce a common subclass for jsonrpc based ServerLaunchers - Move out jsonrpc implementation details from `GLSPServer` implementation into the `JsonRpcGLSPServerLauncher`. This ensures that the Server implementation itself is independent from the chosen communication channel and can reused for other use cases like direct invocation in a node backend or orthogonal communication channels like REST or gRPC. - Update to latest @eclipse-glsp/protocol version and consume shared server interface types from there - Ensure that the `@eclipse-glsp-examples/workflow-server` package is properly indexed - Add entry points for browser and node - Move rpc-server initialization out of index files into app files. Also: Update example applications to ensure that promise rejections/errors are properly catched. Part of eclipse-glsp/glsp#975 Requires eclipse-glsp/glsp-client#245 Contributed on behalf of STMicroelectronics
1 parent dc6b980 commit 3bba361

Some content is hidden

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

43 files changed

+2057
-1326
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
- Renamed the services and handlers of the direct GModel library => consistent use of `GModel` prefix
2929
- The `ModelState` interface no longer has an `isDirty` flag. Dirty state is now handled by the `CommandStack`
3030
- [server] Default port has changed from 5007 (and 8081 for websocket) to 0, which implies autoassignment by the OS [#42](https://github.com/eclipse-glsp/glsp-server-node/pull/42)
31+
- [server] Refactored `GLSPServer` and `GLSPServerLauncher` API [#44](https://github.com/eclipse-glsp/glsp-server-node/pull/44) - Contributed on behalf of STMicroelectronics
32+
- Server type definitions are now consumed from `@eclipse-glsp/protocol`
33+
- `GLSPServer` implementation is no longer relies on json-rpc implementation details.
34+
- JSON-RPC setup is now done with `JsonRpcGLSPServerLauncher`
3135

3236
## [v1.0.0 - 30/06/2022](https://github.com/eclipse-glsp/glsp-server-node/releases/tag/v1.0.0)
3337

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/********************************************************************************
2+
* Copyright (c) 2023 STMicroelectronics and others.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0 which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the Eclipse
10+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
11+
* with the GNU Classpath Exception which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
********************************************************************************/
16+
export * from './lib/browser/index';
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/********************************************************************************
2+
* Copyright (c) 2023 STMicroelectronics and others.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0 which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the Eclipse
10+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
11+
* with the GNU Classpath Exception which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
********************************************************************************/
16+
'use strict';
17+
18+
module.exports = require('./lib/browser/index');

examples/workflow-server/node.d.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/********************************************************************************
2+
* Copyright (c) 2023 STMicroelectronics and others.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0 which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the Eclipse
10+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
11+
* with the GNU Classpath Exception which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
********************************************************************************/
16+
export * from './lib/node/index';

examples/workflow-server/node.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/********************************************************************************
2+
* Copyright (c) 2023 STMicroelectronics and others.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0 which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the Eclipse
10+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
11+
* with the GNU Classpath Exception which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
********************************************************************************/
16+
'use strict';
17+
18+
module.exports = require('./lib/node/index');

examples/workflow-server/src/browser/app.ts

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,30 @@
1313
*
1414
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
1515
********************************************************************************/
16+
import 'reflect-metadata';
17+
1618
import { configureELKLayoutModule } from '@eclipse-glsp/layout-elk';
17-
import { createAppModule, Logger, LoggerFactory, LogLevel, WorkerServerLauncher } from '@eclipse-glsp/server/browser';
19+
import { createAppModule, LogLevel, WorkerServerLauncher } from '@eclipse-glsp/server/browser';
1820
import { Container } from 'inversify';
1921
import { WorkflowLayoutConfigurator } from '../common/layout/workflow-layout-configurator';
2022
import { WorkflowDiagramModule, WorkflowServerModule } from '../common/workflow-diagram-module';
2123
import { WorkflowMockModelStorage } from './mock-model-storage';
2224

2325
export async function launch(argv?: string[]): Promise<void> {
24-
let logger: Logger | undefined;
25-
26-
try {
27-
const appContainer = new Container();
28-
appContainer.load(createAppModule({ logLevel: LogLevel.info }));
26+
const appContainer = new Container();
27+
appContainer.load(createAppModule({ logLevel: LogLevel.info }));
2928

30-
logger = appContainer.get<LoggerFactory>(LoggerFactory)('WorkflowServerApp');
31-
const launcher = appContainer.resolve(WorkerServerLauncher);
32-
const elkLayoutModule = configureELKLayoutModule({ algorithms: ['layered'], layoutConfigurator: WorkflowLayoutConfigurator });
29+
const launcher = appContainer.resolve(WorkerServerLauncher);
30+
const elkLayoutModule = configureELKLayoutModule({ algorithms: ['layered'], layoutConfigurator: WorkflowLayoutConfigurator });
3331

34-
const serverModule = new WorkflowServerModule().configureDiagramModule(
35-
new WorkflowDiagramModule(() => WorkflowMockModelStorage),
36-
elkLayoutModule
37-
);
32+
const serverModule = new WorkflowServerModule().configureDiagramModule(
33+
new WorkflowDiagramModule(() => WorkflowMockModelStorage),
34+
elkLayoutModule
35+
);
3836

39-
launcher.configure(serverModule);
37+
launcher.configure(serverModule);
4038

41-
await launcher.start({});
42-
} catch (error) {
43-
(logger ?? console).error('Error in workflow server launcher:', error);
44-
}
39+
await launcher.start({});
4540
}
41+
42+
launch().catch(error => console.error('Error in workflow server launcher:', error));

examples/workflow-server/src/browser/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,5 @@
1313
*
1414
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
1515
********************************************************************************/
16-
import 'reflect-metadata';
17-
import { launch } from './app';
18-
19-
launch();
16+
export * from '../common/index';
17+
export * from './mock-model-storage';
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/********************************************************************************
2+
* Copyright (c) 2023 STMicroelectronics and others.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0 which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the Eclipse
10+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
11+
* with the GNU Classpath Exception which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
********************************************************************************/
16+
17+
export * from './graph-extension';
18+
export * from './handler/create-activity-node-handler';
19+
export * from './handler/create-automated-task-handler';
20+
export * from './handler/create-category-handler';
21+
export * from './handler/create-decision-node-handler';
22+
export * from './handler/create-edge-handler';
23+
export * from './handler/create-fork-node-handler';
24+
export * from './handler/create-fork-or-join-node-handler';
25+
export * from './handler/create-join-node-handler';
26+
export * from './handler/create-manual-task-handler';
27+
export * from './handler/create-merge-node-handler';
28+
export * from './handler/create-task-handler';
29+
export * from './handler/create-weighted-edge-handler';
30+
export * from './handler/create-workflow-node-operation-handler';
31+
export * from './handler/grid-snapper';
32+
export * from './index';
33+
export * from './labeledit/workflow-label-edit-validator';
34+
export * from './layout/workflow-layout-configurator';
35+
export * from './marker/workflow-model-validator';
36+
export * from './model/workflow-navigation-target-resolver';
37+
export * from './provider/abstract-next-or-previous-navigation-target-provider';
38+
export * from './provider/next-node-navigation-target-provider';
39+
export * from './provider/node-documentation-navigation-target-provider';
40+
export * from './provider/previous-node-navigation-target-provider';
41+
export * from './provider/workflow-command-palette-action-provider';
42+
export * from './provider/workflow-context-menu-item-provider';
43+
export * from './taskedit/edit-task-operation-handler';
44+
export * from './taskedit/task-edit-context-provider';
45+
export * from './taskedit/task-edit-validator';
46+
export * from './util/model-types';
47+
export * from './workflow-diagram-configuration';
48+
export * from './workflow-diagram-module';
49+
export * from './workflow-glsp-server';
50+
export * from './workflow-popup-factory';

examples/workflow-server/src/node/app.ts

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,33 @@
1313
*
1414
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
1515
********************************************************************************/
16+
import 'reflect-metadata';
17+
1618
import { configureELKLayoutModule } from '@eclipse-glsp/layout-elk';
17-
import {
18-
createAppModule,
19-
GModelStorage,
20-
Logger,
21-
LoggerFactory,
22-
SocketServerLauncher,
23-
WebSocketServerLauncher
24-
} from '@eclipse-glsp/server/node';
19+
import { createAppModule, GModelStorage, SocketServerLauncher, WebSocketServerLauncher } from '@eclipse-glsp/server/node';
2520
import { Container } from 'inversify';
21+
2622
import { WorkflowLayoutConfigurator } from '../common/layout/workflow-layout-configurator';
2723
import { WorkflowDiagramModule, WorkflowServerModule } from '../common/workflow-diagram-module';
2824
import { createWorkflowCliParser } from './workflow-cli-parser';
2925

30-
export async function launch(argv?: string[]): Promise<void> {
31-
let logger: Logger | undefined;
32-
try {
33-
const options = createWorkflowCliParser().parse(argv);
34-
const appContainer = new Container();
35-
appContainer.load(createAppModule(options));
26+
async function launch(argv?: string[]): Promise<void> {
27+
const options = createWorkflowCliParser().parse(argv);
28+
const appContainer = new Container();
29+
appContainer.load(createAppModule(options));
3630

37-
logger = appContainer.get<LoggerFactory>(LoggerFactory)('WorkflowServerApp');
31+
const elkLayoutModule = configureELKLayoutModule({ algorithms: ['layered'], layoutConfigurator: WorkflowLayoutConfigurator });
32+
const serverModule = new WorkflowServerModule().configureDiagramModule(new WorkflowDiagramModule(() => GModelStorage), elkLayoutModule);
3833

39-
const elkLayoutModule = configureELKLayoutModule({ algorithms: ['layered'], layoutConfigurator: WorkflowLayoutConfigurator });
40-
const serverModule = new WorkflowServerModule().configureDiagramModule(
41-
new WorkflowDiagramModule(() => GModelStorage),
42-
elkLayoutModule
43-
);
44-
45-
if (options.webSocket) {
46-
const launcher = appContainer.resolve(WebSocketServerLauncher);
47-
launcher.configure(serverModule);
48-
launcher.start({ port: options.port, host: options.host, path: 'workflow' });
49-
} else {
50-
const launcher = appContainer.resolve(SocketServerLauncher);
51-
launcher.configure(serverModule);
52-
launcher.start({ port: options.port, host: options.host });
53-
}
54-
} catch (error) {
55-
(logger ?? console).error('Error in workflow server launcher:', error);
34+
if (options.webSocket) {
35+
const launcher = appContainer.resolve(WebSocketServerLauncher);
36+
launcher.configure(serverModule);
37+
launcher.start({ port: options.port, host: options.host, path: 'workflow' });
38+
} else {
39+
const launcher = appContainer.resolve(SocketServerLauncher);
40+
launcher.configure(serverModule);
41+
launcher.start({ port: options.port, host: options.host });
5642
}
5743
}
44+
45+
launch(process.argv).catch(error => console.error('Error in workflow server launcher:', error));

examples/workflow-server/src/node/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,5 @@
1313
*
1414
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
1515
********************************************************************************/
16-
import 'reflect-metadata';
17-
import { launch } from './app';
18-
19-
launch(process.argv);
16+
export * from '../common/index';
17+
export * from './workflow-cli-parser';

0 commit comments

Comments
 (0)