gerrit/gerrit-pgm
Saša Živkov 10969b185d Inject InitStep members again before calling postRun.
InitStep instances are created before a site is initialized and the set
of injectable objects is quite small at that time. This also limits
what could be done from the postRun method, which is invoked after site
is initialized.

After the site is initialized a sysInjector is already available and
we could make use of it in order to perform optional injection and
provide the InitStep.postRun with additional useful objects. This way
the postRun can perform many more things than before.

To make use of the optional injection in an InitStep one would write
something like:

  public class MyInitStep implements InitStep {

    private final ConsoleUI ui;

    @Inject
    MyInitStep(ConsoleUI ui) {
      this.ui = ui;
    }

    @Override
    public void run() throws Exception {
      ...
    }

    @Inject(optional = true)
    void setGitRepositoryManager(GitRepositoryManager git) {
      gitManager = git;
    }

    @Override
    public void postRun() throws Exception {
      // make use of gitManager
    }
  }

Change-Id: Idfd04747f45db8c7e0aee892175245ccd280d5e0
2014-11-07 09:58:39 +01:00
..
src Inject InitStep members again before calling postRun. 2014-11-07 09:58:39 +01:00
BUCK Install all packaged plugins automatically on auto site init 2014-02-21 13:24:09 +01:00