Mar 12th, 2008, 10:27 AM
ExecutionContext and Statistics
In m3version, to create new statistics, my classes implemented interface StatisticProvider and the getStatistics() method.
Now, in m5, I have seen that statistics are strored in ExecutionContext.
I don't now how to add new statistics in ExecutionContext when I don't know how to get ExecutionContext in my classes.
Is the RepeatSynchronizationManager.getContext() which return ExecutionContext?
Could you help me because I haven't found enough information in javadoc about this point?
Thanks in advance.
Mar 12th, 2008, 11:09 AM
I have found that I had to put my writerClasses in property streams of SimpleStep and to overload the open method to get the executionContext and put it in a field of my classe, then I can put in it some new statistics.
Should I have to use RepeatSynchronizationManager.getContext() to pass some information between a reader and fieldSetCreator for instance or the executionContext could be used to do that?
If it is the executionContext I have to use, how to get it in my FieldSetCreator?
Thanks in advance.
Mar 12th, 2008, 12:24 PM
Shouldn't any information that needs to be passed between reader and writer by part of the item that's passed between the two?
Mar 13th, 2008, 03:00 AM
My use case is:
I have a flat file in input. I read it and I validate the fieldset in the mapper. The mapper return an object that is a "Client" or a "Rejection". I use a CompositeItemWriter to write 3 files containing parts of clients if the object is a "Client", to write a file with the readline like it is in input file if the object is a "Rejection" and to write the Rejection in a database if the object is a "Rejection".
My problem was that I hadn't the readline in String. Then I have create a class Reader that extends FlatFileItemReader and overload readline method to put it in the RepeatContext to be recovered by the fieldsetcreator which prepare the line to write in a flat file.
Have you an other solution to answer to this use case?
What is the use case of RepeatContext recovered by RepeatSynchronisationManager.getContext()?
Mar 13th, 2008, 10:10 AM
I would honestly considering writing out the rejection a 'logging' scenario and throw an exception from the FieldSetMapper, which will then wrap it in a FlatFileParsingException which includes the original line and then rethrow. It's a good point about potentially keeping the original line the FieldSet as well though, perhaps as part of the meta data that someone else has suggested.
I'm think you can keep your writer completely focused on writing to the file and let the reader write out the rejections as it reads.