Skip to content

Process Adapters

ProcessAdapters are classes that enable to call a reader or a writer inside a processor class. They are useful to read several files at once: the first file will be read through the reader as usual while the second file will be read during the processing. Two such classes are: ProcessReaderAdapter that will supply ReadInProcess method, while ProcessWriterAdapter will supply WriteInProcess method. Both classes have an Adaptee property that references the actual reader or writer, and that will be wired through Unity setup will need the StepContextManager.

Example 7.22. Example ProcessAdapter Wiring


// Process adapter
container.StepScopeRegistration<IProcessWriter<EmployeeBO>, ProcessWriterAdapter<EmployeeBO>>("AdapterKey")
    .Property("StepContextManager").Reference<IContextManager>(BatchConstants.StepContextManagerName)
    .Property("Adaptee").Reference<IItemWriter<EmployeeBO>>("WriterKey")
    .Register();

// Actual writer
container.StepScopeRegistration<IItemWriter<EmployeeBO>, FlatFileItemWriter<EmployeeBO>>("WriterKey")
    .Property("Resource").Resource("#{settings[…]}")
    
    .Register();