[GLASSFISH-20406]  @Inject @BatchProperty not working Created: 25/Apr/13  Updated: 26/Apr/13  Resolved: 26/Apr/13

Status: Resolved
Project: glassfish
Component/s: batch
Affects Version/s: 4.0_b85
Fix Version/s: None

Type: Bug Priority: Major
Reporter: myfear Assignee: Mahesh Kannan
Resolution: Works as designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Win 7, JDK 7


Tags: fishcat

 Description   

Trying to use a batch property in a reader:

@Named("entryReader")
public class EntryReader extends AbstractItemReader {

@Inject
@BatchProperty(name = "file.url")
String fileName;
//...
}

Either defining it as

<reader ref="entryReader" >
<properties>
<property name="file.url" value="#

{jobParameters['file.url']}

" />
</properties>
</reader>

with

JobOperator jo = BatchRuntime.getJobOperator();
Properties jobParams = new Properties();
jobParams.put("file.url", "testdata.txt");
long jobId = jo.start("extract-cities", jobParams);

nor directly defining it in the job.xml works.
It always resolves to null.

Try the example here:
https://www.dropbox.com/s/zujizha4jhkhtzd/jbatchexample.zip

The EntryReader is where the injection should take place.



 Comments   
Comment by arunkumar_s [ 25/Apr/13 ]

If you can use the inject variable(filename) for verifying values in the open() method of the Reader, rather than the constructor, then it returns the values from passed JobParameters.

Comment by myfear [ 26/Apr/13 ]

That actually worked. Close please.

Comment by Mahesh Kannan [ 26/Apr/13 ]

Closing this issue as the submitter has confirmed that this is indeed working

Generated at Mon Dec 05 04:12:48 UTC 2016 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.