| Author |
Ejb and reusablility
|
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
Sorry for asking dumb question. EJB are reusable components but I was not able to reuse EJB created in one project to another? What does reuasble actually mean ?
|
Groovy
|
 |
Chris Mathews
Ranch Hand
Joined: Jul 18, 2001
Posts: 2712
|
|
What prevented its reuse? Code can only ever be reused if it is properly abstracted... this holds true for all types of programming including EJB. Overall, I don't think I have ever considered EJB because they are "reusable". What makes you expect EJB to be anymore reusable then any other code?
|
 |
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
EJB encapsulate business logic and this logic is specific to an application. I feel that that EJB's are not reusable most of the time. Writing a generic code is difficult because we must be able to predict the future. Is it wrong to associate the word "reusable" with EJBs?
|
 |
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
|
|
I think the expectation for reusability was based on the fact that EJB is labeled a component technology and the definition of a component includes the magic word... However, developing reusable components doesn't happen by itself -- simply using a component technology doesn't guarantee anything. The component often needs to be explicitly generalized before it becomes reusable.
|
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
|
 |
Chris Mathews
Ranch Hand
Joined: Jul 18, 2001
Posts: 2712
|
|
Originally posted by Pradeep Bhat: Writing a generic code is difficult because we must be able to predict the future. Is it wrong to associate the word "reusable" with EJBs?
With that reasoning you would also have to say the OOP is also not "reusable".
Originally posted by Lasse Koskela: However, developing reusable components doesn't happen by itself -- simply using a component technology doesn't guarantee anything. The component often needs to be explicitly generalized before it becomes reusable.
Exactly!
|
 |
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
With that reasoning you would also have to say the OOP is also not "reusable".
No. It is difficult to implement inheritance in EJB. I have read the EJB inheritance article from theserverside site but not easy to implement. Is it true that future EJB version will make using inheritance easier? [ August 27, 2003: Message edited by: Pradeep Bhat ] [ August 27, 2003: Message edited by: Pradeep Bhat ]
|
 |
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
|
|
|
I have to admit I haven't really seen the benefit of applying inheritance to EJBs. EJBs are components, and components are service-oriented, not object-oriented. Right?
|
 |
Chris Mathews
Ranch Hand
Joined: Jul 18, 2001
Posts: 2712
|
|
Originally posted by Pradeep Bhat: It is difficult to implement inheritance in EJB.
Ah!!! But inheritance != reuse. I can show you a ton of code that you could inherit from, but which would not be reusable in the context of your application. Furthermore, in many cases composition is a far better option for reuse than inheritance. Regardless, since ejbs are components, reuse is intended to be achieved thru dropping the ejb-jars directly into your application. [ August 27, 2003: Message edited by: Chris Mathews ]
|
 |
Juan Rolando Prieur-Reza
Ranch Hand
Joined: Jun 20, 2003
Posts: 233
|
|
Originally posted by Pradeep Bhat: difficult to implement inheritance in EJB...
Gee, I've always thought that its impossible to inherit EJB's. Its just not the done thing. I'd be delighted if someone would inform us if it is possible (and useful).
|
Juan Rolando Prieur-Reza, M.S., LSSBB, SCEA, SCBCD, SCWCD, SCJP/1.6, IBM OOAD, SCSA
|
 |
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
|
|
|
You can apply inheritance to the EJB implementation class.
|
 |
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
Read this http://www.onjava.com/pub/a/onjava/2002/09/04/ejbinherit.html Yes, I agree EJB are service oriented. Thanks Chris and Lasse. You guys are wonderful!
Originally posted by john prieur: Gee, I've always thought that its impossible to inherit EJB's. Its just not the done thing. I'd be delighted if someone would inform us if it is possible (and useful).
|
 |
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
|
|
|
Actually, my brain-block just untangled... Inheritance for entity beans could be very useful on occasion as far as database mapping is concerned.
|
 |
 |
|
|
subject: Ejb and reusablility
|
|
|