Bug 5383 - Support @PostConstruct and @PreDestroy callbacks in batch artifacts
Support @PostConstruct and @PreDestroy callbacks in batch artifacts
Status: NEW
Product: jbatch
Classification: Unclassified
Component: SPEC
1
All All
: P5 enhancement
: ---
Assigned To: ScottKurz
future
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-09-11 15:30 UTC by cf126330
Modified: 2013-10-25 19:43 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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:

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.