• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

To authors

 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Does the book cover the merits of spring over EJB ?
 
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the best source to critizice ejb are the ones by Rod Johnson himself. I am owning Spring in Action and I see the strength of it more in the hands on introduction of the many aspects comprised in the spring framework than a high level architectonical discussion.
 
author
Posts: 422
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Pradeep Bhat:
Does the book cover the merits of spring over EJB ?



Only to some degree. As someone else posted to this thread, Rod Johnson's original J2EE Design & Development does more justice to this topic.

With that said, let me summarize my feelings about Spring vs. EJB:

POJOs are simpler, easier to manage, and easier to test than EJBs. (Note that I'm not saying EJBs are untestable...just that you have to jump through a few more hoops.)

Spring lets you develop an entire application, front-to-back, using POJOs. To be more accurate and pertinent to this discussion, Spring lets you develop your service layer using POJOs--Hibernate and other ORMs let you develop your peristence layer using POJOs.

The main things that EJB brought to the table were declarative transactions, declarative security, and remoting...but you had to do this all within EJB's non-POJO framework. Spring brings declarative transactions to POJOs, using AOP. Acegi (a security framework based on Spring) brings declarative security to POJOs, again using Spring AOP. With regard to remoting, EJBs were accessed locally more often than not, so that may not have been a big deal. But if it is to your project, then Spring also offers several options for remoting, including RMI, Hessian/Burlap, web services, and Spring's own HttpInvoker.

So if Spring lets you do a lot of EJB-like things using POJOs, then what good are EJBs? Well, they certainly lose a lot of their luster when Spring is around. But EJBs still have their place. Perhaps you have a legacy system that exposes services via EJBs. Or perhaps (for political or other non-technical reasons) your project is forced into EJBs. And EJBs also excel at distributed transactions. The good news is that you can still use Spring with EJBs...in two ways:

First, you can develop your EJBs such that they are Spring-aware and thus you can wire Spring beans into your EJBs. This lets you write a session bean that is merely a facade to Spring-managed service beans that do the real work.

Second (and probably the coolest thing) is that you can wire an EJB into your POJOs
without the POJOs being aware that their dealing with an EJB!!! As far as your POJOs are concerned, their talking to another POJO (when, in reality there's an EJB out there). Spring handles everything, include the nasty RemoteExceptions.
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The main things that EJB brought to the table were declarative transactions, declarative security, and remoting...but you had to do this all within EJB's non-POJO framework. Spring brings declarative transactions to POJOs, using AOP. Acegi (a security framework based on Spring) brings declarative security to POJOs, again using Spring AOP. With regard to remoting, EJBs were accessed locally more often than not, so that may not have been a big deal. But if it is to your project, then Spring also offers several options for remoting, including RMI, Hessian/Burlap, web services, and Spring's own HttpInvoker.


Thanks a lot.

Does the Spring framework do any kind of object pooling like the EJB container? Thanks
 
author
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Pradeep Bhat:

Thanks a lot.

Does the Spring framework do any kind of object pooling like the EJB container? Thanks



Yes, Spring does provide a pooling capability through its AOP framework. In broad terms, you configure a ProxyBeanFactory in your application context. The "target" bean of the bean factory is actually a pool of beans (the size of which you can of course configure). Whenever a bean of this type is request from the application context, an instance of one of the pooled beans is returned. You can read the official Spring docs on this feature here:

http://www.springframework.org/docs/reference/aop.html#aop-ts-pool

We do not cover the pooling aspect of Spring's AOP in Spring in Action, and here is why. EJBs do offer pooling. You will use these EJBs in your business and persistence layers of your application. In your Spring application, you will likely be using POJOs to provide these same services (with some AOP thrown in to add features like transaction management). However, these objects will most likely be stateless and threadsade, so pooling is not necessary. You can simply creater singleton Spring beans.

The best pooling scenario we could come up with was connection pooling. This feature is already available through other means, so we opted to leave the pooling feature out of the book - to complex of a topic for too infrequent of a use case.
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. Where can I find the Table of Contents of the book.
 
Ryan Breidenbach
author
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can find the ToC here:

http://www.manning.com/catalog/view.php?book=walls2&item=contents
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ryan. How does Spring compare with other Ioc frameworks?
 
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Is it mentioned somewhere, how to use Hibernate along with the Spring, in the book ? (I could't find it in the index.).

I hope like the other "In Action Series" books, there will be some working example followed by the concept, just touched upon.
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mishra Anshu:
Hi,
Is it mentioned somewhere, how to use Hibernate along with the Spring, in the book ? (I could't find it in the index.).

I hope like the other "In Action Series" books, there will be some working example followed by the concept, just touched upon.



http://www.manning.com/catalog/view.php?book=walls2&item=contents

See 4.4 in the link above
 
Mishra Anshu
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
:roll:

Got it. What about the examples followed by the concept?
I think it must be there.
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mishra.
Try this:
http://www.manning.com/catalog/view.php?book=walls2&item=source
[ April 14, 2005: Message edited by: angelo celeste ]
 
author
Posts: 184
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mishra Anshu:
Hi,
Is it mentioned somewhere, how to use Hibernate along with the Spring, in the book ? (I could't find it in the index.).

I hope like the other "In Action Series" books, there will be some working example followed by the concept, just touched upon.



Yep. As Ryan just said, Hibernate integration with Spring is pretty easy.
The book seems to cover this in less than 5 pages.
 
Craig Walls
author
Posts: 422
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Srikanth Shenoy:


Yep. As Ryan just said, Hibernate integration with Spring is pretty easy.
The book seems to cover this in less than 5 pages.



As Ryan mentioned in another topic, Hibernate integration is very straight forward. You declare a session factory bean, then write DAO objects that extend HibernateDaoSupport. In each of your DAO methods, you write code something like this:




And that's it.

The magic is behind the getHibernateTemplate() method. The Hibernate template looks like a Hibernate session (as far as you DAO is concerned), but it hides the need to deal with HibernateExceptions and it also has hooks into Spring's declarative transaction support.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic