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

Investigate Background Bean Initialization #735

Open
SentryMan opened this issue Nov 16, 2024 · 1 comment
Open

Investigate Background Bean Initialization #735

SentryMan opened this issue Nov 16, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@SentryMan
Copy link
Collaborator

It seems spring has added background initialization as a core DI feature.

Something like this would synergize well with beans that take some time to construct, allowing for other beans to be wired during the same time.

@SentryMan SentryMan added the enhancement New feature or request label Nov 16, 2024
@SentryMan
Copy link
Collaborator Author

SentryMan commented Nov 17, 2024

My initial thought is to generate background beans like this

@Generated("io.avaje.inject.generator")
public final class BackgroundBean$DI  {

  public static void build(Builder builder) {
    if (builder.isAddBeanFor(BackgroundBean.class)) {
      builder.registerProvider(CompletableFuture.supplyAsync(() -> {
        var bean = new BackgroundBean();
        return bean;
      })::join); 
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant