refresh abstract method
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:
- Prepare Refresh: Validate state, prepare internal structures
- Obtain Fresh Factory: Create new pod factory instance
- Prepare Factory: Register core pods and configuration
- Post-process Factory: Apply pod factory post-processors
- Register Processors: Register pod-aware processors
- Initialize Message Source: Set up internationalization
- Init Application Event Bus: Initialize event system
- Register Listeners: Register application event listeners
- Instantiate Singletons: Create non-lazy singleton pods
- 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 configuredPodDefinitionException
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();