--------------Original Comment History----------------------------
Comment from = cf126330 on 2013-09-11 15:30:26 +0000
PostConstruct and PreDestroy callbacks enable applications to influence how batch container manages batch artifact lifecycles. Both classes are in already Java SE 6:
@PostConstruct
private void checkData() throws BatchRuntimeException {
//make sure all injected properties are in place and valid.
//do the necessary data conversion from string properties to other types
//or consolidate several properties into 1
//or other initialization work
}
@PreDestroy
void cleanUp() {
//clean up
}
Currently there is no portable way to perform init and cleanup work in a batch artifact. So applications have to do it at the beginning of business processing methods, and have to take care to only perform it once.
Comment from = ScottKurz on 2016-03-24 14:39:42 +0000
If the batch artifact is loaded via CDI then PostConstruct and PreDestroy will be called.
So it seems the concern would be to standardize this across non-CDI artifact loading.
I don't think we're going to further standardize the non-CDI artifact loading but instead focus on better defining CDI integration. (Notifying @chengfang who originally opened this.)
Originally opened as bug 5383 by cf126330
--------------Original Comment History---------------------------- Comment from = cf126330 on 2013-09-11 15:30:26 +0000
PostConstruct and PreDestroy callbacks enable applications to influence how batch container manages batch artifact lifecycles. Both classes are in already Java SE 6:
http://docs.oracle.com/javase/6/docs/api/javax/annotation/PostConstruct.html http://docs.oracle.com/javase/6/docs/api/javax/annotation/PreDestroy.html
For example,
@PostConstruct private void checkData() throws BatchRuntimeException { //make sure all injected properties are in place and valid. //do the necessary data conversion from string properties to other types //or consolidate several properties into 1 //or other initialization work }
@PreDestroy void cleanUp() { //clean up }
Currently there is no portable way to perform init and cleanup work in a batch artifact. So applications have to do it at the beginning of business processing methods, and have to take care to only perform it once.
Comment from = ScottKurz on 2016-03-24 14:39:42 +0000
If the batch artifact is loaded via CDI then PostConstruct and PreDestroy will be called.
So it seems the concern would be to standardize this across non-CDI artifact loading.