addPodFactoryPostProcessor abstract method

void addPodFactoryPostProcessor(
  1. PodFactoryPostProcessor processor
)

Adds a PodFactoryPostProcessor to be applied to the pod factory.

Pod factory post-processors are powerful extension points that can modify pod definitions, change configuration, or apply custom transformations to the pod factory before pods are instantiated.

Common Use Cases:

  • Property Resolution: Process ${...} placeholders in pod definitions
  • Configuration Enhancement: Add additional metadata to pod definitions
  • Validation: Validate pod definitions before instantiation
  • Proxy Creation: Wrap pods with proxies for AOP or other concerns

Example:

class CustomPostProcessor implements PodFactoryPostProcessor {
  @override
  Future<void> postProcessFactory(ConfigurableListablePodFactory factory) async {
    // Modify pod definitions before instantiation
    final names = factory.getDefinitionNames();
    for (final name in names) {
      final definition = factory.getDefinition(name);
      
      // Apply custom logic
      if (definition.type.hasAnnotation<Profiled>()) {
        definition.lifecycle.isLazy = true;
      }
    }
  }
}

// Registration
context.addPodFactoryPostProcessor(CustomPostProcessor());
context.addPodFactoryPostProcessor(PropertySourcesPlaceholderProcessor());

Execution Order:

Processors are executed in priority order as defined by the Ordered interface or @Order annotation.

Implementation

void addPodFactoryPostProcessor(PodFactoryPostProcessor processor);