All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.deephaven.server.session.ScriptSessionModule Maven / Gradle / Ivy

The newest version!
//
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
//
package io.deephaven.server.session;

import dagger.Module;
import dagger.Provides;
import io.deephaven.configuration.Configuration;
import io.deephaven.engine.util.ScriptSession;

import javax.inject.Provider;
import javax.inject.Singleton;
import java.util.Map;

/**
 * Provides a {@link ScriptSession}.
 */
@Module
public class ScriptSessionModule {

    @Provides
    @Singleton
    public static ScriptSession provideScriptSession(Map> scriptTypes) {
        // Check which script language is configured
        String scriptSessionType = Configuration.getInstance().getProperty("deephaven.console.type");

        // Emit an error if the selected language isn't provided
        if (!scriptTypes.containsKey(scriptSessionType)) {
            throw new IllegalArgumentException("Console type not found: " + scriptSessionType);
        }
        return scriptTypes.get(scriptSessionType).get();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy