• Post Reply Bookmark Topic Watch Topic
  • New Topic

extends in EJB  RSS feed

 
Karthikeyan Rajendraprasad
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am having a stateless session bean say WorkBean. i want to add new methods, but i cant modify the old one, so can i have the new methods written in a new stateless session bean Work_newBean which extends WorkBean. is it an advisable way to do.
 
Vicky Mohan
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well, i am no expert. But i dont see anything wrong in your implementation. This way, you can access all the methods from your super class. Nothing wrong in this.
 
Siplin Ayishoto
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought the yes or no depends on what is the new functionality you
want to add. Also need to be clear is the options you explored before
choosing inheritance.

-Siplin
 
Eric Pramono
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Karthikeyan,

If you need to access a new method (I assume this is a public method) in a SLSB, I don't think you need to perform the inheritance, unless there's another thing you want from the inheritance. SLSB is similar to a utility class where all its public methods can act on their own regardless of the other public method existence.

My initial suggestion, assuming you need no further advantage from the inheritance, would be to create your method in another SLSB which is totally different, and which does not require any relationship with your previous SLSB.

BTW, just as an additional information, extending an SLSB is rather tricky. Here's an example what needs to be done:
1. Create a new Object interface which extends your super SLSB's Object interface
2. Create a new Home interface which consists of create method of your new bean
3. Create a new Session Bean implementation which extends your super SLSB.
4. In your new SLSB's ejbCreate() method, invoke your super SLSB's ejbCreate() method to provide consistency with your previous callback implementation

And I believe there's still plenty of things to watch out for..
Therefore I'd like to stay away from it, unless I really really have to go that way..

- eric
blog
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!