Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
tortmayr committed Sep 16, 2021
1 parent dc63031 commit edaf8a7
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ default CompletableFuture<Void> dispatch(final ActionMessage message) {
* Processes the given action, received from the specified clientId, by dispatching it to all registered handlers.
* </p>
*
* @param clientId The client from which the action was received
* @param action The action that should be dispatched.
* @return
* A {@link CompletableFuture} indicating when the action processing is complete
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
import org.eclipse.glsp.server.actions.SetViewportAction;
import org.eclipse.glsp.server.actions.TriggerEdgeCreationAction;
import org.eclipse.glsp.server.actions.TriggerNodeCreationAction;
import org.eclipse.glsp.server.di.scope.DiagramGlobal;
import org.eclipse.glsp.server.di.scope.DiagramGlobalScope;
import org.eclipse.glsp.server.di.scope.DiagramGlobalSingleton;
import org.eclipse.glsp.server.diagram.DiagramConfiguration;
import org.eclipse.glsp.server.diagram.RequestTypeHintsActionHandler;
import org.eclipse.glsp.server.diagram.ServerConfigurationContribution;
Expand Down Expand Up @@ -117,7 +117,7 @@
* <ul>
* <li>{@link String} annotated with @{@link DiagramType}
* <li>{@link String} annotated with @{@link ClientId}
* <li>{@link DiagramGlobal} bound as Scope
* <li>{@link DiagramGlobalSingleton} bound as Scope
* <li>{@link DiagramConfiguration}
* <li>{@link ServerConfigurationContribution}
* <li>{@link GModelState}
Expand Down Expand Up @@ -163,7 +163,7 @@ protected void configureBase() {
bindClientId();
bindDiagramGobalScope();
// Configurations
bind(DiagramConfiguration.class).to(bindDiagramConfiguration()).in(DiagramGlobal.class);
bind(DiagramConfiguration.class).to(bindDiagramConfiguration()).in(DiagramGlobalSingleton.class);
bind(ServerConfigurationContribution.class).to(bindServerConfigurationContribution()).in(Singleton.class);
// Model-related bindings
bind(GModelState.class).to(bindGModelState()).in(Singleton.class);
Expand Down Expand Up @@ -205,7 +205,6 @@ protected void configureBase() {
bindOptionally(PopupModelFactory.class, bindPopupModelFactory());
bindOptionally(LayoutEngine.class, bindLayoutEngine());
bindOptionally(GraphExtension.class, bindGraphExtension());

}

protected void bindDiagramType() {
Expand All @@ -217,7 +216,7 @@ protected void bindClientId() {
}

protected void bindDiagramGobalScope() {
bindScope(DiagramGlobal.class, new DiagramGlobalScope.NullImpl());
bindScope(DiagramGlobalSingleton.class, new DiagramGlobalScope.NullImpl());
}

protected abstract Class<? extends DiagramConfiguration> bindDiagramConfiguration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@
* The server module is the central configuration artifact for configuring the server injector (i.e. main injector). For
* each application connecting to the server process a new server injector is created. The server module provides the
* base bindings necessary for setting up the base {@link GLSPServer} infrastructure. In addition, it is used to
* configure the set of {@link DiagramModule}s. Diagram modules are used to create the diagram session specific child
* configure the set of {@link DiagramModule}s. Diagram modules are used to create the diagram-session-specific child
* injector when the
* {@link GLSPServer#initializeClientSession(org.eclipse.glsp.server.protocol.InitializeClientSessionParameters)}
* method is called.
*
* All bindings inside of the {@link ServerModule#configure()} method are encapsulated into submethods which makes it
* All bindings inside of the {@link ServerModule#configure()} method are delegated to separate methods which makes it
* easy to override a specific binding in subclasses.
*
* p>The following bindings are provided:
Expand All @@ -71,7 +71,7 @@ public class ServerModule extends GLSPModule {

/**
* Configure a new {@link DiagramModule} for this server. A diagram module represents the base configuration artifact
* for configuring a diagram-language specific client session injector. The diagram type provided
* for configuring a diagram-language-specific client session injector. The diagram type provided
* {@link DiagramModule#getDiagramType()} is used to retrieve the correct diagram module when the {@link GLSPServer}
* initialises a new client session.
* The given diagram module and all (optional) additional modules will be combined to one merged module. If bindings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* A {@link Scope} implementation that is used in GLSP for sharing instances across multiple diagram injectors of the
* same diagram type. A diagram injector is an injector with an installed {@link DiagramModule}. The
* {@link DiagramGlobal} annotation is used to annotated bindings that should be made available to all injectors with
* {@link DiagramGlobalSingleton} annotation is used to annotated bindings that should be made available to all injectors with
* the same diagram type as Singleton.
*
* Use this scope with care. If its used on classes that inject session specific values (e.g. the clientId) it can cause
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ public DiagramGlobalScopeModule(final DiagramGlobalScope scope) {

@Override
protected void configure() {
bindScope(DiagramGlobal.class, scope);
bindScope(DiagramGlobalSingleton.class, scope);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@

/**
*
* Custom scope annotation that is used to declare bindings as diagram global. Diagram global means that one instance of
* Scope annotation to declare bindings as diagram global singleton. Diagram global singleton means that one instance of
* this class is shared across all related injectors of the same diagram type. This is used to declare diagram type
* specific singletons across all diagram session injectors (i.e. child injectors) of one GLSP server (injector).
*
*/
@Target({ TYPE, METHOD })
@Retention(RUNTIME)
@ScopeAnnotation
public @interface DiagramGlobal {}
public @interface DiagramGlobalSingleton {}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class DefaultActionDispatcher extends Disposable implements ActionDispatc
@Inject
protected ActionHandlerRegistry actionHandlerRegistry;

@Inject
@ClientId
protected String clientId;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2019-2020 EclipseSource and others.
* Copyright (c) 2019-2021 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
Expand Down Expand Up @@ -32,26 +32,27 @@
import java.util.function.Function;

import org.apache.log4j.Logger;
import org.eclipse.glsp.server.di.GLSPModule;
import org.eclipse.glsp.server.jsonrpc.GsonConfigurator;
import org.eclipse.glsp.server.di.ServerModule;
import org.eclipse.glsp.server.gson.ServerGsonConfigurator;
import org.eclipse.glsp.server.protocol.GLSPClient;
import org.eclipse.glsp.server.protocol.GLSPServer;
import org.eclipse.lsp4j.jsonrpc.Launcher;
import org.eclipse.lsp4j.jsonrpc.MessageConsumer;

import com.google.gson.GsonBuilder;
import com.google.inject.Injector;
import com.google.inject.Module;

public class DefaultGLSPServerLauncher extends GLSPServerLauncher {
public class SocketGLSPServerLauncher extends GLSPServerLauncher {
public static final String START_UP_COMPLETE_MSG = "[GLSP-Server]:Startup completed";
private static Logger log = Logger.getLogger(DefaultGLSPServerLauncher.class);
private static Logger log = Logger.getLogger(SocketGLSPServerLauncher.class);

private ExecutorService threadPool;
private AsynchronousServerSocketChannel serverSocket;
private CompletableFuture<Void> onShutdown;

public DefaultGLSPServerLauncher(final GLSPModule glspModule) {
super(glspModule);
public SocketGLSPServerLauncher(final ServerModule serverModule, final Module... additionalModules) {
super(serverModule, additionalModules);
}

@Override
Expand All @@ -77,7 +78,7 @@ public Future<Void> asyncRun(final String hostname, final int port)
@Override
public void completed(final AsynchronousSocketChannel result, final Void attachment) {
serverSocket.accept(null, this); // Prepare for the next connection
DefaultGLSPServerLauncher.this.createClientConnection(result);
SocketGLSPServerLauncher.this.createClientConnection(result);
}

@Override
Expand Down Expand Up @@ -121,7 +122,7 @@ protected void createClientConnection(final AsynchronousSocketChannel socketChan
}

protected Consumer<GsonBuilder> configureGson(final Injector injector) {
GsonConfigurator gsonConf = injector.getInstance(GsonConfigurator.class);
ServerGsonConfigurator gsonConf = injector.getInstance(ServerGsonConfigurator.class);
return (final GsonBuilder builder) -> gsonConf.configureGsonBuilder(builder);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

public class DefaultGModelState implements GModelState {

@Inject()
@Inject
@ClientId
protected String clientId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@ public final class ModuleUtil {
private ModuleUtil() {}

/**
* Mixin additional modules into a base modules. Bindings that are already present in the base module will be
* Mix in additional modules into a base modules. Bindings that are already present in the base module will be
* overwritten with the binding of the additional module.
*
* @param baseModule the base module.
* @param additionalModules the additional modules
* @return A merged (mixedin) module
*/
public static Module mixin(Module baseModule, final Module... additionalModules) {

for (Module additionalModule : additionalModules) {
baseModule = Modules.override(baseModule).with(additionalModule);
}
Expand Down

0 comments on commit edaf8a7

Please sign in to comment.