Skip to content
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
Expand Up @@ -85,6 +85,11 @@ public <T> void registerResource(Key<T> key, Consumer<? super T> close)
closeables.addBinding().toProvider(new ResourceCloser<T>(key, close));
}

public void registerCloseable(AutoCloseable instance)
{
closeables.addBinding().toInstance(instance);
}

private static class ResourceCloser<T>
implements Provider<AutoCloseable>
{
Expand Down
5 changes: 5 additions & 0 deletions testing/trino-server-dev/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
<artifactId>trino-main</artifactId>
</dependency>

<dependency>
<groupId>io.trino</groupId>
<artifactId>trino-plugin-toolkit</artifactId>
</dependency>

<dependency>
<groupId>io.trino</groupId>
<artifactId>trino-spi</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@
import com.google.inject.Scopes;
import io.trino.server.PluginManager.PluginsProvider;

import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;

import static com.google.inject.multibindings.OptionalBinder.newOptionalBinder;
import static io.airlift.configuration.ConfigBinder.configBinder;
import static io.trino.plugin.base.ClosingBinder.closingBinder;

public final class DevelopmentServer
extends Server
Expand All @@ -29,11 +35,24 @@ private DevelopmentServer() {}
@Override
protected Iterable<? extends Module> getAdditionalModules()
{
return ImmutableList.of(binder -> {
newOptionalBinder(binder, PluginsProvider.class).setBinding()
.to(DevelopmentPluginsProvider.class).in(Scopes.SINGLETON);
configBinder(binder).bindConfig(DevelopmentLoaderConfig.class);
});
try {
Path pluginPath = Files.createTempDirectory("plugins");

return ImmutableList.of(binder -> {
newOptionalBinder(binder, PluginsProvider.class).setBinding()
.to(DevelopmentPluginsProvider.class).in(Scopes.SINGLETON);
configBinder(binder).bindConfig(DevelopmentLoaderConfig.class);

// Use a temporary directory to satisfy configuration validation
configBinder(binder).bindConfigDefaults(ServerPluginsProviderConfig.class, config ->
config.setInstalledPluginsDirs(ImmutableList.of(pluginPath.toFile())));

closingBinder(binder).registerCloseable(() -> Files.deleteIfExists(pluginPath));
});
}
catch (IOException e) {
throw new UncheckedIOException(e);
}
}

public static void main(String[] args)
Expand Down
Loading