Skip to content

Commit

Permalink
More review points
Browse files Browse the repository at this point in the history
  • Loading branch information
devinrsmith committed Oct 4, 2023
1 parent cd9b816 commit 3a51bc8
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 53 deletions.
7 changes: 0 additions & 7 deletions plugin/src/main/java/io/deephaven/plugin/js/JsPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,4 @@
*/
public interface JsPlugin extends Plugin {

<T> T walk(Visitor<T> visitor);

interface Visitor<T> {
T visit(JsPluginPackagePath packageRoot);

T visit(JsPluginManifestPath manifestRoot);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,4 @@ public final Path manifestJson() {
public final JsPluginPackagePath packagePath(String name) {
return JsPluginPackagePath.of(path().resolve(name));
}

@Override
public final <T> T walk(JsPlugin.Visitor<T> visitor) {
return visitor.visit(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,4 @@ public static JsPluginPackagePath of(Path packageRoot) {
public final Path packageJson() {
return path().resolve(PACKAGE_JSON);
}

@Override
public final <T> T walk(JsPlugin.Visitor<T> visitor) {
return visitor.visit(this);
}
}
35 changes: 10 additions & 25 deletions server/jetty/src/main/java/io/deephaven/server/jetty/JsPlugins.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package io.deephaven.server.jetty;

import io.deephaven.plugin.js.JsPlugin;
import io.deephaven.plugin.js.JsPlugin.Visitor;
import io.deephaven.plugin.js.JsPluginManifestPath;
import io.deephaven.plugin.js.JsPluginPackagePath;

Expand Down Expand Up @@ -37,33 +36,19 @@ public URI filesystem() {

@Override
public void accept(JsPlugin jsPlugin) {
final IOException ioException = jsPlugin.walk(new CopyToZipFilesystem());
if (ioException != null) {
throw new UncheckedIOException(ioException);
}
}

private class CopyToZipFilesystem implements Visitor<IOException> {

@Override
public IOException visit(JsPluginPackagePath srcPackagePath) {
try {
copy(srcPackagePath, zipFs);
return null;
} catch (IOException e) {
return e;
try {
if (jsPlugin instanceof JsPluginPackagePath) {
copy((JsPluginPackagePath) jsPlugin, zipFs);
return;
}
}

@Override
public IOException visit(JsPluginManifestPath srcManifestPath) {
try {
copyAll(srcManifestPath, zipFs);
return null;
} catch (IOException e) {
return e;
if (jsPlugin instanceof JsPluginManifestPath) {
copyAll((JsPluginManifestPath) jsPlugin, zipFs);
return;
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
throw new IllegalStateException("Unexpected JsPlugin class: " + jsPlugin.getClass());
}

private static void copy(JsPluginPackagePath srcPackagePath, JsPluginsZipFilesystem dest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.Iterator;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

/**
* Provides the {@link JsPluginManifestPath manifest path} of {@value JS_PLUGIN_RESOURCE_BASE} if the configuration
Expand Down Expand Up @@ -54,10 +53,7 @@ static Set<Registration> providesConfigDirRegistration() {
@Provides
@ElementsIntoSet
static Set<Registration> providesPackageRoots() {
return jsPluginsPackageRoots()
.stream()
.map(Registration.class::cast)
.collect(Collectors.toSet());
return Set.copyOf(jsPluginsPackageRoots());
}

// deephaven.jsPlugins.resourceBase (manifest root)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public interface DeephavenApiServerComponent {
DeephavenApiServer getServer();

interface Builder<Self extends Builder<Self, Component>, Component extends DeephavenApiServerComponent> {

@BindsInstance
Self withOut(@Nullable @Named("out") PrintStream out);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import dagger.BindsInstance;
import dagger.Component;
import io.deephaven.client.ClientDefaultsModule;
import io.deephaven.configuration.Configuration;
import io.deephaven.engine.context.TestExecutionContext;
import io.deephaven.engine.liveness.LivenessScope;
import io.deephaven.engine.liveness.LivenessScopeStack;
Expand Down Expand Up @@ -65,9 +64,6 @@ interface Builder {
@BindsInstance
Builder withServerConfig(ServerConfig serverConfig);

@BindsInstance
Builder withConfiguration(Configuration config);;

@BindsInstance
Builder withOut(@Named("out") PrintStream out);

Expand Down Expand Up @@ -109,7 +105,6 @@ public void setUp() throws Exception {

serverComponent = DaggerDeephavenApiServerTestBase_TestComponent.builder()
.withServerConfig(config)
.withConfiguration(Configuration.getInstance())
.withAuthorizationProvider(new CommunityAuthorizationProvider())
.withOut(System.out)
.withErr(System.err)
Expand Down

0 comments on commit 3a51bc8

Please sign in to comment.