Skip to content

Assisted injection support #8461

Answered by graemerocher
natros asked this question in Q&A
Discussion options

You must be logged in to vote

closest thing here is parameterized beans:

import jakarta.inject.*;
import io.micronaut.context.annotation.*;

@Singleton
public class DialogBox {
  private final Messages messages;

  @Inject
  DialogBox(Messages messages, @Parameter String caption) {
    this.messages = messages;
    messages.log(String.format("creating DialogBox(%s)", caption));
  }

  public void show() {
    messages.log("show dialog");
  }

  public interface Factory {
    DialogBox create(String caption);
  }

  @Singleton  
  class FactoryImpl implements Factory {
        private final BeanContext context;
        FactoryImpl(BeanContext context) {
            this.context = context;
       }
       @Override
       

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@natros
Comment options

Answer selected by graemerocher
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants