Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Calling EJB's or just regular classes  RSS feed

 
Neil Goldsmith
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm new to EJB's and J2EE and have a question that I can't quite deduce.
In a design I'm looking at, we have an engine that uses session beans to instantiate custom objects that conform to an interface. So for instance, the session beans in the engine will at runtime learn the class information for these custom objects and create them as needed (or do a JNDI lookup). These objects all implement a common interface so the engine knows how to talk to them.
These custom objects will live in the same appserver as the engine and there is no decision around whether or not we want to require these custom objects to be EJB's themselves.
What I'm having trouble with is trying to understand the advantages or disadvantages of having these custom objects as simply java classes or EJB's. If they are regular java objects, then the engine will create them and I'm assuming they will inherit all the advantages of living within the appserver along with the engine's session beans. If they are EJB's themselves and the session bean invokes them, am I only making the engine less efficient, or can these custom EJB objects do more than if I had implemented them as regular java classes? There will be no situation where the custom objects will need to live on another app server.
These custom objects have no use outside the engine, so no other client would ever access them other than the engine.
So what all this lengthy question deduces to: Why would I want to call an EJB (EJB A) from another EJB (EJB B) as opposed to just making EJB A a regular java class?
thanks,
Neil
 
Kishore Dandu
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please refer to "Core J2EE Patterns" book from Sun.
It has some patterns which will guide you to the right direction for your situation.
With respect to EJB or the object by itself, if you are creating the objects based on legacy data or through database info its better to go with Entity beans for transactional security etc.
But you can stick with the session beans accessing the objects in your engine to serve up for the client. It really depends on how these objects are instantiated as I explained above.
Hope it helps.
Kishore.
[ January 18, 2002: Message edited by: Kishore Dandu ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!