This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Ejb and reusablility Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Ejb and reusablility" Watch "Ejb and reusablility" New topic
Author

Ejb and reusablility

Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8903

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: 8903

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
    
    5
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: 8903

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
    
    5
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: 235
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
    
    5
You can apply inheritance to the EJB implementation class.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8903

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
    
    5
Actually, my brain-block just untangled... Inheritance for entity beans could be very useful on occasion as far as database mapping is concerned.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ejb and reusablility
 
Similar Threads
EJB 2.0 or 2.1
Many to Many Table Relational Mapping with 3 Tables
Use of Helper classes
What J2EE and EJB version will be taken in Part I?
What IDE Should I use?