refresh abstract method

void refresh()

Starts the context: registers the beans, checks them and creates every singleton that is not lazy. Call it once.

In order: check the required properties; load the modules (their @PropertySource files and conditions decide which beans exist); run the bean factory post-processors; register the bean post-processors; set up the message source and the event multicaster; register the listeners; check the bean graph (a missing or ambiguous dependency or a cycle fails here, before any constructor runs); create the eager singletons; start the auto-startup SmartLifecycle beans; publish ContextRefreshedEvent.

When a step fails, the lifecycle beans already started are stopped, the created singletons are destroyed, the error is rethrown and the context becomes unusable. Like Spring's GenericApplicationContext, a second call throws a StateError, also after a failed refresh. An init callback (@PostConstruct, afterPropertiesSet, init method) that returns a Future fails the refresh: use refreshAsync for those.

final context = AnnotationConfigApplicationContext([appBeans])
  ..refresh();

Spring (Java):

var context = new AnnotationConfigApplicationContext();
context.register(AppConfig.class);
context.refresh();

Implementation

void refresh();