| Article: |
Using Dependency Injection in Java EE 5.0 | |
| Subject: | So what's new ? | |
| Date: | 2006-01-05 13:12:24 | |
| From: | DebaPanda | |
|
Response to: So what's new ?
|
||
|
But then the article is missing one element: where do you define the resource ? E.g. where in the new J2EE do you define the real class of which the resource is going to be a runtime instance of? Here is what I've in the article:
|
||
Showing messages 1 through 2 of 2.
-
So what's new ?
2006-01-11 00:28:28 GerritCap [View]
-
So what's new ?
2006-01-06 03:38:56 DavideBaroncelli [View]
I do not have any thing against Spring. I agree it has some demerits against containers like Spring but makes your code and configuration portable across any Java EE container. Spring configuration being proprietary is not portable and you have to stick with Spring.
Uhm. My application runs well on Tomcat, WebSphere and WebLogic, and the only configuration files I have to change when I put it on one server or the other are specific to the implementation of the particular "standard" server: my Spring configuration remains untouched, and Spring actively shields me from part of those platform-specific configuration changes. So, what is the point of talking about the "platform dependence" of a Spring configuration? I use oscache as my caching solution, and so I do rely on a oscache.properties file: this does not make my app less portable. Portability is about different things: portability is about being able to run an APP on different platforms, it is not about being able to switch libraries at any time. Now that you've "standardized hibernate" I will be able to run EJB 3.0 persistence apps by switching the persistence provider when I do change my application server: is this "more portable" than what I can have now by moving my hibernate-based application on different application servers? I strongly doubt so: especially in the first months after the implementations will have come out there will surely be a number of subtle incompatibilities, not to mention the implementation-specific features that will probably be needed to manage more complex cases. I do absolutely agree that something standard like EJB3 persistence was needed, but "portability" is not a good argument for those kinds of standardizations, and the fact that the Spring team, their achievements and their lesson have been ignored in this iteration of JEE is frankly disappointing. I will probably stick with Spring, while doing JEE 5: as you say it's a framework to be used with a JEE container.



Well to me this is conceptually exactly the same as requesting the EJB container for a bean with a certain name although you don't program it that way.
Again if I understand it correctly, setter injection isn't basically that different. The EJB container again sets the resource based upon the name of the setter.
So where is the conceptual difference of looking up a bean by its name or the EJB container binding a resource to your objects based upon your name? This is a very limiting IoC strategy, like having inheritance in a OO language without polymorphism. The basics are there but you don't go all the way. Example what if you have 2 DAO's that programmatically use the same name for a data source resource but in a certain setup they would have to use 2 different datasources.
In a conceptually complete IoC implementation (like Spring) you define a DAO object, you define a datasource and you link (or wire) them together. If tomorrow you need a different datasource for that bean then you wire another datasource to it indepedant of the fact of your original datasource still being used (or wired to) another dao.
Get real: every commercial EJB implementation makes money on you using their implementation so they will add some "features" only available on their platform (which usually makes your life easier in certain situations I agree) but once you use these features typically the cost of migrating to another EJB implementation is enourmous compared to the promise of "portability of EJB's". I know of a highly payed (and thus costly) consultant of company XYZ make a lot of money doing nothing but migrating customers to the XYZ EJB platform.
Gerrit