Bug 4366

Summary: @BatchProperty only way to inject properties into an artifact?
Product: jbatch Reporter: chrisschaefer
Component: sourceAssignee: cvignola
Severity: enhancement CC: issues
Priority: P5    
Version: 1   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS   

Description chrisschaefer 2012-11-21 23:33:03 UTC
This in a way is similar to the @Named requirement (http://java.net/bugzilla/show_bug.cgi?id=4304). It seems the only way to inject batch properties into an artifact is by marking fields with @BatchProperty.

The 6.3.1 @BatchProperty example shows:

public class MyItemReaderImpl {
    @BatchProperty String fname="/tmp/input.txt";

This seems somewhat limiting as for example w/ Spring the wiring is done on the bean/artifact itself. So for instance in Spring Batch MyItemReaderImpl's fname value could get wired via XML through a constructor argument, setters or on fields (additionally) with annotations along with type conversion, bean scoping, etc. http://java.net/bugzilla/show_bug.cgi?id=4353 also raises a good point on String only properties and manual conversion.
Comment 1 chrisschaefer 2012-11-21 23:40:14 UTC
I could open another issue if needed, but the same seems to apply for BatchContext.
Comment 2 cvignola 2012-12-07 00:05:57 UTC
In version 1 of this spec,  yes @BatchContext and @BatchProperty are the only way.  There is room for future improvement,  but we need to stay focused on essentials to get version 1 out.