java ee - EJB Stateless Initialization Pattern -


i have ejb stateless session bean. have these requirements:

  1. this stateless ejb should initialized @ startup
  2. the initialization code should make transactional access database

the problem is:

  1. @startup available @singleton ejbs
  2. @postconstruct annotation (at least on websphere) doesn't have transactional context @ point initialization code explode here!

possible solutions?

  1. use java ee timer seems designed periodic execution. want 1 execution @ time zero.
  2. use @singleton + @startup ejb initialization purposes , inject singleton ejb dependant stateless ejbs.

question:

  1. can 1 explain how supposed stateless ejb initialized? or has no sense? (i mean, stateless ejb supposed not have initialization state?)
  2. 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

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -