aspose file tools*
The moose likes Websphere and the fly likes Inheritance in EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "Inheritance in EJB" Watch "Inheritance in EJB" New topic
Author

Inheritance in EJB

Vijay S. Rathore
Ranch Hand

Joined: Oct 29, 2001
Posts: 449
I have seen so many articles indicating the support of Inheritance in EJB.
Most of them say that we can implement inheritance by designing a EJB bean extending out of another EJB Bean.
Is there a way by which I can use inheritance using my own interfaces instead of extending out of an EJB Bean?
Any article or link would help.
Vijay


SCJP, SCJD, SCWCD1.4, IBM486, IBM484, IBM 483, IBM 287, IBM141, IBM Certified Enterprise Developer - WebSphere Studio, V5.0
Author of IBM 287 Simulator Exam
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

http://www.onjava.com/pub/a/onjava/2002/09/04/ejbinherit.html


Groovy
Vijay S. Rathore
Ranch Hand

Joined: Oct 29, 2001
Posts: 449
Thanks Pradeep, I have already gone through all the four parts of this article.
My question is different.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

What do you mean by "my own interface"
Vijay S. Rathore
Ranch Hand

Joined: Oct 29, 2001
Posts: 449
For example I want to write a small Interface factory using which I can make the Session Facads to communicate for two different applications.
To elaborate my explanation:
Lets say a company has two different apps. At one point in time the apps want to share some info from each other. Now instead of writing another application (Or forcing both the apps to directly use the session facad of other app), I want to desin a set of Interfaces making a call to the common components from both apps. Making the communication possible. (Similar to a Business Delegate pattern).
Daniel Berg
author
Greenhorn

Joined: Jan 22, 2004
Posts: 5
Creating beans were the interfaces extend other interfaces is quite easy (even without using EJB inheritance). Look at the last page of the EJB creation wizard in WebSphere Studio. This page allows you to extend the remote and/or local interfaces.
Dan
Co-Author of "Enterprise Java (tm) Programming with IBM Websphere, 2nd Edition"
Vijay S. Rathore
Ranch Hand

Joined: Oct 29, 2001
Posts: 449
Thanks Daniel,
You are missing the point again, the wizard tells you how to Inherit from an existing bean.
(BTW which redbook you are refering to. I am answering WRT redbook SG246819, page 448).
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Vijay -- I don't get your point either. You seem to be talking about reflection, not inheritance. Can you provide us with a code example of what you mean?
Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Vijay S. Rathore
Ranch Hand

Joined: Oct 29, 2001
Posts: 449
Ok Let me try to put my requirement again.
I have 2 apps running on two different servers, say app1 on srv1 and app2 on srv2. App1 has an EJB with mutator setAAA(int) and accessor String getBBB(). Whereas App2 has an EJB with accessor int getXXX() and a mutator setYYY(String).
Now app1 needs to access int getXXX() from app2 and set the returned value to setAAA(int) on srv1 and vice versa.
The design that I was trying to implement creates some factory Interfaces that can access any bean from any server and work as a Business Delegate to both apps. But for that my EJB must inherit those interfaces.
Let's say we forget about EJB Inheritance, how do we implement this solution?
Is there a better way to do this or I am going in a wrong direction?
[ January 22, 2004: Message edited by: Vijay S Rathore ]
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
I'm sorry, I still don't understand why you would want a single object to act as a business delegate to two entirely different interfaces. That just doesn't sound like good OO design to me...
Kyle
Vijay S. Rathore
Ranch Hand

Joined: Oct 29, 2001
Posts: 449
Hi Kyle,
Let's say it's a bad design as the apps started developing independently over time in different phases.
Considering an arcitecht joining a company in the middle. Rework is not possible. They are real big apps. The only alternative is to somehow make them communictae.
How would one handle such kind of situation?
[ January 22, 2004: Message edited by: Vijay S Rathore ]
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
This sounds like a need for the Adapter pattern in your business delegates. However, I must admit I'm still struggling to understand exactly the problem. As I mentioned, code might be useful...
Kyle
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Vijay,
I dont understand why do you need factories?
Vijay S. Rathore
Ranch Hand

Joined: Oct 29, 2001
Posts: 449
Thanks Kyle,
I think I need more study on this case before jumping onto any solution.
Juan Rolando Prieur-Reza
Ranch Hand

Joined: Jun 20, 2003
Posts: 236
Originally posted by Vijay S Rathore:
...Is there a way by which I can use inheritance using my own interfaces instead of extending out of an EJB Bean?...

Vijay, At first I thought I understood your question and the answer should have been quite simple. But the explanations became more confusing rather than clearer. It began to sound like you want to implement a component as a front to two other EJBs rather than inheritance at all.
Neverytheless, I can see why you would want to create a non-bean interface or class from and inherit that in more than one different bean as a means of sharing comon code, say.


Juan Rolando Prieur-Reza, M.S., LSSBB, SCEA, SCBCD, SCWCD, SCJP/1.6, IBM OOAD, SCSA
Vijay S. Rathore
Ranch Hand

Joined: Oct 29, 2001
Posts: 449
Well as a matter of fact I was analysing the implementation of one of the ongoing projects trying to put a bridge between two apps, both using EJBs.
As a first step I was trying to understand the written implementation that had already consumed some large no. of men hours. Plus I was looking at the possible ways to resolve it using the existing implementation.
Earlier, I did read one article that mentioned that there are two ways to implement EJB inheritance, but could not relocate/recollect it on web again. So I thought maybe someone here knows a way to do it. (And I presumed maybe the solution lies within there.)
I think as a usual trap, I started analysing it from already imlemented way insted of pullig the thread other way round.
Now as I already mentioned, I will try to analyse it agian and try to use some patterns mentioned in this thread to resolve it.
Thanks everyone for your valuable comments and support.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Inheritance in EJB