1. Domino Brix
  2. Startup & tasks

Define startup tasks

Startup tasks run after Brix.get().init(config) and before presenters activate. Extend BrixStartupTask, implement run(), and call complete() when finished.

			@BrixPresenter
public class AdminPresenter extends Presenter<AdminView> {
  @Override
  public Set<String> getRoles() {
    return Set.of("admin");
  }

  @Override
  public Authorizer getAuthorizer() {
    return RolesAllowedAuthorizer.INSTANCE;
  }
}

		

Ordering

  • order() groups tasks; same order runs in parallel.
  • complete() is mandatory—tasks block the next group until they finish.
  • After the final group completes, the onComplete callback passed to start(...) fires.

Provide tasks via DI

Bind tasks with the @BrixTask qualifier so you can inject the set into your entry point.

			SecurityContext sc = (SecurityContext) Brix.get().getCoreComponent().core().getSecurityContext();
sc.setUser(new MyUser());
sc.setUnauthorizedAccessHandler(() -> window.alert("Access denied"));

		

Bootstrap with tasks

			public class DepartmentAuthorizer implements Authorizer {
  @Override
  public boolean isAuthorized(IsSecurityContext context, HasRoles hasRoles) {
    return context.isAuthenticated()
        && context.getUser().getAttributes().get("department").ifTypeIs(String.class, dept -> {
             return dept.equals("engineering");
           });
  }
}

		

Classpath discovery (domino-auto)

Annotate tasks with @AutoService(BrixStartupTask.class) to generate a BrixStartupTask_ServiceLoader helper. This lets you start Brix without wiring DI modules.

			@BrixPresenter
@RolesAllowed({"admin", "support"})
public class AdminPresenter extends Presenter<AdminView> {
  // getAuthorizer() and getRoles() are generated by the processor
}

		

Tips

  • Call complete() even for synchronous work.
  • Use higher order() values for tasks that depend on earlier ones.
  • Use getContextWait() if you need to coordinate multiple async operations inside one task.

We are a group of passionate people who love what we do

Donate & Support Us