users@glassfish.java.net

Re: Deploying Spring Application in GlassFish

From: <glassfish_at_javadesktop.org>
Date: Wed, 19 Mar 2008 06:12:56 PST

In addition to the increased portability of a Spring-based application (which you may or may not find relevant, depending on your situation), Spring's dependency injection is more flexible than what's available through EE 5's (ultimately) JNDI-based injection. The latter makes it easy to inject many EE 5 components (session beans, data sources, persistence units) into other EE 5 components, but the former lets you inject anything you can configure through Spring into anything else you can configure through Spring.

One common scenario where the difference gets important when you're injecting references to expensive-to-initialize "singleton" objects, for example; there's no straightforward way in EJB "3.0" to define such an object as an EE component, while Spring makes that sort of thing easy. Of course, your application's design may not depend on such objects. That's one of the reasons the @Singleton annotation is slated to be in EJB 3.1.
[Message sent by forum member 'adamc' (adamc)]

http://forums.java.net/jive/thread.jspa?messageID=264780