This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inheritance in EJB

 
Vijay S. Rathore
Ranch Hand
Posts: 449
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
 
Vijay S. Rathore
Ranch Hand
Posts: 449
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Pradeep, I have already gone through all the four parts of this article.
My question is different.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "my own interface"
 
Vijay S. Rathore
Ranch Hand
Posts: 449
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 449
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3892
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Vijay S. Rathore
Ranch Hand
Posts: 449
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3892
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 449
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3892
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vijay,
I dont understand why do you need factories?
 
Vijay S. Rathore
Ranch Hand
Posts: 449
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Kyle,
I think I need more study on this case before jumping onto any solution.
 
Juan Rolando Prieur-Reza
Ranch Hand
Posts: 237
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Vijay S. Rathore
Ranch Hand
Posts: 449
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic