refresh abstract method

Future<void> refresh()

Refreshes this application context:

  • Loads or reloads pod definitions.
  • Instantiates singletons.
  • Initializes application components.
  • Publishes lifecycle events.

The refresh process is the core initialization sequence that transitions the context from configured to active state.

Refresh Sequence:

  1. Prepare Refresh: Validate state, prepare internal structures
  2. Obtain Fresh Factory: Create new pod factory instance
  3. Prepare Factory: Register core pods and configuration
  4. Post-process Factory: Apply pod factory post-processors
  5. Register Processors: Register pod-aware processors
  6. Initialize Message Source: Set up internationalization
  7. Init Application Event Bus: Initialize event system
  8. Register Listeners: Register application event listeners
  9. Instantiate Singletons: Create non-lazy singleton pods
  10. Finish Refresh: Complete initialization, publish events

Example:

try {
  await context.refresh();
  print('Context refreshed successfully');
  print('Active pods: ${context.getPodDefinitionNames()}');
} on PodDefinitionException catch (e) {
  print('Pod configuration error: ${e.message}');
  exit(1);
} on Exception catch (e) {
  print('Context refresh failed: $e');
  exit(1);
}

Throws:

  • IllegalStateException if the context has not been properly configured
  • PodDefinitionException if pod definitions are invalid
  • Various runtime exceptions if initialization fails

Important:

This method should be called exactly once during the context lifecycle.

Implementation

Future<void> refresh();