Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#95 Adapt example to conform to GLSPServerLauncher refactoring #62

Merged
merged 2 commits into from
Aug 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/org.eclipse.glsp.example.workflow/src/main/java/org/eclipse/glsp/example/workflow/launch/WorkflowServerLauncher.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_EXCLUDE_TEST_CODE" value="true"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.glsp.example.workflow.launch.WorkflowServerLauncher"/>
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="org.eclipse.glsp.example.workflow"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="--logLevel=debug"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.glsp.example.workflow"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/org.eclipse.glsp.example.workflow/src/main/java/org/eclipse/glsp/example/workflow/launch/WorkflowServerLauncher.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_EXCLUDE_TEST_CODE" value="true"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.glsp.example.workflow.launch.WorkflowServerLauncher"/>
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="org.eclipse.glsp.example.workflow"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="--logLevel=debug&#10;--websocket&#10;--port=8081"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.glsp.example.workflow"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
</launchConfiguration>
2 changes: 1 addition & 1 deletion server/org.eclipse.glsp.example.workflow/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.eclipse.glsp.example.workflow.ExampleServerLauncher</mainClass>
<mainClass>org.eclipse.glsp.example.workflow.WorkflowServerLauncher</mainClass>
</transformer>
</transformers>
<filters>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/********************************************************************************
* Copyright (c) 2020 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
* https://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
********************************************************************************/
package org.eclipse.glsp.example.workflow.launch;

import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.eclipse.glsp.server.launch.DefaultCLIParser;

public class WorkflowCLIParser extends DefaultCLIParser {
public static final String OPTION_WEBSOCKET = "websocket";

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

public boolean isWebsocket() { return hasOption(OPTION_WEBSOCKET); }

public static Options getDefaultOptions() {
Options options = DefaultCLIParser.getDefaultOptions();
options.addOption(null, OPTION_WEBSOCKET, false,
"Use websocket launcher instead of default launcher. [default='false']");
return options;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,42 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
package org.eclipse.glsp.example.workflow;
package org.eclipse.glsp.example.workflow.launch;

import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import java.io.IOException;

import org.apache.commons.cli.ParseException;
import org.eclipse.elk.alg.layered.options.LayeredMetaDataProvider;
import org.eclipse.glsp.example.workflow.WorkflowGLSPModule;
import org.eclipse.glsp.layout.ElkLayoutEngine;
import org.eclipse.glsp.server.launch.DefaultGLSPServerLauncher;
import org.eclipse.glsp.server.launch.GLSPServerLauncher;
import org.eclipse.glsp.server.utils.LaunchUtil;
import org.eclipse.glsp.server.websocket.WebsocketServerLauncher;

public final class ExampleServerLauncher {
private ExampleServerLauncher() {}
public final class WorkflowServerLauncher {
private WorkflowServerLauncher() {}

@SuppressWarnings("uncommentedmain")
public static void main(final String[] args) {
configureLogger();
ElkLayoutEngine.initialize(new LayeredMetaDataProvider());
GLSPServerLauncher launcher;
String processName = "WorkflowExampleGlspServer";
try {
WorkflowCLIParser parser = new WorkflowCLIParser(args, processName);
LaunchUtil.configure(parser);
ElkLayoutEngine.initialize(new LayeredMetaDataProvider());

if (args.length == 1 && args[0].equals("websocket")) {
launcher = new WebsocketServerLauncher(new WorkflowGLSPModule(), "/workflow");
launcher.start("localhost", 8081);
int port = parser.parsePort();

} else {
launcher = new DefaultGLSPServerLauncher(new WorkflowGLSPModule());
launcher.start("localhost", 5007);
}
GLSPServerLauncher launcher = parser.isWebsocket()
? new WebsocketServerLauncher(new WorkflowGLSPModule(), "/workflow")
: new DefaultGLSPServerLauncher(new WorkflowGLSPModule());

}
launcher.start("localhost", port);

public static void configureLogger() {
Logger root = Logger.getRootLogger();
if (!root.getAllAppenders().hasMoreElements()) {
root.addAppender(new ConsoleAppender(
new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN)));
} catch (ParseException | IOException ex) {
ex.printStackTrace();
System.out.println();
LaunchUtil.printHelp(processName, WorkflowCLIParser.getDefaultOptions());
}
root.setLevel(Level.DEBUG);

}
}