What is the order of execution of the binded classes in google guice

31 views Asked by At

I've something like the following:

public class ValidationModule extends AbstractModule {
 @Override
 protected void configure() {
    Multibinder<Validator> validatorMultibinder = Multibinder.newSetBinder(binder(),
        Validator.class, Names.named("mainValidators"));
    validatorMultibinder.addBinding().to(FirstValidator.class);
    validatorMultibinder.addBinding().to(SecondValidator.class);
 }
}

I'm a newbie to google/guice and I would like to understand the order of these validator validate function will be executed. Are they going to run from top to bottom or the opposite?

1

There are 1 answers

0
Amro Abdalla On

After running the module in the application I have found that the object that I bounded to "mainValidators" was holding the classes in the order from top to bottom. So when I iterated over them they were in the following order.

  1. FirstValidator
  2. SecondValidator