java ee - EJB Stateless Initialization Pattern -
i have ejb stateless session bean. have these requirements:
- this stateless ejb should initialized @ startup
- the initialization code should make transactional access database
the problem is:
- @startup available @singleton ejbs
- @postconstruct annotation (at least on websphere) doesn't have transactional context @ point initialization code explode here!
possible solutions?
- use java ee timer seems designed periodic execution. want 1 execution @ time zero.
- use @singleton + @startup ejb initialization purposes , inject singleton ejb dependant stateless ejbs.
question:
- can 1 explain how supposed stateless ejb initialized? or has no sense? (i mean, stateless ejb supposed not have initialization state?)
- is there pattern out there says use of secondary ejb @singleton @startup idea?
initializing stateless ejb has no sense since job of java ee container. moreover, java ee 6 provides ioc pattern natively. ioc means hiding injected resources initialization process.
your 2. solution correct, need transactional access.
then need consider both cases/states :
a. singleton started correcty
b. singleton failed @ startup
in other words, sure (1.) statement correct or may interpret lazy-init pattern ?
as @startup occurs when application startup, maybe state on singleton lazy init activation matching needs?
Comments
Post a Comment