Skip to content

Commit

Permalink
update launcher setup
Browse files Browse the repository at this point in the history
Issue #288
  • Loading branch information
rsoika committed Sep 1, 2023
1 parent d27d3af commit 8a721dd
Show file tree
Hide file tree
Showing 14 changed files with 2,690 additions and 1,755 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"type": "java",
"name": "Open-BPMN Server (Debug Mode)",
"request": "launch",
"mainClass": "org.openbpmn.glsp.BPMNServerLauncher",
"mainClass": "org.openbpmn.glsp.launch.BPMNServerLauncher",
"projectName": "open-bpmn.server",
"args": [
"--port",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,53 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
/********************************************************************************
* Copyright (c) 2019-2023 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { bindAsService } from '@eclipse-glsp/protocol';
import { GLSPServerContribution } from '@eclipse-glsp/theia-integration/lib/node';
import { ContainerModule } from '@theia/core/shared/inversify';
import { BPMNGLSPServerContribution } from './bpmn-glsp-server-contribution';
import { BPMNGLSPSocketServerContribution } from './bpmn-glsp-server-contribution';

export default new ContainerModule(bind => {
bind(BPMNGLSPServerContribution).toSelf().inSingletonScope();
bind(GLSPServerContribution).toService(BPMNGLSPServerContribution);
if (isDirectWebSocketConnection()) {
return;
}
bindAsService(bind, GLSPServerContribution, BPMNGLSPSocketServerContribution);
});

const directWebSocketArg = '--directWebSocket';
/**
* Utility function to parse if the frontend should connect directly to a running GLSP WebSocket Server instance
* and skip the binding of the backend contribution.
* i.e. if the {@link directWebSocketArg `--directWebSocket`} argument has been passed.
* @returns `true` if the {@link directWebSocketArg `--directWebSocket`} argument has been set.
*/
function isDirectWebSocketConnection(): boolean {
const args = process.argv.filter(a => a.toLowerCase().startsWith(directWebSocketArg.toLowerCase()));
return args.length > 0;
}

export const integratedArg = '--integratedNode';

/**
* Utility function to parse if the frontend should connect to a GLSP server running directly in the backend
* i.e. if the {@link integratedArg `--integratedNode`} argument has been passed.
* @returns `true` if the {@link integratedArg `--integratedNode`} argument has been set.
*/
export function isIntegratedNodeServer(): boolean {
const args = process.argv.filter(a => a.toLowerCase().startsWith(integratedArg.toLowerCase()));
return args.length > 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,45 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { getPort, GLSPSocketServerContribution, GLSPSocketServerContributionOptions } from '@eclipse-glsp/theia-integration/lib/node';
import {
getPort,
getWebSocketPath,
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 PORT_ARG_KEY = 'GLSP_PORT';
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.0.3-SNAPSHOT-glsp.jar')
);

@injectable()
export class BPMNGLSPServerContribution extends GLSPSocketServerContribution {
export class BPMNGLSPSocketServerContribution extends GLSPSocketServerContribution {
readonly id = BPMNLanguage.contributionId;

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

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

0 comments on commit 8a721dd

Please sign in to comment.