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

Provide io.deephaven.appmode.ApplicationState.Factory via a Set #3037

Merged
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 @@ -5,12 +5,18 @@

import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import dagger.multibindings.ElementsIntoSet;
import dagger.multibindings.IntoSet;
import io.deephaven.appmode.ApplicationState;
import io.deephaven.appmode.ApplicationState.Factory;
import io.deephaven.engine.util.ScriptSession;
import io.deephaven.server.session.TicketResolver;
import io.grpc.BindableService;

import java.util.LinkedHashSet;
import java.util.Set;

@Module
public interface AppModeModule {
@Binds
Expand All @@ -29,4 +35,12 @@ public interface AppModeModule {

@Binds
ApplicationStates bindApplicationStates(ApplicationTicketResolver resolver);

@Provides
@ElementsIntoSet
static Set<Factory> providesFactoriesFromServiceLoader() {
final Set<Factory> set = new LinkedHashSet<>();
ApplicationState.Factory.loadFromServiceFactory().forEach(set::add);
return set;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import io.deephaven.appmode.ApplicationConfig;
import io.deephaven.appmode.ApplicationState;
import io.deephaven.appmode.ApplicationState.Factory;
import io.deephaven.engine.liveness.LivenessScopeStack;
import io.deephaven.engine.util.ScriptSession;
import io.deephaven.internal.log.LoggerFactory;
Expand All @@ -19,6 +20,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Set;

public class ApplicationInjector {

Expand All @@ -27,19 +29,22 @@ public class ApplicationInjector {
private final Provider<ScriptSession> scriptSessionProvider;
private final ApplicationTicketResolver ticketResolver;
private final ApplicationState.Listener applicationListener;
private final Set<Factory> factories;

@Inject
public ApplicationInjector(
final Provider<ScriptSession> scriptSessionProvider,
final ApplicationTicketResolver ticketResolver,
final ApplicationState.Listener applicationListener) {
final ApplicationState.Listener applicationListener,
final Set<Factory> factories) {
this.scriptSessionProvider = Objects.requireNonNull(scriptSessionProvider);
this.ticketResolver = ticketResolver;
this.applicationListener = applicationListener;
this.factories = factories;
}

public void run() throws IOException, ClassNotFoundException {
for (ApplicationState.Factory factory : ApplicationState.Factory.loadFromServiceFactory()) {
for (ApplicationState.Factory factory : factories) {
loadApplicationFactory(factory);
}

Expand Down