• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SessionBean to SessionBean call

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to our EJB forum...
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks dude
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic