My Photo

Become a Fan

DailyMile

Google Ad Skyscraper

« Is bundling Spring with an app server a good idea | Main | Design: Making WebSphere components for WAS Z/OS »

October 10, 2005

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d83452595969e200d8346f7a1f53ef

Listed below are links to weblogs that reference JavaEE 5 injection issues:

Comments

Jason Carreira

Great post, thanks! I didn't realize the JEE5 injection stuff was so limited. At least you saved me from wasting time on it...

Back to my Spring POJOs.

Mats Henricson

Yes, a good eye-opener for me too.

Norman Richards

This posting is quite a bite off. EJB3 actually does allow you to inject arbitrary objects into EJB3 components. In fact, I'm willing to bet I could write a spring integration component in 100 or so lines of code or so that would let you inject any spring component into EJB3s. I'll try and post on this myself, if you really don't know how to accomplish it. (feel free to email me) Likewise, Spring could easily be extended to inject EJB3 components. I'd be quite surprised if that doesn't exist already.

Also, if you are curious, EJB3 doesn't require a "heavy environment", unless, of course, your definition of "heavy" is "anything that has anything to do with EJB in any way shape or form". Take a look out our (JBoss) embeddable EJB3 container as one example.

Billy

I'd like to see it. I'm looking at the spec and 15.4 says attribute injection is limited to simple types. No lists/connections and no arbitrary objects. An EJB is not an arbitrary object given the injection framework assumes it always manages construction of the object and can't be made to delegate construction to another part like a factory.

EJB injection always assumes an interface. It doesn't appear that you can inject an Object rather than an interface even for an EJB.

The only injections allowed are simple attributes (15.4), EJB references (15.5) and web services, transactions, resource refs.

Where is the injection for arbitrary POJOs or lists of them etc?

Now, I believe that you've got proprietary extensions in your JBoss stuff to do this, but it isn't in the spec and hence isn't standard which was kind of the point of the post. Opportunity missed.

Billy

Chris Richardson

I blogged about EJB3/Spring integration a while back: http://chris-richardson.blog-city.com/the_ejb_cult_part_3__integrating_spring_and_ejb_30_dependency_injection.htm

Its certainly possible to inject POJOs but I think its far more dificult than it should be. e.g. some kind of API that lets you plug in Spring more directly would be nice.

Corby Page

"Its certainly possible to inject POJOs"

Eh? Your blog says exactly the opposite:

"EJB 3.0 dependency injection has two big limitations. First, it can only inject dependencies into session and message-driven beans - not arbitrary POJOs"

Billy, your observations are spot on. But Rod Johnson and others raised these exact concerns one year ago:

http://forum.springframework.org/viewtopic.php?t=1390

I didn't realize this was coming as news to the general community. There are going to be some disappointed users...

Stephane DUCAS

Hello,

I agree but I think JBOSS-SEAM will solve most of the problem you are pointing...

I would bet on thet fact that SEAM (or it's futur name) will become for JEE5 what struts is for J2EE: necessary...then integrated into JEE6...

SEAM used with EJB3 and JSF's propose a real and complete programing model...and introduce the concept of "dependency bijection"...

So I'm really happy all that JEE5 stuff and addons are at last implemented...and the imperfections will be corrected by comunity and integrated into JEE6...

Good job Community and SUN fot his great JEE5!!

sallami

Hello, I like to know if I can develop the ejb3 with websphere.

Adam

Oh, where to begin....

"a way of eliminating a few lines of code that looked up dependancies in JNDI"

Since JNDI is the central store for distributed applications, this makes perfect sense. You inject from some local repository (spring config) then your system state will not be maintained in a distributed environment.


"So, it's not ideal for backporting in to a standalone library that customers on older versions of application servers (or even didn't have an application server) could also use it"

It's called J_EE_ for a reason, I you want to write libraries, go write them, but JEE is about JEE components.

"You can only add injection annotations to a JavaEE 5 component (i.e. a servlet or EJB)"

Quite true, only first class objects can participate in injection...so yes, only servlets, and ejbs...and filters...and listeners...and jsf managed beans...and intercepters...and message driven beans...and timed beans...and stateless session beans...and stateful session beans...and ejb 3 listeners...etc.etc.etc. Often engineers throw up their hands and go to something like spring without being aware of the full range of core spec technology. If you need something beyond the core spec for an EE app, then I'd probably tell you to go read the spec a bit more.

"t's closed, limited wiring opportunities"

That seems to be the same as the previous point, so I won't go ther e again.

"You can't wire ANY of these to a J2EE application with the injection in the JavaEE 5 spec"

Go back, read the part of the spec on 2.1/3.0 interroperability

"The lesson here is that J2EE needs to start evolving in a similar manner to how the market place is developing these technologies"

The JCP is made up _of_ the market place (yes, even interface21 is there). JEE5 is a bunch more than just injection -- and the fact that injection works primarily with first class types is, in my view, a good thing. It will force developers to learn the specification before throwing up their hands and saying "this is boring, lets go use this cool new IoC container".

EE programming is about $$. Time to market and maintainability. If you're writing banking and insurance software and arguing the architectural beauty of pojo IoC vs spec Ioc then you're kind of missing the point. JEE5 was never about replacing things like spring, it was about making enteprise programming (real enterprise programming, not some little servlet app) easier, and it's done that to a spectacular degree. IoC is a great concept, where it can be used to advantage...but it's not EE programming...spring is only barely starting to catch up to EE with the more advanced needs of large enterprise like integrated security, sso, distribution and scalability, xa, etc etc

In the last 12 months I have architected and coded on 2 spring projects and 1 EE5 project. Cost of delivery and maintainance is significantly lower with EE5 and you get all the enterprise concepts I discussed above thrown in for free. Along with that, you get webservice annotations, security annotations, webstart client delivery...I could go on and on and on.

Anyone reading this post and giving up on JEE5 (and staying with something like spring)...I would say go download netbeans, knock up a quick little multi tier hello world (make sure it's got stateless session beans and message driven beans, jsf and a webservice to ensure you're across the whole spec) and judge for yourself. It think you'll be pleasantly suprised.

Adam Jenkins
SCJP(5.0), SCWCD, SCBCD(EE5), SCEA

The comments to this entry are closed.