Bug 5383

Summary: Support @PostConstruct and @PreDestroy callbacks in batch artifacts
Product: jbatch Reporter: cf126330
Component: SPECAssignee: ScottKurz
Status: NEW ---    
Severity: enhancement CC: issues, thomas_haines
Priority: P5    
Version: 1   
Target Milestone: ---   
Hardware: All   
OS: All   

Description cf126330 2013-09-11 15:30:26 UTC
PostConstruct and PreDestroy callbacks enable applications to influence how batch container manages batch artifact lifecycles.  Both classes are in already Java SE 6:


For example,

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

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 1 ScottKurz 2016-03-24 14:39:42 UTC
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.