Skip to content

Commit

Permalink
alligned client code to EMF Theia Project template
Browse files Browse the repository at this point in the history
Issue #303
  • Loading branch information
rsoika committed Nov 20, 2023
1 parent 6af7a10 commit 4c5b35c
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 71 deletions.
32 changes: 31 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,39 @@
"vmArgs": [
"--add-opens",
"java.base/java.util=ALL-UNNAMED",
],
],
"console": "internalConsole",
"internalConsoleOptions": "openOnSessionStart"
},
{
"type": "node",
"request": "launch",
"name": "Launch Workflow Theia Backend (External GLSP Server)",
"program": "${workspaceRoot}/open-bpmn.glsp-client/open-bpmn-app/src-gen/backend/main.js",
"args": [
"--loglevel=debug",
"--port=3000",
"--no-cluster",
"--WF_GLSP=5007",
"--debug",
"--app-project-path=${workspaceRoot}/open-bpmn.glsp-client/open-bpmn-app",
"--root-dir=${workspaceRoot}/open-bpmn.glsp-client/workspace"
],
"env": {
"NODE_ENV": "development"
},
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/open-bpmn.glsp-client/node_modules/@theia/*/lib/**/*.js",
"${workspaceRoot}/open-bpmn.glsp-client/node_modules/@eclipse-glsp/*/lib/**/*.js",
"${workspaceRoot}/open-bpmn.glsp-client/open-bpmn-app/lib/**/*.js",
"${workspaceRoot}/open-bpmn.glsp-client/open-bpmn-theia/lib/**/*.js",
"${workspaceRoot}/open-bpmn.glsp-client/open-bpmn-glsp/lib/**/*.js",
"${workspaceRoot}/open-bpmn.glsp-client/open-bpmn-app/src-gen/**/*.js"
],
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
}
]
}
38 changes: 38 additions & 0 deletions open-bpmn.glsp-client/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Workflow Theia Backend (External GLSP Server)",
"program": "${workspaceRoot}/open-bpmn-app/src-gen/backend/main.js",
"args": [
"--loglevel=debug",
"--port=3000",
"--no-cluster",
"--WF_GLSP=5007",
"--debug",
"--app-project-path=${workspaceRoot}/open-bpmn-app",
"--root-dir=${workspaceRoot}/workspace"
],
"env": {
"NODE_ENV": "development"
},
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/node_modules/@theia/*/lib/**/*.js",
"${workspaceRoot}/node_modules/@eclipse-glsp/*/lib/**/*.js",
"${workspaceRoot}/open-bpmn-app/lib/**/*.js",
"${workspaceRoot}/open-bpmn-theia/lib/**/*.js",
"${workspaceRoot}/open-bpmn-glsp/lib/**/*.js",
"${workspaceRoot}/open-bpmn-app/src-gen/**/*.js"
],
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
}
]
}
24 changes: 12 additions & 12 deletions open-bpmn.glsp-client/open-bpmn-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
},
"dependencies": {
"@open-bpmn/open-bpmn-theia": "1.2.0",
"@theia/core": "1.40.1",
"@theia/editor": "1.40.1",
"@theia/filesystem": "1.40.1",
"@theia/markers": "1.40.1",
"@theia/messages": "1.40.1",
"@theia/monaco": "1.40.1",
"@theia/navigator": "1.40.1",
"@theia/preferences": "1.40.1",
"@theia/process": "1.40.1",
"@theia/terminal": "1.40.1",
"@theia/workspace": "1.40.1"
"@theia/core": "1.39.0",
"@theia/editor": "1.39.0",
"@theia/filesystem": "1.39.0",
"@theia/markers": "1.39.0",
"@theia/messages": "1.39.0",
"@theia/monaco": "1.39.0",
"@theia/navigator": "1.39.0",
"@theia/preferences": "1.39.0",
"@theia/process": "1.39.0",
"@theia/terminal": "1.39.0",
"@theia/workspace": "1.39.0"
},
"devDependencies": {
"@theia/cli": "1.40.1"
"@theia/cli": "1.39.0"
},
"theia": {
"target": "browser"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
********************************************************************************/
import { Args, MaybePromise } from '@eclipse-glsp/client';

import { BaseGLSPClientContribution, WebSocketConnectionOptions } from '@eclipse-glsp/theia-integration/lib/browser';
import { BaseGLSPClientContribution } from '@eclipse-glsp/theia-integration/lib/browser';
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
import { inject, injectable } from '@theia/core/shared/inversify';
import { BPMNLanguage } from '../common/bpmn-language';



export interface BPMNInitializeOptions {
timestamp: Date;
message: string;
Expand All @@ -39,27 +41,5 @@ export class BPMNGLSPClientContribution extends BaseGLSPClientContribution {
['message']: 'Custom Options Available'
};
}

protected override async getWebSocketConnectionOptions(): Promise<WebSocketConnectionOptions | undefined> {
const webSocketPort = await this.getWebSocketPortFromEnv();
if (webSocketPort) {
return {
path: this.id,
port: webSocketPort
};
}
return undefined;
}

protected async getWebSocketPortFromEnv(): Promise<number | undefined> {
const envVar = await this.envVariablesServer.getValue('WEBSOCKET_PORT');
if (envVar && envVar.value) {
const webSocketPort = Number.parseInt(envVar.value, 10);
if (isNaN(webSocketPort) || webSocketPort < 0 || webSocketPort > 65535) {
throw new Error('Value of environment variable WEBSOCKET_PORT is not a valid port');
}
return webSocketPort;
}
return undefined;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import { BPMNLanguage } from '../../common/bpmn-language';
export class BPMNDiagramConfiguration extends GLSPDiagramConfiguration {
diagramType: string = BPMNLanguage.diagramType;

configureContainer(container: Container, ...containerConfiguration: ContainerConfiguration): Container {
configureContainer(container: Container, ...containerConfiguration: ContainerConfiguration): void {
initializeBPMNDiagramContainer(container, ...containerConfiguration);
return container;
//return container;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import {
getPort, getWebSocketPath,
getPort,
GLSPSocketServerContribution,
GLSPSocketServerContributionOptions
} from '@eclipse-glsp/theia-integration/lib/node';
import { injectable } from '@theia/core/shared/inversify';
import { join, resolve } from 'path';
import { BPMNLanguage } from '../common/bpmn-language';

//export const DEFAULT_PORT = 5007;
export const DEFAULT_PORT = 0;
export const DEFAULT_PORT = 5007;
//export const DEFAULT_PORT = 0;
export const PORT_ARG_KEY = 'GLSP_PORT';
export const WEBSOCKET_PATH_ARG_KEY = 'PATH_PATH';
//export const WEBSOCKET_PATH_ARG_KEY = 'PATH_PATH';
export const LOG_DIR = join(__dirname, '..', '..', 'logs');
const JAR_FILE = resolve(
join(__dirname, '..', '..', '..', '..', 'open-bpmn.glsp-server', 'target', 'open-bpmn.server-1.2.0-SNAPSHOT-glsp.jar')
Expand All @@ -35,29 +35,29 @@ const JAR_FILE = resolve(
export class BPMNGLSPSocketServerContribution extends GLSPSocketServerContribution {
readonly id = BPMNLanguage.contributionId;

// Java Server
// createContributionOptions(): Partial<GLSPSocketServerContributionOptions> {
// return {
// executable: JAR_FILE,
// additionalArgs: ['--consoleLog', 'false', '--fileLog', 'true', '--logDir', LOG_DIR],
// socketConnectionOptions: {
// port: getPort(PORT_ARG_KEY, DEFAULT_PORT)
// }
// };
// }


//Java Server
createContributionOptions(): Partial<GLSPSocketServerContributionOptions> {
return {
executable: JAR_FILE,
additionalArgs: ['--no-consoleLog', '--fileLog', 'true', '--logDir', LOG_DIR],
additionalArgs: ['--consoleLog', 'false', '--fileLog', 'true', '--logDir', LOG_DIR],
socketConnectionOptions: {
port: getPort(PORT_ARG_KEY, DEFAULT_PORT),
path: getWebSocketPath(WEBSOCKET_PATH_ARG_KEY)
port: getPort(PORT_ARG_KEY, DEFAULT_PORT)
}
};
}


// createContributionOptions(): Partial<GLSPSocketServerContributionOptions> {
// return {
// executable: JAR_FILE,
// additionalArgs: ['--no-consoleLog', '--fileLog', 'true', '--logDir', LOG_DIR],
// socketConnectionOptions: {
// port: getPort(PORT_ARG_KEY, DEFAULT_PORT),
// path: getWebSocketPath(WEBSOCKET_PATH_ARG_KEY)
// }
// };
// }

// NodeJS Sever (??)
// createContributionOptions(): Partial<GLSPSocketServerContributionOptions> {
// return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
import org.apache.logging.log4j.Level;
import org.eclipse.glsp.server.launch.DefaultCLIParser;

public class BPMNCLIParser extends DefaultCLIParser {
public class BPMNCLIParserOld extends DefaultCLIParser {
public static final String OPTION_WEBSOCKET = "websocket";
public static final String OPTION_JETTY_LOG_LEVEL = "jettyLogLevel";

public static final class BPMNLaunchOptions {
public static final Level WEBSOCKET_LOG_LEVEL = Level.INFO;
}

public BPMNCLIParser(final String[] args, final String processName)
public BPMNCLIParserOld(final String[] args, final String processName)
throws ParseException {
super(args, BPMNCLIParser.getDefaultOptions(), processName);
super(args, BPMNCLIParserOld.getDefaultOptions(), processName);
}

public boolean isWebsocket() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@

import org.apache.commons.cli.ParseException;
import org.eclipse.glsp.server.di.ServerModule;
import org.eclipse.glsp.server.launch.DefaultCLIParser;
import org.eclipse.glsp.server.launch.GLSPServerLauncher;
import org.eclipse.glsp.server.launch.SocketGLSPServerLauncher;
import org.eclipse.glsp.server.utils.LaunchUtil;
import org.eclipse.glsp.server.websocket.WebsocketServerLauncher;
//import org.openbpmn.glsp.BPMNDiagramModule;
import org.openbpmn.glsp.BPMNDiagramModule;

public final class BPMNServerLauncher {
Expand All @@ -30,21 +31,31 @@ private BPMNServerLauncher() {
public static void main(final String[] args) {
String processName = "open-bpmn.server-X.X.X-glsp.jar";
try {
BPMNCLIParser parser = new BPMNCLIParser(args, processName);
DefaultCLIParser parser = new DefaultCLIParser(args, processName);
LaunchUtil.configure(parser);

int port = parser.parsePort();
String host = parser.parseHostname();
ServerModule bpmnServerModule = new BPMNServerModule()
ServerModule bpmnServerModule = new ServerModule()
.configureDiagramModule(new BPMNDiagramModule());

GLSPServerLauncher launcher = parser.isWebsocket()
? new WebsocketServerLauncher(bpmnServerModule, "/bpmn", parser.parseWebsocketLogLevel())
: new SocketGLSPServerLauncher(bpmnServerModule);
GLSPServerLauncher launcher = new SocketGLSPServerLauncher(bpmnServerModule);
launcher.start("localhost", port);
// BPMNCLIParserOld parser = new BPMNCLIParserOld(args, processName);
// int port = parser.parsePort();
// String host = parser.parseHostname();
// ServerModule bpmnServerModule = new BPMNServerModule()
// .configureDiagramModule(new BPMNDiagramModule());

// GLSPServerLauncher launcher = parser.isWebsocket()
// ? new WebsocketServerLauncher(bpmnServerModule, "/bpmn",
// parser.parseWebsocketLogLevel())
// : new SocketGLSPServerLauncher(bpmnServerModule);

launcher.start(host, port, parser);
// launcher.start(host, port, parser);
} catch (ParseException ex) {
ex.printStackTrace();
System.out.println();
LaunchUtil.printHelp(processName, BPMNCLIParser.getDefaultOptions());
LaunchUtil.printHelp(processName, BPMNCLIParserOld.getDefaultOptions());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.eclipse.glsp.server.protocol.GLSPServer;
import org.openbpmn.glsp.BPMNGLSPServer;

public class BPMNServerModule extends ServerModule {
public class BPMNServerModuleOld extends ServerModule {

@Override
protected Class<? extends GLSPServer> bindGLSPServer() {
Expand Down

0 comments on commit 4c5b35c

Please sign in to comment.