Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Singleton and EJB

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all
I have a requirement of having a single EJB object in the EJB tier, this is basically to reduce the time taken to create EJB object as my EJB stores some static valeues.
So I want something like this
From Client side I will look up EJB, say EJB with JNDI name 'A' Then I will get an EJB object say 'objA'
Some other client will lookup the EJB A
Then I should get objA only.
How do I achieve this?
Thanks in anticipation
Mrutyunjay
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could create the ejb as a wrapper to the singleton object. I.e. let the server create as many ejb objects as it wants. Each of them would then have a pointer to the singleton object. Note this prevents you from distributing this component across multiple JVM's.
The preferred choice is to just create a stateless bean and allow the server to create as many beans as it needs. They only get instantiated once and the server can keep them in a pool to be used as needed. This allows the server to scale your application more readily.
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I discuss the stateless session bean wrapper to a singleton (with example code) in this article.
Kyle
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic