• Post Reply Bookmark Topic Watch Topic
  • New Topic

SessionBean to SessionBean call  RSS feed

 
aadhar sharma
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a couple of session beans how can i use the methods of one session bean in the other.

a)can i directly create the instance of one sessionbean class into another
and access it methods.

b)or i need to call it using the interface.

c) or i need to create a common class where i can add the buisness logic
and instantiate that class

d)or if theres some other way to do the above

e)which of them is the best or the worst option and why .

Thanks and Regards

Aadhar Sharma
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our EJB forum...
 
Michael Dirks
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
aadhar,

I don't know the right answer to this, but I've always done (C) - Creating a common class and putting the common methods in that class and instantiating it from the bean.

You can call another bean from inside a bean, but depending on how you set up your access (remotely or locally) you could affect your performance a lot. It's always better to just create a common class in either the EJB project or in a Utility project and call that class.
 
aadhar sharma
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks dude
 
Karthik Janagiraman
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Buddy ,

According to me the right thing to do would be to go through the interface for calling the method in the other session bean.
 
aadhar sharma
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hay Karthik

I know what you are saying is right

but why cant i creat a new object of the session bean thats my Question

people say that i then will not be able to get the services of the

container

but any ways i donot want those services
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!