java ee - Singleton session bean -


  1. singleton session bean has been introduced address problems ?? sharing data common beans ??

  2. how problem managed in ejb 3.0 , versions before ?

  3. if retains client specific conversational state , single instance having clients'(that trying access concurrently) specific data in it?? secure??

  4. if can use static final variables , static initializer block or static methods initialize them (as static variables per class data not per instance data) in other session beans, sharing common data across beans, need of singleton session bean ?

  5. is design have business methods in singleton?? if so, response time client requests served single instance more when served multiple instances.

    moreover, while singleton bean allows concurrent access of single bean instance multiple clients, default lock type (write lock) in default concurrency type (container managed) block other threads accessing bean until method over, , , seems disadvantage right ??

  6. it helpful if give clear & simple usecase no other beans fit singleton bean does

thanks in advance :)

  1. yes.

  2. typically data stored in static variables. static variables not great variety of reasons including unit testing. additionally, static variables require kind of synchronization, , strict reading of ejb spec not allow though in practice worked fine.

  3. typically state stored in singleton not client-specific application-specific. example, caching global configuration state or caching global state database, perhaps refreshing periodic non-persistent timer.

  4. there isn't, see #2.

  5. no, singleton beans not fit request-based business logic. yes, default container concurrency write lock, single thread @ time. should use @lock(read) or @concurrencymanagement(bean) needed.

  6. as mentioned in #3, typically "global" application state needs shared across beans. find singleton session beans useful application configuration , managing application-wide timers.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -